non-JNDI EntityBean Oracle solution?

Hi -

I was wondering about an alternate way to

connect to Oracle from an entity bean...

In the J2EE examples for entity beans, the

context is queried to find the datasource

and then the datasource is queried to get

a connection.

To replace CLOUDSCAPE with ORACLE in the

reference implementation, I was thinking,

why not change the makeConnection() call,

in order/OrderBean.java from:

InitialContext ic = new InitialContext();

DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/Oracle");

m_conn = ds.getConnection();

to:

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

m_conn = DriverManager.getConnection("jdbc:oracle:thin:...", "scott", "tiger");

} catch (Exception e) { }

What are the implications of connecting

directly to Oracle and not using JNDI?

[904 byte] By [gavinelster] at [2007-9-26 2:04:32]
# 1
No difference, just different way provide the connect string.
fayefun at 2007-6-29 8:48:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

A datasource uses a connection pool. When you request a connection using the JDBC API, the connection is not obtained from the pool, resulting in more connections needed, plus a longer time to obtain the connection (for the connection in a pool is already established).

Raphael Parree

RaphaelP at 2007-6-29 8:48:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Yes, I have tried just now, RaphaeIP is right!
fayefun at 2007-6-29 8:48:34 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...