|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface DataSource
The javax.sql.DataSource implementation of SunONE application
server will implement this interface. An application program would be able
to use this interface to do the extended functionality exposed by SunONE
application server.
A sample code for getting driver's connection implementation would like the following.
InitialContext ic = new InitialContext();
com.sun.appserv.DataSource ds = (com.sun.appserv.DataSOurce) ic.lookup("jdbc/PointBase");
Connection con = ds.getConnection();
Connection drivercon = ds.getConnection(con);
// Do db operations.
con.close();
| Method Summary | |
|---|---|
Connection |
getConnection(Connection con)
Retrieves the actual SQLConnection from the Connection wrapper implementation of SunONE application server. |
Connection |
getNonTxConnection()
Gets a connection that is not in the scope of any transaction. |
Connection |
getNonTxConnection(String userName,
String password)
Gets a connection that is not in the scope of any transaction. |
void |
markConnectionAsBad(Connection conn)
API to mark a connection as bad. |
| Methods inherited from interface javax.sql.DataSource |
|---|
getConnection, getConnection |
| Methods inherited from interface javax.sql.CommonDataSource |
|---|
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter |
| Methods inherited from interface java.sql.Wrapper |
|---|
isWrapperFor, unwrap |
| Method Detail |
|---|
Connection getConnection(Connection con)
throws SQLException
con - Connection obtained from Datasource.getConnection()
java.sql.Connection implementation of the driver.
java.sql.SQLException - If connection cannot be obtained.
SQLException
Connection getNonTxConnection()
throws SQLException
java.sql.Connection
java.sql.SQLException - If connection cannot be obtained
SQLException
Connection getNonTxConnection(String userName,
String password)
throws SQLException
user - User name for authenticating the connectionpassword - Password for authenticating the connection
java.sql.Connection
java.sql.SQLException - If connection cannot be obtained
SQLExceptionvoid markConnectionAsBad(Connection conn)
com.sun.appserv.jdbc.DataSource ds=
(com.sun.appserv.jdbc.DataSource)context.lookup("dataSource");
Connection con = ds.getConnection();
Statement stmt = null;
try{
stmt = con.createStatement();
stmt.executeUpdate("Update");
}catch(BadConnectionException e){
dataSource.markConnectionAsBad(con) //marking it as bad for removal
}finally{
stmt.close();
con.close(); //Connection will be destroyed while close or Tx completion
}
conn - java.sql.Connection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||