public class OceanBaseDataSource extends Object implements DataSource, XADataSource
| 限定符和类型 | 字段和说明 |
|---|---|
protected Integer |
connectTimeoutInMs |
protected String |
database |
protected String |
hostname |
protected String |
password |
protected Integer |
port |
protected String |
url |
protected String |
user |
| 构造器和说明 |
|---|
OceanBaseDataSource()
Default constructor. hostname will be localhost, port 3306.
|
OceanBaseDataSource(String url) |
OceanBaseDataSource(String hostname,
int port,
String database)
Constructor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
Connection |
getConnection()
Attempts to establish a connection with the data source that this
DataSource
object represents. |
Connection |
getConnection(String username,
String password)
Attempts to establish a connection with the data source that this
DataSource
object represents. |
String |
getDatabaseName()
Gets the name of the database.
|
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. |
Logger |
getParentLogger() |
int |
getPort()
Returns the port number.
|
int |
getPortNumber()
Returns the port number.
|
String |
getServerName()
Returns the name of the database server.
|
String |
getURL()
Returns the URL for this connection
|
protected UrlParser |
getUrlParser()
For testing purpose only.
|
String |
getUser()
Gets the username.
|
String |
getUserName()
Gets the username.
|
XAConnection |
getXAConnection() |
XAConnection |
getXAConnection(String user,
String password) |
protected void |
initialize() |
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 |
setPassword(String password)
Sets the password.
|
void |
setPort(int port)
Sets the database port.
|
void |
setPortNumber(int port)
Sets the port number.
|
void |
setProperties(String properties)
已过时。
|
void |
setServerName(String serverName)
Sets the server name.
|
void |
setUrl(String url)
Sets the connection string URL.
|
void |
setURL(String url)
Sets the URL for this connection
|
void |
setUser(String user)
Sets the username.
|
void |
setUserName(String userName)
Sets the username.
|
<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.
|
protected String hostname
protected Integer port
protected Integer connectTimeoutInMs
protected String database
protected String url
protected String user
protected String password
public OceanBaseDataSource(String hostname, int port, String database)
hostname - hostname (ipv4, ipv6, dns name)port - server portdatabase - database namepublic OceanBaseDataSource(String url)
public OceanBaseDataSource()
public String getDatabaseName()
public void setDatabaseName(String database) throws SQLException
database - the name of the databaseSQLException - if connection information are erroneouspublic String getUser()
public void setUser(String user) throws SQLException
user - the usernameSQLException - if connection information are erroneouspublic String getUserName()
public void setUserName(String userName) throws SQLException
userName - the usernameSQLException - if connection information are erroneouspublic void setPassword(String password) throws SQLException
password - the passwordSQLException - if connection information are erroneouspublic int getPort()
public void setPort(int port)
throws SQLException
port - the portSQLException - if connection information are erroneouspublic int getPortNumber()
public void setPortNumber(int port)
throws SQLException
port - the portSQLException - if connection information are erroneoussetPort(int)@Deprecated public void setProperties(String properties) throws SQLException
SQLExceptionpublic void setUrl(String url) throws SQLException
url - the connection stringSQLException - if error in URLpublic String getServerName()
public void setServerName(String serverName) throws SQLException
serverName - the server nameSQLException - if connection information are erroneouspublic Connection getConnection() throws SQLException
DataSource
object represents.getConnection 在接口中 DataSourceSQLException - if a database access error occurspublic Connection getConnection(String username, String password) throws SQLException
DataSource
object represents.getConnection 在接口中 DataSourceusername - the database user on whose behalf the connection is being madepassword - the user's passwordSQLException - 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 在接口中 CommonDataSourcesetLogWriter(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 在接口中 CommonDataSourceout - the new log writer; to disable logging, set to nullgetLogWriter()public int getLoginTimeout()
DataSource object is
created, the login timeout is initially zero.getLoginTimeout 在接口中 CommonDataSourcesetLoginTimeout(int)public void setLoginTimeout(int seconds)
throws SQLException
DataSource object
is created, the login timeout is initially zero.setLoginTimeout 在接口中 CommonDataSourceseconds - the data source login time limitSQLExceptiongetLoginTimeout()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 在接口中 Wrapperiface - 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 在接口中 WrapperinterfaceOrWrapper - 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 在接口中 XADataSourceSQLExceptionpublic XAConnection getXAConnection(String user, String password) throws SQLException
getXAConnection 在接口中 XADataSourceSQLExceptionpublic Logger getParentLogger()
getParentLogger 在接口中 CommonDataSourceprotected UrlParser getUrlParser()
protected void initialize()
throws SQLException
SQLExceptionpublic void setURL(String url) throws SQLException
url - the URL for this connectionSQLExceptionpublic String getURL()
Copyright © 2024 oceanbase.com. All rights reserved.