| java.lang.Object org.h2.message.TraceObject org.h2.jdbcx.JdbcDataSource
JdbcDataSource | public class JdbcDataSource extends TraceObject implements XADataSource,DataSource,ConnectionPoolDataSource,Serializable,Referenceable(Code) | | A data source for H2 database connections. It is a factory for XAConnection
and Connection objects. This class is usually registered in a JNDI naming
service. To create a data source object and register it with a JNDI service,
use the following code:
import org.h2.jdbcx.JdbcDataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:˜/test");
ds.setUser("sa");
ds.setPassword("sa");
Context ctx = new InitialContext();
ctx.bind("jdbc/dsName", ds);
To use a data source that is already registered, use the following code:
import java.sql.Connection;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/dsName");
Connection conn = ds.getConnection();
In this example the user name and password are serialized as
well; this may be a security problem in some cases.
|
JdbcDataSource | public JdbcDataSource()(Code) | | The public constructor.
|
getConnection | public Connection getConnection() throws SQLException(Code) | | Open a new connection using the current URL, user name and password.
the connection |
getConnection | public Connection getConnection(String user, String password) throws SQLException(Code) | | Open a new connection using the current URL and the specified user name
and password.
Parameters: user - the user name Parameters: password - the password the connection |
getLoginTimeout | public int getLoginTimeout() throws SQLException(Code) | | Get the login timeout in seconds, 0 meaning no timeout.
the timeout in seconds |
getPassword | public String getPassword()(Code) | | Get the current password.
the password |
getPooledConnection | public PooledConnection getPooledConnection() throws SQLException(Code) | | Open a new XA connection using the current URL, user name and password.
the connection |
getPooledConnection | public PooledConnection getPooledConnection(String user, String password) throws SQLException(Code) | | Open a new XA connection using the current URL and the specified user
name and password.
Parameters: user - the user name Parameters: password - the password the connection |
getReference | public Reference getReference() throws NamingException(Code) | | Get a new reference for this object, using the current settings.
the new reference |
getURL | public String getURL()(Code) | | Get the current URL.
the URL |
getUser | public String getUser()(Code) | | Get the current user name.
the user name |
getXAConnection | public XAConnection getXAConnection() throws SQLException(Code) | | Open a new XA connection using the current URL, user name and password.
the connection |
getXAConnection | public XAConnection getXAConnection(String user, String password) throws SQLException(Code) | | Open a new XA connection using the current URL and the specified user
name and password.
Parameters: user - the user name Parameters: password - the password the connection |
setLogWriter | public void setLogWriter(PrintWriter out) throws SQLException(Code) | | Set the current log writer for this object.
This value is ignored by this database.
Parameters: out - the log writer |
setLoginTimeout | public void setLoginTimeout(int timeout) throws SQLException(Code) | | Set the login timeout in seconds, 0 meaning no timeout.
The default value is 0.
This value is ignored by this database.
Parameters: timeout - the timeout in seconds |
setPassword | public void setPassword(String password)(Code) | | Set the current password
Parameters: password - the new password. |
setURL | public void setURL(String url)(Code) | | Set the current URL.
Parameters: url - the new URL |
setUser | public void setUser(String user)(Code) | | Set the current user name.
Parameters: user - the new user name |
Fields inherited from org.h2.message.TraceObject | final public static int CALLABLE_STATEMENTCONNECTIONDATABASE_META_DATAPREPARED_STATEMENTRESULT_SETRESULT_SET_META_DATASAVEPOINTSQL_EXCEPTIONSTATEMENTBLOBCLOBPARAMETER_META_DATA(Code)(Java Doc) final public static int DATA_SOURCEXA_DATA_SOURCEXIDARRAY(Code)(Java Doc)
|
|
|