java.lang.Object
org.seasar.doma.jdbc.SimpleDataSource
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
A simple data source that creates
Connection by using DriverManager.getConnection(String, Properties).
It is assumed that this object is used only in simple applications. In production environment,
you should use the DataSource implementation that provides connection pooling.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected final Propertiesprotected static final StringtheSQLStatecode to indicate that the this data source is unable to establish the connectionprotected Stringprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(String key, String value) Add a JDBC property.getConnection(String user, String password) protected ConnectionintReturns the database passwordgetUrl()Returns the database url.getUser()Returns the database user.booleanisWrapperFor(Class<?> iface) voidsetLoginTimeout(int seconds) voidsetLogWriter(PrintWriter out) voidsetPassword(String password) Sets the database passwordvoidSets the database url of the formjdbc:subprotocol:subname.voidSets the database user.<T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilderMethods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Field Details
-
UNABLE_TO_ESTABLISH_CONNECTION
theSQLStatecode to indicate that the this data source is unable to establish the connection- See Also:
-
url
-
user
-
password
-
properties
-
-
Constructor Details
-
SimpleDataSource
public SimpleDataSource()
-
-
Method Details
-
getUrl
Returns the database url.- Returns:
- the database url
-
setUrl
Sets the database url of the formjdbc:subprotocol:subname.- Parameters:
url- the database url
-
getUser
Returns the database user.- Returns:
- the database user
-
setUser
Sets the database user.- Parameters:
user- the database user
-
getPassword
Returns the database password- Returns:
- the database password
-
setPassword
Sets the database password- Parameters:
password- the database password
-
addProperty
Add a JDBC property.- Parameters:
key- the key of the propertyvalue- the value of the property
-
getLoginTimeout
public int getLoginTimeout()- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource
-
setLoginTimeout
public void setLoginTimeout(int seconds) - Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnectionInternal
- Throws:
SQLException
-
getLogWriter
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Throws:
SQLException
-
setLogWriter
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-