Programmer Guide : solidDB® JDBC Driver : JDBC 2.0 optional package API support : JDBC connection pooling
  
JDBC connection pooling
The JDBC 2.0 Standard Extension API specifies that users can implement a pooling technique by using specific caching or pooling algorithms that best suit their needs. solidDB®provides classes that implement the standard ConnectionPoolDataSource and PooledConnection interfaces.
solidDB® implements these classes as follows:
ConnectionPoolDataSource
A javax.sql.ConnectionPoolDataSource interface serves as a resource manager connection factory for pooled java.sql.Connection objects. solidDB® provides the implementation for that interface in class SolidConnectionPoolDataSource. For API functions, see ConnectionPoolDataSource API functions.
PooledConnection
A javax.sql.PooledConnection interface encapsulates the physical connection to a database. solidDB® provides the implementation for that interface in class SolidPooledConnection. For API functions, see PooledConnection API functions.
solidDB® does not provide an implementation for the actual connection pool; the data structure and the logic to actually pool the PooledConnection instances are not available. You must implement your own connection pooling logic, that is, a class that actually pools the connections.
ConnectionPoolDataSource API functions
The public class SolidConnectionPoolDataSource implements javax.sql.ConnectionPoolDataSource. The API functions for javax.sql.ConnectionPoolDataSource interface are described as follows:
Description type
Description
Function Name
Constructor
Function Type
solidDB® proprietary API
Description
Initializes class variables
Parameters
None
Return value
None
Syntax and exceptions
public SolidConnectionPoolDataSource()
Constructor
Description type
Description
Function Name
Constructor
Function Type
solidDB® proprietary API
Description
Initializes class variables
Parameters
url As String which identifies the DB server
Return value
None
Syntax and exceptions
public SolidConnectionPoolDataSource(String urlStr)
setDescription
Description type
Description
Function Name
setDescription
Function Type
solidDB® proprietary API
Description
This function sets the description string.
Parameters
description string (descString)
Return value
None
Syntax and exceptions
public void setDescription(String descString)
getDescription
Description type
Description
Function Name
getDescription
Function Type
solidDB® proprietary API
Description
This function returns the description string.
Parameters
None
Return value
returns a String (description)
Syntax and exceptions
public String getDescription()
setURL
Description type
Description
Function Name
setURL
Function Type
solidDB® proprietary API
Description
This function sets the url string which points to an solidDB® server.
Parameters
url string (urlStr)
Return value
None
Syntax and exceptions
public void setURL(String urlStr)
getURL
Description type
Description
Function Name
getURL
Function Type
solidDB® proprietary API
Description
This function returns the DB url string.
Parameters
None
Return value
returns a String (url)
Syntax and exceptions
public String getURL()
setUser
Description type
Description
Function Name
setUser
Function Type
solidDB® proprietary API
Description
This function sets the username string. (WebSphere compatibility)
Parameters
username string
Return value
None
Syntax and exceptions
public void setUser(String newUser)
getUser
Description type
Description
Function Name
getUser
Function Type
solidDB® proprietary API
Description
This function returns the username string. (WebSphere compatibility)
Parameters
None
Return value
returns a String (username)
Syntax and exceptions
public String getUser()
setPassword
Description type
Description
Function Name
setPassword
Function Type
solidDB® proprietary API
Description
This function sets the password string. (WebSphere compatibility)
Parameters
password string
Return value
None
Syntax and exceptions
public void setPassword(String newPassword)
getPassword
Description type
Description
Function Name
getPassword
Function Type
solidDB® proprietary API
Description
This function returns the password string. (WebSphere compatibility)
Parameters
None
Return value
returns a String (password)
Syntax and exceptions
public String getPassword()
setConnectionURL
Description type
Description
Function Name
setConnectionURL
Function Type
solidDB® proprietary API
Description
This function sets the url string which points to an solidDB® server.
Parameters
url string
Return value
None
Syntax and exceptions
public void setConnectionURL(String newUrl)
getConnectionURL
Description type
Description
Function Name
getConnectionURL
Function Type
solidDB® proprietary API
Description
This function returns the url string.
Parameters
None
Return value
returns a String (url)
Syntax and exceptions
public String getConnectionURL()
getLoginTimeout
Description type
Description
Function Name
getLoginTimeout
Function Type
javax.sql.ConnectionPoolDataSource API
Description
This function returns the login timeout value.
Parameters
None
Return value
returns a timeout value as an integer (seconds)
Syntax and exceptions
public int getLoginTimeout() throws java.sql.SQLException
getLogWriter
Description type
Description
Function Name
getLogWriter
Function Type
javax.sql.ConnectionPoolDataSource API
Description
This function returns the handle to a writer used for printing debugging messages.
Parameters
None
Return value
returns a handle to java.io.PrintWriter
Syntax and exceptions
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getPooledConnection
Description type
Description
Function Name
getPooledConnection
Function Type
javax.sql.ConnectionPoolDataSource API
Description
This function returns a PooledConnection object from the connection pool. This object has a valid connection to the database server.
Parameters
None
Return value
returns a PooledConnection object.
Syntax and exceptions
public javax.sql.PooledConnection getPooledConnection() throws java.sql.SQLException
getPooledConnection
Description type
Description
Function Name
getPooledConnection
Function Type
javax.sql.ConnectionPoolDataSource API
Description
This function returns a PooledConnection object from the connection pool. This object has a valid connection to the database server.
Parameters
user (username as String), password (password as String)
Return value
returns a PooledConnection object.
Syntax and exceptions
public javax.sql.PooledConnection getPooledConnection(String user, String password)
throws java.sql.SQLException
setLoginTimeout
Description type
Description
Function Name
setLoginTimeout
Function Type
javax.sql.ConnectionPoolDataSource API
Description
This function sets the login timeout value in seconds
Parameters
seconds (as integer)
Return value
None
Syntax and exceptions
public void setLoginTimeout(int seconds)
set Log Writer
Description type
Description
Function Name
set Log Writer
Function Type
javax.sql.ConnectionPoolDataSource API
Description
This function sets the handle to a writer object that will be used to print/log debug messages.
Parameters
handle to java.io.PrintWriter
Return value
None
Syntax and exceptions
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
PooledConnection API functions
The public class SolidPooledConnection implements javax.sql.PooledConnection. The API functions for javax.sql.PooledConnection interface are:
add Connection Event Listener
Description type
Description
Function Name
add Connection Event Listener
Function Type
javax.sql.PooledConnection API
Description
Adds an event listener to whom this object should notify when it wants to release the connection. This listener is generally the connection pooling module.
Parameters
listener (handle to javax.sql.ConnectionEventListener)
Return value
None
Syntax and exceptions
public void add Connection Event Listener(javax.sql.ConnectionEventListener listener)
close
Description type
Description
Function Name
close
Function Type
javax.sql.PooledConnection API
Description
This function closes the physical connection.
Parameters
None
Return value
None
Syntax and exceptions
public void close()
throws java.sql.SQLException
getConnection
Description type
Description
Function Name
getConnection
Function Type
javax.sql.PooledConnection API
Description
returns a handle to java.sql.Connection
Parameters
None
Return value
java.sql.Connection
Syntax and exceptions
public java.sql.Connection getConnection() throws java.sql.SQLException
removeConnectionEventListener
Description type
Description
Function Name
removeConnectionEventListener
Function Type
javax.sql.PooledConnection API
Description
This function removes the reference to the listener
Parameters
listener
Return value
None
Syntax and exceptions
public void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
See also
JDBC 2.0 optional package API support