on 01-13-2006 10:06 AM
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
Hi,
have the answers been of any value for you? If yes, please consider rewarding points for helpful answers! Thanks in avance!
Best regards
Detlev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vito,
could you please tell us
- what driver jars you are using?
- what oracle db you are attempting to access to (version)?
- what your DS config looks like, passing the exported DS xml along?
- if, after definition, you did test the DS?
I'm really convinced, making a DS fly, even on *nix, can be done. Let's give it another try!
Regards
Gregor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pls. Recheck whether the datasource is deployed properly and it is referring proper connection pool.
Instead of testing the connection pool through code, check connection pool through server whether configuration is correct. It should give ok.
Hope this will help you.
Regards,
Mani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vito,
as already written last night:
> java:comp/env/<b>ejb</b>/ORDINE_MODELLO_POOL
?!?! Is this a typo?!
Hope it helps
Detlev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vito,
the error is in the lookup of the datasource
<b>DataSource ds = (DataSource) ctx.lookup("java:comp/env/ejb/ORDINE_MODELLO_POOL");</b>
Though exactly what the problem is I can not tell you as I am not familiar with your application. You are either referencing the datasource wrong or the the service is not active or deployed.
You could try a direct JDBC connection.
regards,
Dion
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.