Openfire 3.5.2 Javadoc

org.jivesoftware.database
Class DefaultConnectionProvider

java.lang.Object
  extended by org.jivesoftware.database.DefaultConnectionProvider
All Implemented Interfaces:
ConnectionProvider

public class DefaultConnectionProvider
extends Object
implements ConnectionProvider

Default Jive connection provider, which uses an internal connection pool.

Author:
Jive Software

Constructor Summary
DefaultConnectionProvider()
          Creates a new DefaultConnectionProvider.
 
Method Summary
 void destroy()
          Tells the connection provider to destroy itself.
 Connection getConnection()
          Returns a database connection.
 double getConnectionTimeout()
          Returns the amount of time between connection recycles in days.
 String getDriver()
          Returns the JDBC driver classname used to make database connections.
 int getMaxConnections()
          Returns the maximum number of connections that the pool will use.
 int getMinConnections()
          Returns the minimum number of connections that the pool will use.
 String getPassword()
          Returns the password used to connect to the database.
 String getServerURL()
          Returns the JDBC connection URL used to make database connections.
 Boolean getTestAfterUse()
          Returns whether returned connections will be tested after being returned to the pool.
 Boolean getTestBeforeUse()
          Returns whether returned connections will be tested before being handed over to be used.
 String getTestSQL()
          Returns the SQL statement used to test if a connection is valid.
 String getUsername()
          Returns the username used to connect to the database.
 boolean isMysqlUseUnicode()
           
 boolean isPooled()
          Returns true if this connection provider provides connections out of a connection pool.
 void restart()
          This method should be called whenever properties have been changed so that the changes will take effect.
 void setConnectionTimeout(double connectionTimeout)
          Sets the amount of time between connection recycles in days.
 void setDriver(String driver)
          Sets the JDBC driver classname used to make database connections.
 void setMaxConnections(int maxConnections)
          Sets the maximum number of connections that the pool will use.
 void setMinConnections(int minConnections)
          Sets the minimum number of connections that the pool will use.
 void setPassword(String password)
          Sets the password used to connect to the database.
 void setServerURL(String serverURL)
          Sets the JDBC connection URL used to make database connections.
 void setTestAfterUse(Boolean testAfterUse)
          Sets whether connections will be tested after being returned to the pool.
 void setTestBeforeUse(Boolean testBeforeUse)
          Sets whether connections will be tested before being handed over to be used.
 void setTestSQL(String testSQL)
          Sets the SQL statement used to test if a connection is valid.
 void setUsername(String username)
          Sets the username used to connect to the database.
 void start()
          Starts the connection provider.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultConnectionProvider

public DefaultConnectionProvider()
Creates a new DefaultConnectionProvider.

Method Detail

isPooled

public boolean isPooled()
Description copied from interface: ConnectionProvider
Returns true if this connection provider provides connections out of a connection pool. Implementing and using connection providers that are pooled is strongly recommended, as they greatly increase the speed of Jive.

Specified by:
isPooled in interface ConnectionProvider
Returns:
true if the Connection objects returned by this provider are pooled.

getConnection

public Connection getConnection()
                         throws SQLException
Description copied from interface: ConnectionProvider
Returns a database connection. When a Jive component is done with a connection, it will call the close method of that connection. Therefore, connection pools with special release methods are not directly supported by the connection provider infrastructure. Instead, connections from those pools should be wrapped such that calling the close method on the wrapper class will release the connection from the pool.

Specified by:
getConnection in interface ConnectionProvider
Returns:
a Connection object.
Throws:
SQLException - is an SQL error occured while retrieving the connection.

start

public void start()
Description copied from interface: ConnectionProvider
Starts the connection provider. For some connection providers, this will be a no-op. However, connection provider users should always call this method to make sure the connection provider is started.

Specified by:
start in interface ConnectionProvider

restart

public void restart()
Description copied from interface: ConnectionProvider
This method should be called whenever properties have been changed so that the changes will take effect.

Specified by:
restart in interface ConnectionProvider

destroy

public void destroy()
Description copied from interface: ConnectionProvider
Tells the connection provider to destroy itself. For many connection providers, this will essentially result in a no-op. However, connection provider users should always call this method when changing from one connection provider to another to ensure that there are no dangling database connections.

Specified by:
destroy in interface ConnectionProvider

getDriver

public String getDriver()
Returns the JDBC driver classname used to make database connections. For example: com.mysql.jdbc.Driver

Returns:
the JDBC driver classname.

setDriver

public void setDriver(String driver)
Sets the JDBC driver classname used to make database connections. For example: com.mysql.jdbc.Driver

Parameters:
driver - the fully qualified JDBC driver name.

getServerURL

public String getServerURL()
Returns the JDBC connection URL used to make database connections.

Returns:
the JDBC connection URL.

setServerURL

public void setServerURL(String serverURL)
Sets the JDBC connection URL used to make database connections.

Parameters:
serverURL - the JDBC connection URL.

getUsername

public String getUsername()
Returns the username used to connect to the database. In some cases, a username is not needed so this method will return null.

Returns:
the username used to connect to the datbase.

setUsername

public void setUsername(String username)
Sets the username used to connect to the database. In some cases, a username is not needed so null should be passed in.

Parameters:
username - the username used to connect to the database.

getPassword

public String getPassword()
Returns the password used to connect to the database. In some cases, a password is not needed so this method will return null.

Returns:
the password used to connect to the database.

setPassword

public void setPassword(String password)
Sets the password used to connect to the database. In some cases, a password is not needed so null should be passed in.

Parameters:
password - the password used to connect to the database.

getMinConnections

public int getMinConnections()
Returns the minimum number of connections that the pool will use. This should probably be at least three.

Returns:
the minimum number of connections in the pool.

setMinConnections

public void setMinConnections(int minConnections)
Sets the minimum number of connections that the pool will use. This should probably be at least three.

Parameters:
minConnections - the minimum number of connections in the pool.

getMaxConnections

public int getMaxConnections()
Returns the maximum number of connections that the pool will use. The actual number of connections in the pool will vary between this value and the minimum based on the current load.

Returns:
the max possible number of connections in the pool.

setMaxConnections

public void setMaxConnections(int maxConnections)
Sets the maximum number of connections that the pool will use. The actual number of connections in the pool will vary between this value and the minimum based on the current load.

Parameters:
maxConnections - the max possible number of connections in the pool.

getConnectionTimeout

public double getConnectionTimeout()
Returns the amount of time between connection recycles in days. For example, a value of .5 would correspond to recycling the connections in the pool once every half day.

Returns:
the amount of time in days between connection recycles.

setConnectionTimeout

public void setConnectionTimeout(double connectionTimeout)
Sets the amount of time between connection recycles in days. For example, a value of .5 would correspond to recycling the connections in the pool once every half day.

Parameters:
connectionTimeout - the amount of time in days between connection recycles.

getTestSQL

public String getTestSQL()
Returns the SQL statement used to test if a connection is valid.

Returns:
the SQL statement that will be run to test a connection.

setTestSQL

public void setTestSQL(String testSQL)
Sets the SQL statement used to test if a connection is valid. House keeping and before/after connection tests make use of this. This should be something that causes the minimal amount of work by the database server and is as quick as possible.

Parameters:
testSQL - the SQL statement that will be run to test a connection.

getTestBeforeUse

public Boolean getTestBeforeUse()
Returns whether returned connections will be tested before being handed over to be used.

Returns:
True if connections are tested before use.

setTestBeforeUse

public void setTestBeforeUse(Boolean testBeforeUse)
Sets whether connections will be tested before being handed over to be used.

Parameters:
testBeforeUse - True or false if connections are to be tested before use.

getTestAfterUse

public Boolean getTestAfterUse()
Returns whether returned connections will be tested after being returned to the pool.

Returns:
True if connections are tested after use.

setTestAfterUse

public void setTestAfterUse(Boolean testAfterUse)
Sets whether connections will be tested after being returned to the pool.

Parameters:
testAfterUse - True or false if connections are to be tested after use.

isMysqlUseUnicode

public boolean isMysqlUseUnicode()

toString

public String toString()
Overrides:
toString in class Object

Openfire 3.5.2 Javadoc

Copyright © 2003-2007 Jive Software.