Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with lookup("jdbc/OracleSample")-it doesn't work

Status
Not open for further replies.

davinia1

Programmer
Jul 2, 2004
12
ES
Hi,
I've found this code in a manual of websphere, but it seems that it doesn't find jdbc\OracleSample:

Could you help me, please? I would be very grateful.


// Retrieve a DataSource through the JNDI Naming Service

java.util.Properties parms = new java.util.Properties();
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

// Create the Initial Naming Context
javax.naming.Context ctx = new javax.naming.InitialContext(parms);

// Lookup through the naming service to retrieve a DataSource object
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/OracleSample");

// Obtain a Connection from the DataSource
java.sql.Connection conn = ds.getConnection();

// Retrieve a DataSource through the JNDI Naming Service

java.util.Properties parms = new java.util.Properties();
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

// Create the Initial Naming Context
javax.naming.Context ctx = new javax.naming.InitialContext(parms);

// Lookup through the naming service to retrieve a DataSource object
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/OracleSample");

// Obtain a Connection from the DataSource
java.sql.Connection conn = ds.getConnection();

If I write:
ctx.lookup("jdbc/OracleSample"); I get:
Error 500: DSRA9002E: ResourceException con código de error null: javax.resource.spi.ResourceAllocationException: Caught ResourceException thrown during creation of the ManagedConnection. at

In the server configuration, I've created in JDBC Provider List:
Name: OracleDriver
Implementation class name: oracle.jdbc.pool.OracleDataSource
Classpath: c:\oracle\ora92\jdbc\lib\classes12.zip
c:\oracle\ora92\jdbc\lib\nls_charset12.jar
Native Path: C:\oracle\ora92\jlib\jndi.jar

I've created a DataSource:
Name: DataSourceOracle
JNDIName: jdbc/OracleSample

I've refilled:
driverType: thin
databasename: SID
serverName: maquina
portNumber: puerto
Url: jdbc:eek:racle:thin@maquina:puerto:SID

I work with Oracle9i

Thanks in advance.
Davinia.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top