|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectproper.core.ProperObject
proper.database.Connector
public class Connector
This class connects to a given SQL database (standard is MySQL).
Field Summary | |
---|---|
static java.lang.String |
MYSQL_DRIVER
the standard driver for MySQL |
static java.lang.String |
MYSQL_LIMIT
the standard limit SQL statement, containing "%ROWS%" as placeholder for the number of rows |
static java.lang.String |
MYSQL_PASSWORD
the standard user, used with no password |
static java.lang.String |
MYSQL_URL
the standard url |
static java.lang.String |
MYSQL_USER
the standard user, used with no password |
static java.lang.String |
ROWS
the placeholder for the number of rows in the LIMIT string |
Fields inherited from interface proper.core.ProperInterface |
---|
VERSION |
Constructor Summary | |
---|---|
Connector()
initializes the object (it initializes with the MySQL driver) |
|
Connector(java.lang.String url,
java.lang.String database)
connects with the MySQL-Driver to the given host/database |
|
Connector(java.lang.String url,
java.lang.String database,
java.lang.String user)
connects with the MySQL-Driver to the given host/database w/o password |
|
Connector(java.lang.String url,
java.lang.String database,
java.lang.String user,
java.lang.String password)
connects with the MySQL-Driver to the given host/database with user/pw |
|
Connector(java.lang.String driver,
java.lang.String url,
java.lang.String database,
java.lang.String user,
java.lang.String password)
connects to the database with the given driver, url, etc. |
Method Summary | |
---|---|
boolean |
connect()
connects the with current parameters to the database, does an automatic disconnect |
boolean |
connect(java.lang.String driver,
java.lang.String url,
java.lang.String database,
java.lang.String user,
java.lang.String password)
connects to the database with given data |
void |
disconnect()
disconnects from the database |
java.sql.Connection |
getConnection()
returns the connection |
java.lang.String |
getDatabase()
returns the database |
java.lang.String |
getDriver()
returns the driver name |
java.lang.String |
getLimit()
returns the current set limit string for a select with a certain amount of rows |
java.lang.String |
getLimit(int count)
returns the current set limit string for a select with the given amount of rows |
java.lang.String |
getPassword()
returns the password |
java.lang.String |
getUrl()
returns the url |
java.lang.String |
getUser()
returns the user |
boolean |
isConnected()
checks whether the connection is open or not |
void |
setLimit(java.lang.String limit)
sets the String that limits the select to a number of rows, e.g. in MySQL it is done with "LIMIT %ROWS%" and it Oracle with "WHERE ROWCOUNT <= %ROWS%" |
java.lang.String |
toString()
returns parameters in a string representation |
Methods inherited from class proper.core.ProperObject |
---|
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MYSQL_DRIVER
public static final java.lang.String MYSQL_USER
public static final java.lang.String MYSQL_PASSWORD
public static final java.lang.String MYSQL_URL
public static final java.lang.String ROWS
setLimit(String)
,
Constant Field Valuespublic static final java.lang.String MYSQL_LIMIT
ROWS
,
setLimit(String)
,
Constant Field ValuesConstructor Detail |
---|
public Connector() throws java.lang.Exception
java.lang.Exception
public Connector(java.lang.String url, java.lang.String database) throws java.lang.Exception
url
- the url consists of jdbc:subprotocol://host[:port]/database
- the database to use
java.lang.Exception
public Connector(java.lang.String url, java.lang.String database, java.lang.String user) throws java.lang.Exception
url
- the url consists of jdbc:subprotocol://host[:port]/database
- the database to useuser
- the user to connect as
java.lang.Exception
public Connector(java.lang.String url, java.lang.String database, java.lang.String user, java.lang.String password) throws java.lang.Exception
url
- the url consists of jdbc:subprotocol://host[:port]/database
- the database to useuser
- the user to connect aspassword
- the corresponding password
java.lang.Exception
public Connector(java.lang.String driver, java.lang.String url, java.lang.String database, java.lang.String user, java.lang.String password) throws java.lang.Exception
driver
- the class to use as driverurl
- the url consists of jdbc:subprotocol://host[:port]/database
- the database to useuser
- the user to connect aspassword
- the corresponding password
java.lang.Exception
Method Detail |
---|
public boolean connect()
public boolean connect(java.lang.String driver, java.lang.String url, java.lang.String database, java.lang.String user, java.lang.String password)
driver
- the class to use as driverurl
- the url consists of jdbc:subprotocol://host[:port]/database
- the database to useuser
- the user to connect aspassword
- the corresponding password
public void disconnect() throws java.lang.Exception
java.lang.Exception
public boolean isConnected() throws java.lang.Exception
java.lang.Exception
public java.lang.String getDriver()
public java.lang.String getUrl()
public java.lang.String getDatabase()
public java.lang.String getUser()
public java.lang.String getPassword()
public java.sql.Connection getConnection()
public void setLimit(java.lang.String limit)
MYSQL_LIMIT
,
ROWS
public java.lang.String getLimit()
MYSQL_LIMIT
,
ROWS
public java.lang.String getLimit(int count)
MYSQL_LIMIT
,
ROWS
public java.lang.String toString()
toString
in class ProperObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |