类 MysqlDataSource
- java.lang.Object
-
- com.mysql.cj.conf.DefaultPropertySet
-
- com.mysql.cj.jdbc.JdbcPropertySetImpl
-
- com.mysql.cj.jdbc.MysqlDataSource
-
- 所有已实现的接口:
PropertySet,JdbcPropertySet,Serializable,Wrapper,Referenceable,CommonDataSource,DataSource
public class MysqlDataSource extends JdbcPropertySetImpl implements DataSource, Referenceable, Serializable, JdbcPropertySet
A JNDI DataSource for a Mysql JDBC connection- 另请参阅:
- 序列化表格
-
-
字段概要
字段 修饰符和类型 字段 说明 protected StringdatabaseNameDatabase Nameprotected Stringdescriptionprotected StringencodingCharacter Encodingprotected booleanexplicitPortWas the port explicitly set?protected booleanexplicitUrlShould we construct the URL, or has it been set explicitly?protected StringhostNameHostnameprotected PrintWriterlogWriterLog streamprotected static NonRegisteringDrivermysqlDriverThe driver to create connections withprotected StringpasswordPasswordprotected intportPort numberprotected StringprofileSQLStringThe profileSQL propertyprotected StringurlThe JDBC URLprotected StringuserUser name
-
构造器概要
构造器 构造器 说明 MysqlDataSource()Default no-arg constructor for Serialization
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 PropertiesexposeAsProperties()protected booleangetBooleanRuntimeProperty(String name)Used in properties getters added by instrumentation.ConnectiongetConnection()ConnectiongetConnection(String userID, String pass)protected ConnectiongetConnection(Properties props)Creates a connection using the specified properties.StringgetDatabaseName()Gets the name of the databaseStringgetDescription()protected StringgetEnumRuntimeProperty(String name)Used in properties getters added by instrumentation.protected intgetIntegerRuntimeProperty(String name)Used in properties getters added by instrumentation.intgetLoginTimeout()PrintWritergetLogWriter()protected longgetLongRuntimeProperty(String name)Used in properties getters added by instrumentation.protected intgetMemorySizeRuntimeProperty(String name)Used in properties getters added by instrumentation.LoggergetParentLogger()StringgetPassword()Get the password.intgetPort()Returns the port numberintgetPortNumber()Returns the port numberReferencegetReference()Required method to support this class as aReferenceable.StringgetServerName()Returns the name of the database serverprotected StringgetStringRuntimeProperty(String name)Used in properties getters added by instrumentation.StringgetUrl()Returns the JDBC URL that will be used to create the database connection.StringgetURL()Returns the URL for this connectionStringgetUser()Returns the configured user for this connectionbooleanisWrapperFor(Class<?> iface)protected voidsetBooleanRuntimeProperty(String name, boolean value)Used in properties setters added by instrumentation.voidsetDatabaseName(String dbName)Sets the database name.voidsetDescription(String value)protected voidsetEnumRuntimeProperty(String name, String value)Used in properties setters added by instrumentation.protected voidsetIntegerRuntimeProperty(String name, int value)Used in properties setters added by instrumentation.voidsetLoginTimeout(int seconds)voidsetLogWriter(PrintWriter output)protected voidsetLongRuntimeProperty(String name, long value)Used in properties setters added by instrumentation.protected voidsetMemorySizeRuntimeProperty(String name, int value)Used in properties setters added by instrumentation.voidsetPassword(String pass)Sets the passwordvoidsetPort(int p)Sets the database port.voidsetPortNumber(int p)Sets the port numbervoidsetPropertiesViaRef(Reference ref)Initializes driver properties that come from a JNDI reference (in the case of a javax.sql.DataSource bound into some name service that doesn't handle Java objects directly).voidsetServerName(String serverName)Sets the server name.protected voidsetStringRuntimeProperty(String name, String value)Used in properties setters added by instrumentation.voidsetUrl(String url)This method is used by the app server to set the url string specified within the datasource deployment descriptor.voidsetURL(String url)Sets the URL for this connectionvoidsetUser(String userID)Sets the user ID.<T> Tunwrap(Class<T> iface)-
从类继承的方法 com.mysql.cj.jdbc.JdbcPropertySetImpl
exposeAsDriverPropertyInfo, postInitialization
-
从类继承的方法 com.mysql.cj.conf.DefaultPropertySet
addProperty, getBooleanProperty, getBooleanProperty, getEnumProperty, getEnumProperty, getIntegerProperty, getIntegerProperty, getLongProperty, getLongProperty, getMemorySizeProperty, getMemorySizeProperty, getProperty, getProperty, getStringProperty, getStringProperty, initializeProperties, removeProperty, removeProperty, reset
-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 javax.sql.CommonDataSource
createShardingKeyBuilder
-
从接口继承的方法 javax.sql.DataSource
createConnectionBuilder
-
从接口继承的方法 com.mysql.cj.jdbc.JdbcPropertySet
exposeAsDriverPropertyInfo
-
从接口继承的方法 com.mysql.cj.conf.PropertySet
addProperty, getBooleanProperty, getBooleanProperty, getEnumProperty, getEnumProperty, getIntegerProperty, getIntegerProperty, getLongProperty, getLongProperty, getMemorySizeProperty, getMemorySizeProperty, getProperty, getProperty, getStringProperty, getStringProperty, initializeProperties, postInitialization, removeProperty, removeProperty, reset
-
-
-
-
字段详细资料
-
mysqlDriver
protected static final NonRegisteringDriver mysqlDriver
The driver to create connections with
-
logWriter
protected transient PrintWriter logWriter
Log stream
-
databaseName
protected String databaseName
Database Name
-
encoding
protected String encoding
Character Encoding
-
url
protected String url
The JDBC URL
-
explicitUrl
protected boolean explicitUrl
Should we construct the URL, or has it been set explicitly?
-
hostName
protected String hostName
Hostname
-
port
protected int port
Port number
-
explicitPort
protected boolean explicitPort
Was the port explicitly set?
-
user
protected String user
User name
-
password
protected String password
Password
-
profileSQLString
protected String profileSQLString
The profileSQL property
-
description
protected String description
-
-
方法详细资料
-
getConnection
public Connection getConnection() throws SQLException
- 指定者:
getConnection在接口中DataSource- 抛出:
SQLException
-
getConnection
public Connection getConnection(String userID, String pass) throws SQLException
- 指定者:
getConnection在接口中DataSource- 抛出:
SQLException
-
getDescription
public String getDescription()
-
setDescription
public void setDescription(String value)
-
setDatabaseName
public void setDatabaseName(String dbName)
Sets the database name.- 参数:
dbName- the name of the database
-
getDatabaseName
public String getDatabaseName()
Gets the name of the database- 返回:
- the name of the database for this data source
-
setLogWriter
public void setLogWriter(PrintWriter output) throws SQLException
- 指定者:
setLogWriter在接口中CommonDataSource- 指定者:
setLogWriter在接口中DataSource- 抛出:
SQLException
-
getLogWriter
public PrintWriter getLogWriter()
- 指定者:
getLogWriter在接口中CommonDataSource- 指定者:
getLogWriter在接口中DataSource
-
setLoginTimeout
public void setLoginTimeout(int seconds) throws SQLException- 指定者:
setLoginTimeout在接口中CommonDataSource- 指定者:
setLoginTimeout在接口中DataSource- 抛出:
SQLException
-
getLoginTimeout
public int getLoginTimeout()
- 指定者:
getLoginTimeout在接口中CommonDataSource- 指定者:
getLoginTimeout在接口中DataSource
-
setPassword
public void setPassword(String pass)
Sets the password- 参数:
pass- the password
-
getPassword
public String getPassword()
Get the password.- 返回:
- password
-
setPort
public void setPort(int p)
Sets the database port.- 参数:
p- the port
-
getPort
public int getPort()
Returns the port number- 返回:
- the port number
-
setPortNumber
public void setPortNumber(int p)
Sets the port number- 参数:
p- the port
-
getPortNumber
public int getPortNumber()
Returns the port number- 返回:
- the port number
-
setPropertiesViaRef
public void setPropertiesViaRef(Reference ref) throws SQLException
Initializes driver properties that come from a JNDI reference (in the case of a javax.sql.DataSource bound into some name service that doesn't handle Java objects directly).- 参数:
ref- The JNDI Reference that holds RefAddrs for all properties- 抛出:
SQLException- if error occurs
-
getReference
public Reference getReference() throws NamingException
Required method to support this class as aReferenceable.- 指定者:
getReference在接口中Referenceable- 返回:
- a Reference to this data source
- 抛出:
NamingException- if a JNDI error occurs
-
setServerName
public void setServerName(String serverName)
Sets the server name.- 参数:
serverName- the server name
-
getServerName
public String getServerName()
Returns the name of the database server- 返回:
- the name of the database server
-
setURL
public void setURL(String url)
Sets the URL for this connection- 参数:
url- the URL for this connection
-
getURL
public String getURL()
Returns the URL for this connection- 返回:
- the URL for this connection
-
setUrl
public void setUrl(String url)
This method is used by the app server to set the url string specified within the datasource deployment descriptor. It is discovered using introspection and matches if property name in descriptor is "url".- 参数:
url- url to be used within driver.connect
-
getUrl
public String getUrl()
Returns the JDBC URL that will be used to create the database connection.- 返回:
- the URL for this connection
-
setUser
public void setUser(String userID)
Sets the user ID.- 参数:
userID- the User ID
-
getUser
public String getUser()
Returns the configured user for this connection- 返回:
- the user for this connection
-
getConnection
protected Connection getConnection(Properties props) throws SQLException
Creates a connection using the specified properties.- 参数:
props- the properties to connect with- 返回:
- a connection to the database
- 抛出:
SQLException- if an error occurs
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- 指定者:
getParentLogger在接口中CommonDataSource- 抛出:
SQLFeatureNotSupportedException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- 指定者:
unwrap在接口中Wrapper- 抛出:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- 指定者:
isWrapperFor在接口中Wrapper- 抛出:
SQLException
-
getStringRuntimeProperty
protected String getStringRuntimeProperty(String name) throws SQLException
Used in properties getters added by instrumentation.- 参数:
name- property name property name- 返回:
- property value
- 抛出:
SQLException- if error occurs
-
setStringRuntimeProperty
protected void setStringRuntimeProperty(String name, String value) throws SQLException
Used in properties setters added by instrumentation.- 参数:
name- property namevalue- value- 抛出:
SQLException- if error occurs
-
getBooleanRuntimeProperty
protected boolean getBooleanRuntimeProperty(String name) throws SQLException
Used in properties getters added by instrumentation.- 参数:
name- property name- 返回:
- property value
- 抛出:
SQLException- if error occurs
-
setBooleanRuntimeProperty
protected void setBooleanRuntimeProperty(String name, boolean value) throws SQLException
Used in properties setters added by instrumentation.- 参数:
name- property namevalue- value- 抛出:
SQLException- if error occurs
-
getIntegerRuntimeProperty
protected int getIntegerRuntimeProperty(String name) throws SQLException
Used in properties getters added by instrumentation.- 参数:
name- property name- 返回:
- property value
- 抛出:
SQLException- if error occurs
-
setIntegerRuntimeProperty
protected void setIntegerRuntimeProperty(String name, int value) throws SQLException
Used in properties setters added by instrumentation.- 参数:
name- property namevalue- value- 抛出:
SQLException- if error occurs
-
getLongRuntimeProperty
protected long getLongRuntimeProperty(String name) throws SQLException
Used in properties getters added by instrumentation.- 参数:
name- property name- 返回:
- property value
- 抛出:
SQLException- if error occurs
-
setLongRuntimeProperty
protected void setLongRuntimeProperty(String name, long value) throws SQLException
Used in properties setters added by instrumentation.- 参数:
name- property namevalue- value- 抛出:
SQLException- if error occurs
-
getMemorySizeRuntimeProperty
protected int getMemorySizeRuntimeProperty(String name) throws SQLException
Used in properties getters added by instrumentation.- 参数:
name- property name- 返回:
- property value
- 抛出:
SQLException- if error occurs
-
setMemorySizeRuntimeProperty
protected void setMemorySizeRuntimeProperty(String name, int value) throws SQLException
Used in properties setters added by instrumentation.- 参数:
name- property namevalue- value- 抛出:
SQLException- if error occurs
-
getEnumRuntimeProperty
protected String getEnumRuntimeProperty(String name) throws SQLException
Used in properties getters added by instrumentation.- 参数:
name- property name- 返回:
- property value
- 抛出:
SQLException- if error occurs
-
setEnumRuntimeProperty
protected void setEnumRuntimeProperty(String name, String value) throws SQLException
Used in properties setters added by instrumentation.- 参数:
name- property namevalue- value- 抛出:
SQLException- if error occurs
-
exposeAsProperties
public Properties exposeAsProperties()
- 指定者:
exposeAsProperties在接口中PropertySet- 覆盖:
exposeAsProperties在类中DefaultPropertySet
-
-