Hola,
me podeis ayudar?
Cuando me intento conectar a una base de datos (Oracle9i) con el siguiente codigo me da los siguientes errores de ejecucion:
// 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();
El problema creo que esta en lookup, si pongo ctx.lookup("java:comp/env/jdbc/OracleSample"); obtengo:
[6/07/04 9:59:34:953 CEST] 583b210f WebGroup E SRVE0026E: [Error de servlet]-[Name jdbc not found in context "java:".]: javax.naming.NameNotFoundException: Name jdbc not found in context "java:".
si pongo ctx.lookup("jdbc/OracleSample"); obtengo:
Error 500: DSRA9002E: ResourceException con código de error null: javax.resource.spi.ResourceAllocationException: Caught ResourceException thrown during creation of the ManagedConnection. at
En la configuracion del servidor, en websphere, he creado en 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
He creado un DataSource:
Name: DataSourceOracle
JNDIName: jdbc/OracleSample
He rellenado driverType: thin
databasename: SID
serverName: maquina
portNumber: puerto
Url: jdbc:oracle:thin@maquina:puerto:SID
Gracias por adelantado.
Davinia.