Top Description Fields Constructors Methods
org.hsqldb.jdbc

public abstract Class JDBCCommonDataSource

extends Object
implements CommonDataSource, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.sql.CommonDataSource
Known Direct Subclasses
org.hsqldb.jdbc.JDBCDataSource, org.hsqldb.jdbc.pool.JDBCPooledDataSource, org.hsqldb.jdbc.pool.JDBCXADataSource
Imports
java.io.PrintWriter, .Serializable, java.sql.SQLException, .SQLFeatureNotSupportedException, java.util.Properties, javax.sql.CommonDataSource

Common base for DataSource implementations. This class implements the methods used for setting the properties for new connections. The setUrl() or setDatabase() methods are used to set the URL. It is possible to set all the rest of required properties in a Properties file and use the setProperties() method. Alternatively, the setXXX() methods for user and password can be used. It is best to use only one method for setting the properties. If setXXX() methods are used, the values override the values set in a call made to setProperties() before or after calling setXXX().
Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
JDK 1.2, HSQLDB 2.0
Version
2.7.3

Field Summary

Modifier and TypeField and Description
protected Properties
protected String
dataSourceName

name of data source - informational

protected String
description

description of data source - informational

protected int
loginTimeout

login timeout

protected transient PrintWriter
logWriter

log writer

protected String
networkProtocol

network protocol - informational

protected String
password

connection password

protected String
serverName

name of server - informational

protected String
url

database URL

protected String
user

connection user

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the jdbc database connection url attribute
getDatabase
()

Synonym for getUrl().

public String

Returns:

the jdbc database connection url attribute
getDatabaseName
()

Synonym for getUrl().

public String

Returns:

the description
getDataSourceName
()

Retrieves the name of the data source.

public String

Returns:

the description
getDescription
()

Retrieves the description of the data source.

public int

Returns:

the data source login time limit
getLoginTimeout
()

Implements javax.sql.CommonDataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.

public PrintWriter

Returns:

the log writer for this data source or null if logging is disabled
getLogWriter
()

Implements javax.sql.CommonDataSource.getLogWriter.

Retrieves the log writer for this DataSource object.

public String

Returns:

the network protocol
getNetworkProtocol
()

Retrieves the network protocol of the data source.

public Logger

Returns:

the parent Logger for this data source
getParentLogger
()

Implements javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source.

public String

Returns:

the server name attribute
getServerName
()

Retrieves the server name attribute.

public String

Returns:

the jdbc database connection url attribute
getUrl
()

Retrieves the jdbc database connection url attribute.

public String

Returns:

the jdbc database connection url attribute
getURL
()

Retrieves the jdbc database connection url attribute.

public String

Returns:

the username for the connection
getUser
()

Retrieves the user name for the connection.

public void
setDatabase(String
the new value for the attribute
database
)

Synonym for setUrl(String).

public void
setDatabaseName(String
the new value for the attribute
databaseName
)

Synonym for setUrl(String).

public void
setLoginTimeout(int
the data source login time limit
seconds
)

Implements javax.sql.CommonDataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

public void
setLogWriter(PrintWriter
the new log writer; to disable logging, set to null
out
)

Implements javax.sql.CommonDataSource.setLogWriter.

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

public void
setPassword(String
the password
password
)

Sets the password for the username.

public void
setProperties(Properties
properties. If null, then existing properties will be cleared/replaced.
props
)

Sets connection properties.

public void
setUrl(String
the new value of this object's jdbc database connection url attribute
url
)

Sets the jdbc database URL.

public void
setURL(String
the new value of this object's jdbc database connection url attribute
url
)

Sets the jdbc database URL.

public void
setUser(String
the user id
user
)

Sets the user name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionPropsback to summary
protected Properties connectionProps
dataSourceNameback to summary
protected String dataSourceName

name of data source - informational

descriptionback to summary
protected String description

description of data source - informational

loginTimeoutback to summary
protected int loginTimeout

login timeout

logWriterback to summary
protected transient PrintWriter logWriter

log writer

networkProtocolback to summary
protected String networkProtocol

network protocol - informational

passwordback to summary
protected String password

connection password

serverNameback to summary
protected String serverName

name of server - informational

urlback to summary
protected String url

database URL

userback to summary
protected String user

connection user

Constructor Detail

JDBCCommonDataSourceback to summary
public JDBCCommonDataSource()

Method Detail

getDatabaseback to summary
public String getDatabase()

Synonym for getUrl().

Returns:String

the jdbc database connection url attribute

getDatabaseNameback to summary
public String getDatabaseName()

Synonym for getUrl().

Returns:String

the jdbc database connection url attribute

getDataSourceNameback to summary
public String getDataSourceName()

Retrieves the name of the data source.

Returns:String

the description

getDescriptionback to summary
public String getDescription()

Retrieves the description of the data source.

Returns:String

the description

getLoginTimeoutback to summary
public int getLoginTimeout() throws SQLException

Implements javax.sql.CommonDataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise, it means that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Returns:int

the data source login time limit

Exceptions
SQLException:
if a database access error occurs.
Since
1.4
See Also
setLoginTimeout
getLogWriterback to summary
public PrintWriter getLogWriter() throws SQLException

Implements javax.sql.CommonDataSource.getLogWriter.

Retrieves the log writer for this 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.

Returns:PrintWriter

the log writer for this data source or null if logging is disabled

Exceptions
SQLException:
if a database access error occurs
Since
1.4
See Also
setLogWriter
getNetworkProtocolback to summary
public String getNetworkProtocol()

Retrieves the network protocol of the data source.

Returns:String

the network protocol

getParentLoggerback to summary
public Logger getParentLogger() throws SQLFeatureNotSupportedException

Implements javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source. This should be the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this data source. Configuring this Logger will affect all of the log messages generated by the data source. In the worst case, this may be the root Logger.

Returns:Logger

the parent Logger for this data source

Exceptions
SQLFeatureNotSupportedException:
if the data source does not use java.util.logging.
Since
JDK 1.7, HSQLDB 2.0.1
getServerNameback to summary
public String getServerName()

Retrieves the server name attribute.

Returns:String

the server name attribute

getUrlback to summary
public String getUrl()

Retrieves the jdbc database connection url attribute.

Returns:String

the jdbc database connection url attribute

getURLback to summary
public String getURL()

Retrieves the jdbc database connection url attribute.

Returns:String

the jdbc database connection url attribute

getUserback to summary
public String getUser()

Retrieves the user name for the connection.

Returns:String

the username for the connection

setDatabaseback to summary
public void setDatabase(String database)

Synonym for setUrl(String).

Parameters
database:String

the new value for the attribute

setDatabaseNameback to summary
public void setDatabaseName(String databaseName)

Synonym for setUrl(String).

Parameters
databaseName:String

the new value for the attribute

setLoginTimeoutback to summary
public void setLoginTimeout(int seconds) throws SQLException

Implements javax.sql.CommonDataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it specifies that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Parameters
seconds:int

the data source login time limit

Exceptions
SQLException:
if a database access error occurs.
Since
1.4
See Also
getLoginTimeout
setLogWriterback to summary
public void setLogWriter(PrintWriter out) throws SQLException

Implements javax.sql.CommonDataSource.setLogWriter.

Sets the log writer for this 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.

Parameters
out:PrintWriter

the new log writer; to disable logging, set to null

Exceptions
SQLException:
if a database access error occurs
Since
1.4
See Also
getLogWriter
setPasswordback to summary
public void setPassword(String password)

Sets the password for the username.

Parameters
password:String

the password

setPropertiesback to summary
public void setProperties(Properties props)

Sets connection properties. If user / password / loginTimeout has been set with one of the setXXX() methods it will be added to the Properties object.

Parameters
props:Properties

properties. If null, then existing properties will be cleared/replaced.

setUrlback to summary
public void setUrl(String url)

Sets the jdbc database URL.

Parameters
url:String

the new value of this object's jdbc database connection url attribute

setURLback to summary
public void setURL(String url)

Sets the jdbc database URL.

Parameters
url:String

the new value of this object's jdbc database connection url attribute

setUserback to summary
public void setUser(String user)

Sets the user name.

Parameters
user:String

the user id