MySQL Connector/J size='-1'>5.0.8

com.mysql.jdbc.jdbc2.optional
Class MysqlDataSource

java.lang.Object
  extended by com.mysql.jdbc.ConnectionProperties
      extended by com.mysql.jdbc.jdbc2.optional.MysqlDataSource
All Implemented Interfaces:
java.io.Serializable, javax.naming.Referenceable, javax.sql.DataSource
Direct Known Subclasses:
MysqlConnectionPoolDataSource, MysqlXADataSource

public class MysqlDataSource
extends ConnectionProperties
implements javax.sql.DataSource, javax.naming.Referenceable, java.io.Serializable

A JNDI DataSource for a Mysql JDBC connection

Author:
Mark Matthews
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.mysql.jdbc.ConnectionProperties
ConnectionProperties.LongConnectionProperty
 
Field Summary
protected  java.lang.String databaseName
          Database Name
protected  java.lang.String encoding
          Character Encoding
protected  boolean explicitUrl
          Should we construct the URL, or has it been set explicitly
protected  java.lang.String hostName
          Hostname
protected  java.io.PrintWriter logWriter
          Log stream
protected static Driver mysqlDriver
          The driver to create connections with
protected  java.lang.String password
          Password
protected  int port
          Port number
protected  java.lang.String profileSql
          The profileSql property
protected  java.lang.String url
          The JDBC URL
protected  java.lang.String user
          User name
 
Fields inherited from class com.mysql.jdbc.ConnectionProperties
ZERO_DATETIME_BEHAVIOR_CONVERT_TO_NULL, ZERO_DATETIME_BEHAVIOR_EXCEPTION, ZERO_DATETIME_BEHAVIOR_ROUND
 
Constructor Summary
MysqlDataSource()
          Default no-arg constructor for Serialization
 
Method Summary
 java.sql.Connection getConnection()
          Creates a new connection using the already configured username and password.
protected  java.sql.Connection getConnection(java.util.Properties props)
          Creates a connection using the specified properties.
 java.sql.Connection getConnection(java.lang.String userID, java.lang.String pass)
          Creates a new connection with the given username and password
 java.lang.String getDatabaseName()
          Gets the name of the database
 int getLoginTimeout()
          Returns the login timeout
 java.io.PrintWriter getLogWriter()
          Returns the log writer for this data source
 int getPort()
          Returns the port number
 int getPortNumber()
          Returns the port number
 javax.naming.Reference getReference()
          Required method to support this class as a Referenceable.
 java.lang.String getServerName()
          Returns the name of the database server
 java.lang.String getUrl()
          Returns the JDBC URL that will be used to create the database connection.
 java.lang.String getURL()
          Returns the URL for this connection
 java.lang.String getUser()
          Returns the configured user for this connection
 void setDatabaseName(java.lang.String dbName)
          Sets the database name.
 void setLoginTimeout(int seconds)
          DOCUMENT ME!
 void setLogWriter(java.io.PrintWriter output)
          Sets the log writer for this data source.
 void setPassword(java.lang.String pass)
          Sets the password
 void setPort(int p)
          Sets the database port.
 void setPortNumber(int p)
          Sets the port number
 void setPropertiesViaRef(javax.naming.Reference ref)
          DOCUMENT ME!
 void setServerName(java.lang.String serverName)
          Sets the server name.
 void setUrl(java.lang.String url)
          This method is used by the app server to set the url string specified within the datasource deployment descriptor.
 void setURL(java.lang.String url)
          Sets the URL for this connection
 void setUser(java.lang.String userID)
          Sets the user ID.
 
Methods inherited from class com.mysql.jdbc.ConnectionProperties
exposeAsDriverPropertyInfo, exposeAsDriverPropertyInfoInternal, exposeAsProperties, exposeAsXml, getAllowLoadLocalInfile, getAllowMultiQueries, getAllowNanAndInf, getAllowUrlInLocalInfile, getAlwaysSendSetIsolation, getAutoClosePStmtStreams, getAutoDeserialize, getAutoGenerateTestcaseScript, getAutoReconnectForPools, getBlobsAreStrings, getBlobSendChunkSize, getCacheCallableStatements, getCacheCallableStmts, getCachePreparedStatements, getCachePrepStmts, getCacheResultSetMetadata, getCacheServerConfiguration, getCallableStatementCacheSize, getCallableStmtCacheSize, getCapitalizeTypeNames, getCharacterSetResults, getClobberStreamingResults, getClobCharacterEncoding, getConnectionCollation, getConnectTimeout, getContinueBatchOnError, getCreateDatabaseIfNotExist, getDefaultFetchSize, getDontTrackOpenResources, getDumpMetadataOnColumnNotFound, getDumpQueriesOnException, getDynamicCalendars, getElideSetAutoCommits, getEmptyStringsConvertToZero, getEmulateLocators, getEmulateUnsupportedPstmts, getEnablePacketDebug, getEnableQueryTimeouts, getEncoding, getExplainSlowQueries, getFailOverReadOnly, getFunctionsNeverReturnBlobs, getGatherPerfMetrics, getGatherPerformanceMetrics, getGenerateSimpleParameterMetadata, getHighAvailability, getHoldResultsOpenOverStatementClose, getIgnoreNonTxTables, getIncludeInnodbStatusInDeadlockExceptions, getInitialTimeout, getInteractiveClient, getIsInteractiveClient, getJdbcCompliantTruncation, getJdbcCompliantTruncationForReads, getLoadBalanceStrategy, getLocalSocketAddress, getLocatorFetchBufferSize, getLogger, getLoggerClassName, getLogSlowQueries, getLogXaCommands, getMaintainTimeStats, getMaxQuerySizeToLog, getMaxReconnects, getMaxRows, getMetadataCacheSize, getNoAccessToProcedureBodies, getNoDatetimeStringSync, getNoTimezoneConversionForTimeType, getNullCatalogMeansCurrent, getNullNamePatternMatchesAll, getOverrideSupportsIntegrityEnhancementFacility, getPacketDebugBufferSize, getPadCharsWithSpace, getParanoid, getPedantic, getPinGlobalTxToPhysicalConnection, getPopulateInsertRowWithDefaultValues, getPreparedStatementCacheSize, getPreparedStatementCacheSqlLimit, getPrepStmtCacheSize, getPrepStmtCacheSqlLimit, getProcessEscapeCodesForPrepStmts, getProfileSql, getProfileSQL, getPropertiesTransform, getQueriesBeforeRetryMaster, getReconnectAtTxEnd, getRelaxAutoCommit, getReportMetricsIntervalMillis, getRequireSSL, getResourceId, getResultSetSizeThreshold, getRetainStatementAfterResultSetClose, getRewriteBatchedStatements, getRollbackOnPooledClose, getRoundRobinLoadBalance, getRunningCTS13, getSecondsBeforeRetryMaster, getServerTimezone, getSessionVariables, getSlowQueryThresholdMillis, getSlowQueryThresholdNanos, getSocketFactory, getSocketFactoryClassName, getSocketTimeout, getStrictFloatingPoint, getStrictUpdates, getTcpKeepAlive, getTcpNoDelay, getTcpRcvBuf, getTcpSndBuf, getTcpTrafficClass, getTinyInt1isBit, getTraceProtocol, getTransformedBitIsBoolean, getTreatUtilDateAsTimestamp, getUltraDevHack, getUseCompression, getUseConfigs, getUseCursorFetch, getUseDynamicCharsetInfo, getUseFastDateParsing, getUseFastIntParsing, getUseGmtMillisForDatetimes, getUseHostsInPrivileges, getUseInformationSchema, getUseJDBCCompliantTimezoneShift, getUseJvmCharsetConverters, getUseLocalSessionState, getUseNanosForElapsedTime, getUseOldAliasMetadataBehavior, getUseOldUTF8Behavior, getUseOnlyServerErrorMessages, getUseReadAheadInput, getUseServerPreparedStmts, getUseServerPrepStmts, getUseSqlStateCodes, getUseSSL, getUseSSPSCompatibleTimezoneShift, getUseStreamLengthsInPrepStmts, getUseTimezone, getUseUltraDevWorkAround, getUseUnbufferedInput, getUseUnicode, getUseUsageAdvisor, getYearIsDateType, getZeroDateTimeBehavior, initializeFromRef, initializeProperties, postInitialization, setAllowLoadLocalInfile, setAllowMultiQueries, setAllowNanAndInf, setAllowUrlInLocalInfile, setAlwaysSendSetIsolation, setAutoClosePStmtStreams, setAutoDeserialize, setAutoGenerateTestcaseScript, setAutoReconnect, setAutoReconnectForConnectionPools, setAutoReconnectForPools, setBlobsAreStrings, setBlobSendChunkSize, setCacheCallableStatements, setCacheCallableStmts, setCachePreparedStatements, setCachePrepStmts, setCacheResultSetMetadata, setCacheServerConfiguration, setCallableStatementCacheSize, setCallableStmtCacheSize, setCapitalizeDBMDTypes, setCapitalizeTypeNames, setCharacterEncoding, setCharacterSetResults, setClobberStreamingResults, setClobCharacterEncoding, setConnectionCollation, setConnectTimeout, setContinueBatchOnError, setCreateDatabaseIfNotExist, setDefaultFetchSize, setDetectServerPreparedStmts, setDontTrackOpenResources, setDumpMetadataOnColumnNotFound, setDumpQueriesOnException, setDynamicCalendars, setElideSetAutoCommits, setEmptyStringsConvertToZero, setEmulateLocators, setEmulateUnsupportedPstmts, setEnablePacketDebug, setEnableQueryTimeouts, setEncoding, setExplainSlowQueries, setFailOverReadOnly, setFunctionsNeverReturnBlobs, setGatherPerfMetrics, setGatherPerformanceMetrics, setGenerateSimpleParameterMetadata, setHighAvailability, setHoldResultsOpenOverStatementClose, setIgnoreNonTxTables, setIncludeInnodbStatusInDeadlockExceptions, setInitialTimeout, setInteractiveClient, setIsInteractiveClient, setJdbcCompliantTruncation, setJdbcCompliantTruncationForReads, setLoadBalanceStrategy, setLocalSocketAddress, setLocatorFetchBufferSize, setLogger, setLoggerClassName, setLogSlowQueries, setLogXaCommands, setMaintainTimeStats, setMaxQuerySizeToLog, setMaxReconnects, setMaxRows, setMetadataCacheSize, setNoAccessToProcedureBodies, setNoDatetimeStringSync, setNoTimezoneConversionForTimeType, setNullCatalogMeansCurrent, setNullNamePatternMatchesAll, setOverrideSupportsIntegrityEnhancementFacility, setPacketDebugBufferSize, setPadCharsWithSpace, setParanoid, setPedantic, setPinGlobalTxToPhysicalConnection, setPopulateInsertRowWithDefaultValues, setPreparedStatementCacheSize, setPreparedStatementCacheSqlLimit, setPrepStmtCacheSize, setPrepStmtCacheSqlLimit, setProcessEscapeCodesForPrepStmts, setProfileSql, setProfileSQL, setPropertiesTransform, setQueriesBeforeRetryMaster, setReconnectAtTxEnd, setRelaxAutoCommit, setReportMetricsIntervalMillis, setRequireSSL, setResourceId, setResultSetSizeThreshold, setRetainStatementAfterResultSetClose, setRewriteBatchedStatements, setRollbackOnPooledClose, setRoundRobinLoadBalance, setRunningCTS13, setSecondsBeforeRetryMaster, setServerTimezone, setSessionVariables, setSlowQueryThresholdMillis, setSlowQueryThresholdNanos, setSocketFactory, setSocketFactoryClassName, setSocketTimeout, setStrictFloatingPoint, setStrictUpdates, setTcpKeepAlive, setTcpNoDelay, setTcpRcvBuf, setTcpSndBuf, setTcpTrafficClass, setTinyInt1isBit, setTraceProtocol, setTransformedBitIsBoolean, setTreatUtilDateAsTimestamp, setUltraDevHack, setUseCompression, setUseConfigs, setUseCursorFetch, setUseDynamicCharsetInfo, setUseFastDateParsing, setUseFastIntParsing, setUseGmtMillisForDatetimes, setUseHostsInPrivileges, setUseInformationSchema, setUseJDBCCompliantTimezoneShift, setUseJvmCharsetConverters, setUseLocalSessionState, setUseNanosForElapsedTime, setUseOldAliasMetadataBehavior, setUseOldUTF8Behavior, setUseOnlyServerErrorMessages, setUseReadAheadInput, setUseServerPreparedStmts, setUseServerPrepStmts, setUseSqlStateCodes, setUseSSL, setUseSSPSCompatibleTimezoneShift, setUseStreamLengthsInPrepStmts, setUseTimezone, setUseUltraDevWorkAround, setUseUnbufferedInput, setUseUnicode, setUseUsageAdvisor, setYearIsDateType, setZeroDateTimeBehavior, storeToRef, useUnbufferedInput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mysqlDriver

protected static Driver mysqlDriver
The driver to create connections with


logWriter

protected java.io.PrintWriter logWriter
Log stream


databaseName

protected java.lang.String databaseName
Database Name


encoding

protected java.lang.String encoding
Character Encoding


hostName

protected java.lang.String hostName
Hostname


password

protected java.lang.String password
Password


profileSql

protected java.lang.String profileSql
The profileSql property


url

protected java.lang.String url
The JDBC URL


user

protected java.lang.String user
User name


explicitUrl

protected boolean explicitUrl
Should we construct the URL, or has it been set explicitly


port

protected int port
Port number

Constructor Detail

MysqlDataSource

public MysqlDataSource()
Default no-arg constructor for Serialization

Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Creates a new connection using the already configured username and password.

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs

getConnection

public java.sql.Connection getConnection(java.lang.String userID,
                                         java.lang.String pass)
                                  throws java.sql.SQLException
Creates a new connection with the given username and password

Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
userID - the user id to connect with
password - the password to connect with
Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs

setDatabaseName

public void setDatabaseName(java.lang.String dbName)
Sets the database name.

Parameters:
dbName - the name of the database

getDatabaseName

public java.lang.String getDatabaseName()
Gets the name of the database

Returns:
the name of the database for this data source

setLogWriter

public void setLogWriter(java.io.PrintWriter output)
                  throws java.sql.SQLException
Sets the log writer for this data source.

Specified by:
setLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.setLogWriter(PrintWriter)

getLogWriter

public java.io.PrintWriter getLogWriter()
Returns the log writer for this data source

Specified by:
getLogWriter in interface javax.sql.DataSource
Returns:
the log writer for this data source

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
DOCUMENT ME!

Specified by:
setLoginTimeout in interface javax.sql.DataSource
Parameters:
seconds - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

getLoginTimeout

public int getLoginTimeout()
Returns the login timeout

Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
the login timeout

setPassword

public void setPassword(java.lang.String pass)
Sets the password

Parameters:
pass - the password

setPort

public void setPort(int p)
Sets the database port.

Parameters:
p - the port

getPort

public int getPort()
Returns the port number

Returns:
the port number

setPortNumber

public void setPortNumber(int p)
Sets the port number

Parameters:
p - the port
See Also:
setPort(int)

getPortNumber

public int getPortNumber()
Returns the port number

Returns:
the port number

setPropertiesViaRef

public void setPropertiesViaRef(javax.naming.Reference ref)
                         throws java.sql.SQLException
DOCUMENT ME!

Parameters:
ref - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Required method to support this class as a Referenceable.

Specified by:
getReference in interface javax.naming.Referenceable
Returns:
a Reference to this data source
Throws:
javax.naming.NamingException - if a JNDI error occurs

setServerName

public void setServerName(java.lang.String serverName)
Sets the server name.

Parameters:
serverName - the server name

getServerName

public java.lang.String getServerName()
Returns the name of the database server

Returns:
the name of the database server

setURL

public void setURL(java.lang.String url)
Sets the URL for this connection

Parameters:
url - the URL for this connection

getURL

public java.lang.String getURL()
Returns the URL for this connection

Returns:
the URL for this connection

setUrl

public void setUrl(java.lang.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".

Parameters:
url - url to be used within driver.connect

getUrl

public java.lang.String getUrl()
Returns the JDBC URL that will be used to create the database connection.

Returns:
the URL for this connection

setUser

public void setUser(java.lang.String userID)
Sets the user ID.

Parameters:
userID - the User ID

getUser

public java.lang.String getUser()
Returns the configured user for this connection

Returns:
the user for this connection

getConnection

protected java.sql.Connection getConnection(java.util.Properties props)
                                     throws java.sql.SQLException
Creates a connection using the specified properties.

Parameters:
props - the properties to connect with
Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs

MySQL Connector/J size='-1'>5.0.8