public class OceanBasePoolDataSource extends OceanBaseDataSource implements ConnectionPoolDataSource, XADataSource, Closeable, AutoCloseable
connectTimeoutInMs, database, hostname, password, port, url, user| 构造器和说明 |
|---|
OceanBasePoolDataSource()
Default constructor. hostname will be localhost, port 3306.
|
OceanBasePoolDataSource(String url) |
OceanBasePoolDataSource(String hostname,
int port,
String database)
Constructor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
Close datasource.
|
int |
getLoginTimeout()
Gets the maximum time in seconds that this data source can wait while attempting to connect to
a database.
|
PrintWriter |
getLogWriter()
Retrieves the log writer for this
DataSource object. |
int |
getMaxIdleTime()
Max time a connection can be idle.
|
int |
getMaxPoolSize()
Pool maximum connection size.
|
int |
getMinPoolSize()
Get minimum pool size (pool will grow at creation untile reaching this size).
|
Logger |
getParentLogger() |
PooledConnection |
getPooledConnection()
Attempts to establish a physical database connection that can be used as a pooled connection.
|
PooledConnection |
getPooledConnection(String user,
String password)
Attempts to establish a physical database connection that can be used as a pooled connection.
|
String |
getPoolName() |
Integer |
getPoolValidMinDelay()
If connection has been used in less time than poolValidMinDelay, then no connection validation
will be done (0=mean validation every time).
|
int |
getPortNumber()
Returns the port number.
|
Boolean |
getStaticGlobal() |
protected UrlParser |
getUrlParser()
For testing purpose only.
|
XAConnection |
getXAConnection() |
XAConnection |
getXAConnection(String user,
String password) |
boolean |
isWrapperFor(Class<?> interfaceOrWrapper)
Returns true if this either implements the interface argument or is directly or indirectly a
wrapper for an object that does.
|
void |
setDatabaseName(String database)
Sets the database name.
|
void |
setLoginTimeout(int seconds)
Sets the maximum time in seconds that this data source will wait while attempting to connect to
a database.
|
void |
setLogWriter(PrintWriter out)
Sets the log writer for this
DataSource object to the given
java.io.PrintWriter object. |
void |
setMaxIdleTime(int maxIdleTime) |
void |
setMaxPoolSize(int maxPoolSize) |
void |
setMinPoolSize(int minPoolSize) |
void |
setPassword(String password)
Sets the password.
|
void |
setPoolName(String poolName) |
void |
setPoolValidMinDelay(Integer poolValidMinDelay) |
void |
setPort(int port)
Sets the database port.
|
void |
setPortNumber(int port)
Sets the port number.
|
void |
setServerName(String serverName)
Sets the server name.
|
void |
setStaticGlobal(Boolean staticGlobal) |
void |
setUrl(String url)
Sets the connection string URL.
|
void |
setUser(String user)
Sets the username.
|
void |
testForceMaxIdleTime(int maxIdleTime)
Permit to create test that doesn't wait for maxIdleTime minimum value of 60 seconds. !!
|
List<Long> |
testGetConnectionIdleThreadIds()
Get current idle threads. !!
|
Pool |
testGetPool()
Get pool. !!
|
<T> T |
unwrap(Class<T> iface)
Returns an object that implements the given interface to allow access to non-standard methods,
or standard methods not exposed by the proxy.
|
getConnection, getConnection, getDatabaseName, getPort, getServerName, getURL, getUser, getUserName, initialize, setProperties, setURL, setUserNamepublic OceanBasePoolDataSource(String hostname, int port, String database)
hostname - hostname (ipv4, ipv6, dns name)port - server portdatabase - database namepublic OceanBasePoolDataSource(String url)
public OceanBasePoolDataSource()
public void setDatabaseName(String database) throws SQLException
setDatabaseName 在类中 OceanBaseDataSourcedatabase - the name of the databaseSQLException - if error in URLpublic void setUser(String user) throws SQLException
setUser 在类中 OceanBaseDataSourceuser - the usernameSQLException - if error in URLpublic void setPassword(String password) throws SQLException
setPassword 在类中 OceanBaseDataSourcepassword - the passwordSQLException - if error in URLpublic void setPort(int port)
throws SQLException
setPort 在类中 OceanBaseDataSourceport - the portSQLException - if error in URLpublic int getPortNumber()
getPortNumber 在类中 OceanBaseDataSourcepublic void setPortNumber(int port)
throws SQLException
setPortNumber 在类中 OceanBaseDataSourceport - the portSQLException - if error in URLsetPort(int)public void setUrl(String url) throws SQLException
setUrl 在类中 OceanBaseDataSourceurl - the connection stringSQLException - if error in URLpublic void setServerName(String serverName) throws SQLException
setServerName 在类中 OceanBaseDataSourceserverName - the server nameSQLException - if error in URLpublic PooledConnection getPooledConnection() throws SQLException
getPooledConnection 在接口中 ConnectionPoolDataSourcePooledConnection object that is a physical connection to the database
that this ConnectionPoolDataSource object representsSQLException - if a database access error occurs if the JDBC driver does not support this
methodpublic PooledConnection getPooledConnection(String user, String password) throws SQLException
getPooledConnection 在接口中 ConnectionPoolDataSourceuser - the database user on whose behalf the connection is being madepassword - the user's passwordPooledConnection object that is a physical connection to the database
that this ConnectionPoolDataSource object representsSQLException - if a database access error occurspublic PrintWriter getLogWriter()
DataSource object.
The log writer is a character output stream to which all logging and tracing messages for
this data source will be printed. This includes messages printed by the methods of this object,
messages printed by methods of other objects manufactured by this object, and so on. Messages
printed to a data source specific log writer are not printed to the log writer associated with
the java.sql.DriverManager class.
When a DataSource object is created, the log writer is initially null; in other
words, the default is for logging to be disabled.
getLogWriter 在接口中 CommonDataSourcegetLogWriter 在类中 OceanBaseDataSourcesetLogWriter(java.io.PrintWriter)public void setLogWriter(PrintWriter out)
DataSource object to the given
java.io.PrintWriter object.
The log writer is a character output stream to which all logging and tracing messages for
this data source will be printed. This includes messages printed by the methods of this object,
messages printed by methods of other objects manufactured by this object, and so on. Messages
printed to a data source- specific log writer are not printed to the log writer associated with
the java.sql.DriverManager class. When a DataSource object is created
the log writer is initially null; in other words, the default is for logging to be disabled.
setLogWriter 在接口中 CommonDataSourcesetLogWriter 在类中 OceanBaseDataSourceout - the new log writer; to disable logging, set to nullgetLogWriter()public int getLoginTimeout()
DataSource object is
created, the login timeout is initially zero.getLoginTimeout 在接口中 CommonDataSourcegetLoginTimeout 在类中 OceanBaseDataSourcesetLoginTimeout(int)public void setLoginTimeout(int seconds)
throws SQLException
DataSource object
is created, the login timeout is initially zero.setLoginTimeout 在接口中 CommonDataSourcesetLoginTimeout 在类中 OceanBaseDataSourceseconds - the data source login time limitSQLException - if a database access error occurs.getLoginTimeout()public <T> T unwrap(Class<T> iface) throws SQLException
If the receiver implements the interface then the result is the receiver or a proxy for the
receiver. If the receiver is a wrapper and the wrapped object implements the interface then the
result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result
of calling unwrap recursively on the wrapped object or a proxy for that result. If
the receiver is not a wrapper and does not implement the interface, then an SQLException
is thrown.
unwrap 在接口中 Wrapperunwrap 在类中 OceanBaseDataSourceiface - A Class defining an interface that the result must implement.SQLException - If no object found that implements the interfacepublic boolean isWrapperFor(Class<?> interfaceOrWrapper) throws SQLException
isWrapperFor on the wrapped object. If this does not implement the interface and is not
a wrapper, return false. This method should be implemented as a low-cost operation compared to
unwrap so that callers can use this method to avoid expensive unwrap
calls that may fail. If this method returns true then calling unwrap with the same
argument should succeed.isWrapperFor 在接口中 WrapperisWrapperFor 在类中 OceanBaseDataSourceinterfaceOrWrapper - a Class defining an interface.SQLException - if an error occurs while determining whether this is a wrapper for an
object with the given interface.public XAConnection getXAConnection() throws SQLException
getXAConnection 在接口中 XADataSourcegetXAConnection 在类中 OceanBaseDataSourceSQLExceptionpublic XAConnection getXAConnection(String user, String password) throws SQLException
getXAConnection 在接口中 XADataSourcegetXAConnection 在类中 OceanBaseDataSourceSQLExceptionpublic Logger getParentLogger()
getParentLogger 在接口中 CommonDataSourcegetParentLogger 在类中 OceanBaseDataSourceprotected UrlParser getUrlParser()
getUrlParser 在类中 OceanBaseDataSourcepublic String getPoolName()
public void setPoolName(String poolName) throws SQLException
SQLExceptionpublic int getMaxPoolSize()
public void setMaxPoolSize(int maxPoolSize)
throws SQLException
SQLExceptionpublic int getMinPoolSize()
public void setMinPoolSize(int minPoolSize)
throws SQLException
SQLExceptionpublic int getMaxIdleTime()
public void setMaxIdleTime(int maxIdleTime)
throws SQLException
SQLExceptionpublic Boolean getStaticGlobal()
public void setStaticGlobal(Boolean staticGlobal)
public Integer getPoolValidMinDelay()
public void setPoolValidMinDelay(Integer poolValidMinDelay)
public void close()
close 在接口中 Closeableclose 在接口中 AutoCloseablepublic List<Long> testGetConnectionIdleThreadIds()
public void testForceMaxIdleTime(int maxIdleTime)
throws SQLException
maxIdleTime - forced value of maxIdleTime option.SQLException - if connection string has errorpublic Pool testGetPool()
Copyright © 2024 oceanbase.com. All rights reserved.