Skip to Content
0
Former Member
Jan 13, 2006 at 10:06 AM

Oracle connection using DataSource

22 Views

Hi all,

I'm trying to connect Oracle DB using dataSource from an EJB:

try {

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("java:comp/env/ejb/ORDINE_MODELLO_POOL");

Connection con = ds.getConnection();

String query = "select ordine_modello_sq.nextval from dual";

Statement stmt = con.createStatement();

try {

ResultSet rs = stmt.executeQuery(query);

try {

while ( rs.next() ) {

//Insert the sequence value

int prog_ordine_int = rs.getInt(1);

prog_ordine_seq = new Integer(prog_ordine_int);

}

} finally {

rs.close();

}

} finally {

stmt.close();

}

}catch (Exception e) {

e.printStackTrace();

}

I have this error:

com.sap.engine.services.jndi.persistent.exceptions.NamingException: Exception during lookup operation of object with name ejbContexts/sap.com/ModelloApplication/MySessionBean/java:comp/env/jdbc/ORDINE_MODELLO_POOL, cannot resolve object reference. [Root exception is com.sap.engine.services.connector.exceptions.BaseResourceException: ConnectionFactory "jdbc/ORDINE_MODELLO_POOL" does not exist. Possible reasons: the connector in which ConnectionFactory "jdbc/ORDINE_MODELLO_POOL" is defined is not deployed or not started.]

What I can do to solve the problem? Thanks to all.

Vito