|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.db.DBConnDirect | +--xbn.db.DBConnection
Convenience class for handling a single database connection created from the user/pass/JDBC characteristics. See java.sql.Connection.
Source code: DBConnection.java. Example code XmplDBConnection.
Note: When you set a connection directly, via DBConnDirect.setConnection, be aware of the following. If that connection has a different username/password/JDBC characteristics than was passed into the constructor of this class, then if you disconnect and reconnect, you'll be reconnecting to the database using the same user/pass/JDBC characteristics as provided to the constructor of this class.
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
DBConnection(String s_username,
String s_password,
String s_jdbcConnectionString,
String s_jdbcDriver,
String s_verificationSelect)
Create a DBConnection. |
|
DBConnection(String s_username,
String s_password,
String s_jdbcConnectionString,
String s_jdbcDriver,
String s_verificationSelect,
Outputter optr_dbg)
Create a DBConnection. |
Method Summary | |
void |
connect()
Connect to the database, if not already connected. |
void |
connect(String s_username,
String s_password,
String s_jdbcConnectionString,
String s_jdbcDriver)
Connect to the database. |
String |
getDatabasePassword()
Get the database user's password... |
String |
getDatabaseUsername()
Get the database username. |
String |
getJdbcConnectionString()
Get the JDBC connection string. |
String |
getJdbcDriver()
Get the JDBC driver string. |
String |
toString()
Get some information about this DBConnection. |
Methods inherited from class xbn.db.DBConnDirect |
crashIfNotVerified, dbg, dbgnl, disconnect, finalize, getConnection, getConnectionAndSeparate, getOptrDbg, getVerificationSelect, isConnected, isVerified, isVerified, prepareVerificationSelect, setConnection, setOptrDbg, throwAXDbg, throwSQLX |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DBConnection(String s_username, String s_password, String s_jdbcConnectionString, String s_jdbcDriver, String s_verificationSelect) throws SQLException, ClassNotFoundException
Create a DBConnection.
s_verificationSelect
- Passed directly to the two-parameter constructor of DBConnDirect.All
- other params passed directly to connectpublic DBConnection(String s_username, String s_password, String s_jdbcConnectionString, String s_jdbcDriver, String s_verificationSelect, Outputter optr_dbg) throws SQLException, ClassNotFoundException
Create a DBConnection.
This immediately attempts to connect to the database.
s_verificationSelect
- Passed directly to the two-parameter constructor of DBConnDirect.optr_dbg
- Passed directly to the two-parameter constructor of DBConnDirect.All
- other params passed directly to connectMethod Detail |
public final void connect() throws SQLException, ClassNotFoundException
Connect to the database, if not already connected. You may disconnect and connect repeatedly, although it is process and resource-intensive.
AssertException
- If isConnected is true.SQLException
- If anything database related goes wrong, such as an incorrect username/password combination.ClassNotFoundException
- If anything is inaccurate with the JDBC driver as you provided into the constructor.public String getDatabaseUsername()
Get the database username.
public String getDatabasePassword()
Get the database user's password...
Just kidding. It only returns null.
public String getJdbcDriver()
Get the JDBC driver string.
public String getJdbcConnectionString()
Get the JDBC connection string.
public String toString()
Get some information about this DBConnection.
toString
in class DBConnDirect
public void connect(String s_username, String s_password, String s_jdbcConnectionString, String s_jdbcDriver) throws SQLException, ClassNotFoundException
Connect to the database.
If currently connected, then disconnect.
s_username
- Database username. If non-null, may not be zero characters in length.s_password
- Database password associated to s_username. If non-null, may not be zero characters in length.s_jdbcConnectionString
- JDBC connection string. May not be null or zero characters in length. For example: jdbc:oracle:thin:@horizon.wharton.upenn.edu:1521:dev"
. Your database administrator will be able to help you determine what this (parts of it, anyway) needs to be.s_jdbcDriver
- JDBC driver. May not be null or zero characters in length. For example: "oracle.jdbc.driver.OracleDriver"
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/xbnjava