CommonDataSource
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
|
Interface that defines the methods which are common between DataSource
,
XADataSource
and ConnectionPoolDataSource
.
Public Method Summary
abstract
PrintWriter
|
getLogWriter()
Retrieves the log writer for this DataSource
object.
|
abstract
int
|
getLoginTimeout()
Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database.
|
abstract
Logger
|
getParentLogger()
Return the parent Logger of all the Loggers used by this data source.
|
abstract
void
|
setLogWriter( PrintWriter out)
Sets the log writer for this DataSource
object to the given java.io.PrintWriter object.
|
abstract
void
|
setLoginTimeout(int seconds)
Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database.
|
Public Methods
public
abstract
PrintWriter
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
- the log writer for this data source or null if
logging is disabled
public
abstract
int
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
- the data source login time limit
public
abstract
Logger
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
- the parent Logger for this data source
public
abstract
void
setLogWriter
(PrintWriter out)
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 |
the new log writer; to disable logging, set to null |
public
abstract
void
setLoginTimeout
(int seconds)
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 |
the data source login time limit |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eCommonDataSource\u003c/code\u003e defines methods shared by \u003ccode\u003eDataSource\u003c/code\u003e, \u003ccode\u003eXADataSource\u003c/code\u003e, and \u003ccode\u003eConnectionPoolDataSource\u003c/code\u003e for database interactions.\u003c/p\u003e\n"],["\u003cp\u003eIt allows setting and retrieving a log writer for tracing messages from the data source.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to manage the login timeout for connecting to a database.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCommonDataSource\u003c/code\u003e includes a \u003ccode\u003egetParentLogger\u003c/code\u003e method, offering control over logging configurations.\u003c/p\u003e\n"]]],[],null,["# CommonDataSource\n\npublic interface **CommonDataSource** \n\n|---|---|---|\n| Known Indirect Subclasses [ConnectionPoolDataSource](../../../reference/javax/sql/ConnectionPoolDataSource.html), [DataSource](../../../reference/javax/sql/DataSource.html) |----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| | [ConnectionPoolDataSource](../../../reference/javax/sql/ConnectionPoolDataSource.html) | A factory for `PooledConnection` objects. | | [DataSource](../../../reference/javax/sql/DataSource.html) | A factory for connections to the physical data source that this `DataSource` object represents. | |||\n\nInterface that defines the methods which are common between `DataSource`,\n`XADataSource` and `ConnectionPoolDataSource`.\n\n\n### Public Method Summary\n\n|---------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [PrintWriter](../../../reference/java/io/PrintWriter.html) | [getLogWriter](../../../reference/javax/sql/CommonDataSource.html#getLogWriter())() Retrieves the log writer for this `DataSource` object. |\n| abstract int | [getLoginTimeout](../../../reference/javax/sql/CommonDataSource.html#getLoginTimeout())() Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. |\n| abstract [Logger](../../../reference/java/util/logging/Logger.html) | [getParentLogger](../../../reference/javax/sql/CommonDataSource.html#getParentLogger())() Return the parent Logger of all the Loggers used by this data source. |\n| abstract void | [setLogWriter](../../../reference/javax/sql/CommonDataSource.html#setLogWriter(java.io.PrintWriter))([PrintWriter](../../../reference/java/io/PrintWriter.html) out) Sets the log writer for this `DataSource` object to the given `java.io.PrintWriter` object. |\n| abstract void | [setLoginTimeout](../../../reference/javax/sql/CommonDataSource.html#setLoginTimeout(int))(int seconds) Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. |\n\nPublic Methods\n--------------\n\n#### public abstract [PrintWriter](../../../reference/java/io/PrintWriter.html)\n**getLogWriter**\n()\n\n\u003cbr /\u003e\n\nRetrieves the log writer for this `DataSource`\nobject.\n\nThe log writer is a character output stream to which all logging\nand tracing messages for this data source will be\nprinted. This includes messages printed by the methods of this\nobject, messages printed by methods of other objects manufactured\nby this object, and so on. Messages printed to a data source\nspecific log writer are not printed to the log writer associated\nwith the `java.sql.DriverManager` class. When a\n`DataSource` object is\ncreated, the log writer is initially null; in other words, the\ndefault is for logging to be disabled. \n\n##### Returns\n\n- the log writer for this data source or null if logging is disabled \n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs |\n|---------------------------------------------------------------|-----------------------------------|\n\n##### See Also\n\n- [setLogWriter(PrintWriter)](../../../reference/javax/sql/CommonDataSource.html#setLogWriter(java.io.PrintWriter)) \n\n#### public abstract int\n**getLoginTimeout**\n()\n\nGets the maximum time in seconds that this data source can wait\nwhile attempting to connect to a database. A value of zero\nmeans that the timeout is the default system timeout\nif there is one; otherwise, it means that there is no timeout.\nWhen a `DataSource` object is created, the login timeout is\ninitially zero. \n\n##### Returns\n\n- the data source login time limit \n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs. |\n|---------------------------------------------------------------|------------------------------------|\n\n##### See Also\n\n- [setLoginTimeout(int)](../../../reference/javax/sql/CommonDataSource.html#setLoginTimeout(int)) \n\n#### public abstract [Logger](../../../reference/java/util/logging/Logger.html)\n**getParentLogger**\n()\n\nReturn the parent Logger of all the Loggers used by this data source. This\nshould be the Logger farthest from the root Logger that is\nstill an ancestor of all of the Loggers used by this data source. Configuring\nthis Logger will affect all of the log messages generated by the data source.\nIn the worst case, this may be the root Logger. \n\n##### Returns\n\n- the parent Logger for this data source \n\n##### Throws\n\n| [SQLFeatureNotSupportedException](../../../reference/java/sql/SQLFeatureNotSupportedException.html) | if the data source does not use `java.util.logging``.` |\n|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------|\n\n#### public abstract void\n**setLogWriter**\n([PrintWriter](../../../reference/java/io/PrintWriter.html) out)\n\n\u003cbr /\u003e\n\nSets the log writer for this `DataSource`\nobject to the given `java.io.PrintWriter` object.\n\nThe log writer is a character output stream to which all logging\nand tracing messages for this data source will be\nprinted. This includes messages printed by the methods of this\nobject, messages printed by methods of other objects manufactured\nby this object, and so on. Messages printed to a data source-\nspecific log writer are not printed to the log writer associated\nwith the `java.sql.DriverManager` class. When a\n`DataSource` object is created the log writer is\ninitially null; in other words, the default is for logging to be\ndisabled. \n\n##### Parameters\n\n| out | the new log writer; to disable logging, set to null |\n|-----|-----------------------------------------------------|\n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs |\n|---------------------------------------------------------------|-----------------------------------|\n\n##### See Also\n\n- [getLogWriter()](../../../reference/javax/sql/CommonDataSource.html#getLogWriter()) \n\n#### public abstract void\n**setLoginTimeout**\n(int seconds)\n\n\u003cbr /\u003e\n\nSets the maximum time in seconds that this data source will wait\nwhile attempting to connect to a database. A value of zero\nspecifies that the timeout is the default system timeout\nif there is one; otherwise, it specifies that there is no timeout.\nWhen a `DataSource` object is created, the login timeout is\ninitially zero. \n\n##### Parameters\n\n| seconds | the data source login time limit |\n|---------|----------------------------------|\n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs. |\n|---------------------------------------------------------------|------------------------------------|\n\n##### See Also\n\n- [getLoginTimeout()](../../../reference/javax/sql/CommonDataSource.html#getLoginTimeout())"]]