how to use connection pool in ejb?(100分)

  • 主题发起人 主题发起人 netxray
  • 开始时间 开始时间
N

netxray

Unregistered / Unconfirmed
GUEST, unregistred user!
i put below codes in setEntityContext method.
but i get a error message from console:
java.lang.ClassCastException in setEntityContext.
why?can u help me?thanks a lot.
----------------------------------------------
// Create a OracleConnectionPoolDataSource instance
OracleConnectionPoolDataSource ocpds = (OracleConnectionPoolDataSource)ic.lookup(dbName);
// Create a pooled connection
PooledConnection pc = ocpds.getPooledConnection();
// Get a Logical connection
con = pc.getConnection();
-------------------------------------------------
 
you must creat a datasource in application server such as websphere or weblogic
 
i am use J2EE server.how todo
it now?
i get this idea from http://www.cn.ibm.com/developerWorks/java/j-pool/index_eng.shtml
i mean use oracle.jdbc.pool.*...
 
weblogic 里有一个例子,可参考
 
I have no experience on Sun J2ee server .But based on analyse your code,I think
you should adjust the position of oracle.jdbc.pool.*... class file.Is there more
than two position which the class file stay at?If so or not,change you classpath for
Sun J2ee server .
good lucky!
 
check variable declaration
 
TO 小猪:
Ido
n't understand What did you said ?
Give me explain for the creation of datasouce in aplication server ,Please
 
ido
nt't know if it is the key,
had u create a datasource called as the dbname which u lookup in
ur code?
following is how to use datasource in websphere

Hashtable params=new Hashtable();
params.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
Context ctx=new InitialContext(params);
DataSource ds=(DataSource)ctx.lookup("mydbsource");
Connection conn=ds.getConnection("user name","password");
now if i want it to execute successfully,i must create a datasource named
"mydbsource" in websphere manager consoal.
u must know that the datasource's name is its jndi name.
 
多人接受答案了。
 
后退
顶部