|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.liquidsite.util.db.DatabaseConnector
A database connector. The database connector manages all connections to the database, pooling resources as desired. By default connection pooling is not used, but is may be activated by modifying the pool size.
| Field Summary | |
static long |
DEFAULT_CONNECTION_TIMEOUT
The default connection timeout in milliseconds. |
static int |
DEFAULT_QUERY_TIMEOUT
The default query timeout in seconds. |
| Constructor Summary | |
DatabaseConnector(java.lang.String url)
Creates a new database connector. |
|
DatabaseConnector(java.lang.String url,
java.util.Properties properties)
Creates a new database connector. |
|
| Method Summary | |
DatabaseResults |
execute(DatabaseQuery query)
Executes a database query or statement. |
void |
execute(java.io.File file)
Executes a set of SQL statements from a file. |
DatabaseConnection |
getConnection()
Returns a database connection. |
long |
getConnectionTimeout()
Returns the database connection expiration timeout. |
int |
getPoolSize()
Returns the maximum database connection pool size. |
java.util.Properties |
getProperties()
Returns the database connector properties. |
java.lang.String |
getProperty(java.lang.String name)
Returns a specified database connector property. |
java.lang.String |
getUrl()
Returns the JDBC database URL. |
static void |
loadDriver(java.lang.String driver)
Loads the specified JDBC database driver. |
void |
loadFunctions(java.io.File file)
Loads a set of database functions. |
void |
returnConnection(DatabaseConnection con)
Disposes of a database connection. |
void |
setConnectionTimeout(long timeout)
Sets the database connection expiration timeout. |
void |
setPoolSize(int size)
Sets the maximum database connection pool size. |
void |
setProperty(java.lang.String name,
java.lang.String value)
Sets the specified database connector property. |
java.lang.String |
toString()
Returns a string representation of this object. |
void |
update()
Updates the connection pool. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final long DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_QUERY_TIMEOUT
DatabaseConnection.setQueryTimeout(int),
Constant Field Values| Constructor Detail |
public DatabaseConnector(java.lang.String url)
url - the JDBC database URL
public DatabaseConnector(java.lang.String url,
java.util.Properties properties)
url - the JDBC database URLproperties - the JDBC database properties| Method Detail |
public static void loadDriver(java.lang.String driver)
throws DatabaseConnectionException
driver - the fully qualified classname
DatabaseConnectionException - if the class couldn't be
found or loaded correctlypublic java.lang.String toString()
public java.lang.String getUrl()
public java.lang.String getProperty(java.lang.String name)
name - the property name
public java.util.Properties getProperties()
public void setProperty(java.lang.String name,
java.lang.String value)
name - the property namevalue - the property valuepublic long getConnectionTimeout()
setConnectionTimeout(long),
DEFAULT_CONNECTION_TIMEOUTpublic void setConnectionTimeout(long timeout)
timeout - the new connection timeout (in milliseconds), or
a negative value for unlimitedgetConnectionTimeout()public int getPoolSize()
setPoolSize(int)public void setPoolSize(int size)
size - the new maximum connection pool sizegetPoolSize()
public DatabaseConnection getConnection()
throws DatabaseConnectionException
DatabaseConnectionException - if a database connection
couldn't be establishedreturnConnection(org.liquidsite.util.db.DatabaseConnection)public void returnConnection(DatabaseConnection con)
con - the database connectiongetConnection()
public void loadFunctions(java.io.File file)
throws java.io.FileNotFoundException,
java.io.IOException
file - the file containing the functions
java.io.FileNotFoundException - if the file couldn't be found
java.io.IOException - if the file couldn't be read properly
public void update()
throws DatabaseConnectionException
DatabaseConnectionException - if a database connection
couldn't be established
public DatabaseResults execute(DatabaseQuery query)
throws DatabaseConnectionException,
DatabaseException
query - the database query
DatabaseConnectionException - if a database connection
couldn't be established
DatabaseException - if the query or statement couldn't
be executed correctly
public void execute(java.io.File file)
throws java.io.FileNotFoundException,
java.io.IOException,
DatabaseConnectionException,
DatabaseException
file - the file with SQL statements
java.io.FileNotFoundException - if the file couldn't be found
java.io.IOException - if the file couldn't be read properly
DatabaseConnectionException - if a database connection
couldn't be established
DatabaseException - if some statement couldn't be
executed correctly
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||