Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

get ClassCastException when getting database connection from JNDI

534692Feb 25 2008 — edited Feb 27 2008
I tried to get database connection through datasource in AS server in my java code. But I got ClassCastException in run time. I wonder if I used the right class. I am using AS 10.1.3.3.

Can anyone help? thank you!

Exception: java.lang.ClassCastException: oracle_jdbc_driver_LogicalConnection_Proxy



My code is like this:

public static OracleConnection getJNDIConnection() {
OracleConnection conn = null;
DataSource ds =null;
try {
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Context initCtx = new InitialContext();
ds = (DataSource) initCtx.lookup("jdbc/DEAMS_CONNECTION_POOL");
System.out.println("Start getting connection.... " );
conn = (OracleConnection)ds.getConnection();
System.out.println("got connection. " );
} catch (SQLException e) {
System.out.println("Cannot get connection: " + e);
} catch (NamingException e) {
System.out.println("NamingException: " + e);
}
catch (Exception e) {
System.out.println("Exception: " + e);
}
return conn;
}

Message was edited by:
KateShan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2008
Added on Feb 25 2008
2 comments
1,512 views