com.ibatis.common.jdbc
Class SimpleDataSource

java.lang.Object
  extended by com.ibatis.common.jdbc.SimpleDataSource
所有已实现接口:
javax.sql.DataSource

public class SimpleDataSource
extends java.lang.Object
implements javax.sql.DataSource

This is a simple, synchronous, thread-safe database connection pool.

REQUIRED PROPERTIES ------------------- JDBC.Driver JDBC.ConnectionURL JDBC.Username JDBC.Password

Pool.MaximumActiveConnections Pool.MaximumIdleConnections Pool.MaximumCheckoutTime Pool.TimeToWait Pool.PingQuery Pool.PingEnabled Pool.PingConnectionsOlderThan Pool.PingConnectionsNotUsedFor Pool.QuietMode


嵌套类摘要
static class SimpleDataSource.SimplePooledConnection
          --------------------------------------------------------------------------------------- SimplePooledConnection ---------------------------------------------------------------------------------------
 
构造器摘要
SimpleDataSource(java.util.Map props)
          Constructor to allow passing in a map of properties for configuration
 
方法摘要
protected  void finalize()
           
 void forceCloseAll()
          Closes all of the connections in the pool
 long getAverageCheckoutTime()
          Getter for the average age of a connection checkout
 long getAverageOverdueCheckoutTime()
          Getter for the average age of overdue connections
 long getAverageRequestTime()
          Getter for the average time required to get a connection to the database
 long getAverageWaitTime()
          Getter for the average time spent waiting for connections that were in use
 long getBadConnectionCount()
          Getter for the number of invalid connections that were found in the pool
 long getClaimedOverdueConnectionCount()
          Getter for the number of connections that were claimed before they were returned
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
           
 long getHadToWaitCount()
          Getter for the number of requests that had to wait for connections that were in use
 java.lang.String getJdbcDriver()
          Getter for the name of the JDBC driver class used
 java.lang.String getJdbcPassword()
          Getter for the JDBC password used
 java.lang.String getJdbcUrl()
          Getter of the JDBC URL used
 java.lang.String getJdbcUsername()
          Getter for the JDBC user name used
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 int getPoolMaximumActiveConnections()
          Getter for the maximum number of active connections
 int getPoolMaximumCheckoutTime()
          Getter for the maximum time a connection can be used before it *may* be given away again.
 int getPoolMaximumIdleConnections()
          Getter for the maximum number of idle connections
 int getPoolPingConnectionsNotUsedFor()
          If a connection has not been used in this many milliseconds, ping the database to make sure the connection is still good.
 int getPoolPingConnectionsOlderThan()
          Getter for the age of connections that should be pinged before using
 java.lang.String getPoolPingQuery()
          Getter for the query to be used to check a connection
 int getPoolTimeToWait()
          Getter for the time to wait before retrying to get a connection
 long getRequestCount()
          Getter for the number of connection requests made
 java.lang.String getStatus()
          Returns the status of the connection pool
 boolean isPoolPingEnabled()
          Getter to tell if we should use the ping query
 void setLoginTimeout(int loginTimeout)
           
 void setLogWriter(java.io.PrintWriter logWriter)
           
static java.sql.Connection unwrapConnection(java.sql.Connection conn)
          Unwraps a pooled connection to get to the 'real' connection
 
类方法继承: java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造器详细信息

SimpleDataSource

public SimpleDataSource(java.util.Map props)
Constructor to allow passing in a map of properties for configuration

参数:
props - - the configuration parameters
方法详细信息

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
规范说明:
getConnection in interface javax.sql.DataSource
抛出异常:
java.sql.SQLException
另请参见:
DataSource.getConnection()

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
规范说明:
getConnection in interface javax.sql.DataSource
抛出异常:
java.sql.SQLException
另请参见:
DataSource.getConnection(java.lang.String, java.lang.String)

setLoginTimeout

public void setLoginTimeout(int loginTimeout)
                     throws java.sql.SQLException
规范说明:
setLoginTimeout in interface javax.sql.DataSource
抛出异常:
java.sql.SQLException
另请参见:
DataSource.setLoginTimeout(int)

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
规范说明:
getLoginTimeout in interface javax.sql.DataSource
抛出异常:
java.sql.SQLException
另请参见:
DataSource.getLoginTimeout()

setLogWriter

public void setLogWriter(java.io.PrintWriter logWriter)
                  throws java.sql.SQLException
规范说明:
setLogWriter in interface javax.sql.DataSource
抛出异常:
java.sql.SQLException
另请参见:
DataSource.setLogWriter(java.io.PrintWriter)

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
规范说明:
getLogWriter in interface javax.sql.DataSource
抛出异常:
java.sql.SQLException
另请参见:
DataSource.getLogWriter()

getPoolPingConnectionsNotUsedFor

public int getPoolPingConnectionsNotUsedFor()
If a connection has not been used in this many milliseconds, ping the database to make sure the connection is still good.

返回:
the number of milliseconds of inactivity that will trigger a ping

getJdbcDriver

public java.lang.String getJdbcDriver()
Getter for the name of the JDBC driver class used

返回:
The name of the class

getJdbcUrl

public java.lang.String getJdbcUrl()
Getter of the JDBC URL used

返回:
The JDBC URL

getJdbcUsername

public java.lang.String getJdbcUsername()
Getter for the JDBC user name used

返回:
The user name

getJdbcPassword

public java.lang.String getJdbcPassword()
Getter for the JDBC password used

返回:
The password

getPoolMaximumActiveConnections

public int getPoolMaximumActiveConnections()
Getter for the maximum number of active connections

返回:
The maximum number of active connections

getPoolMaximumIdleConnections

public int getPoolMaximumIdleConnections()
Getter for the maximum number of idle connections

返回:
The maximum number of idle connections

getPoolMaximumCheckoutTime

public int getPoolMaximumCheckoutTime()
Getter for the maximum time a connection can be used before it *may* be given away again.

返回:
The maximum time

getPoolTimeToWait

public int getPoolTimeToWait()
Getter for the time to wait before retrying to get a connection

返回:
The time to wait

getPoolPingQuery

public java.lang.String getPoolPingQuery()
Getter for the query to be used to check a connection

返回:
The query

isPoolPingEnabled

public boolean isPoolPingEnabled()
Getter to tell if we should use the ping query

返回:
True if we need to check a connection before using it

getPoolPingConnectionsOlderThan

public int getPoolPingConnectionsOlderThan()
Getter for the age of connections that should be pinged before using

返回:
The age

getRequestCount

public long getRequestCount()
Getter for the number of connection requests made

返回:
The number of connection requests made

getAverageRequestTime

public long getAverageRequestTime()
Getter for the average time required to get a connection to the database

返回:
The average time

getAverageWaitTime

public long getAverageWaitTime()
Getter for the average time spent waiting for connections that were in use

返回:
The average time

getHadToWaitCount

public long getHadToWaitCount()
Getter for the number of requests that had to wait for connections that were in use

返回:
The number of requests that had to wait

getBadConnectionCount

public long getBadConnectionCount()
Getter for the number of invalid connections that were found in the pool

返回:
The number of invalid connections

getClaimedOverdueConnectionCount

public long getClaimedOverdueConnectionCount()
Getter for the number of connections that were claimed before they were returned

返回:
The number of connections

getAverageOverdueCheckoutTime

public long getAverageOverdueCheckoutTime()
Getter for the average age of overdue connections

返回:
The average age

getAverageCheckoutTime

public long getAverageCheckoutTime()
Getter for the average age of a connection checkout

返回:
The average age

getStatus

public java.lang.String getStatus()
Returns the status of the connection pool

返回:
The status

forceCloseAll

public void forceCloseAll()
Closes all of the connections in the pool


unwrapConnection

public static java.sql.Connection unwrapConnection(java.sql.Connection conn)
Unwraps a pooled connection to get to the 'real' connection

参数:
conn - - the pooled connection to unwrap
返回:
The 'real' connection

finalize

protected void finalize()
                 throws java.lang.Throwable
重写:
finalize in class java.lang.Object
抛出异常:
java.lang.Throwable