|
Hi,
I want to execute a query in CMP(my
requirement). I wrote following
method
private DataSource dataSource =
null;
private Connection getConnection() throws
EJBException, SQLException {
if (dataSource == null) { //Finds DataSource from JNDI Context initialContext = null; try { initialContext = new InitialContext(); dataSource = (DataSource)initialContext.lookup("java:comp/env/jdbc/StudentID"); } catch (Exception e) { System.out.println("Cannot lookup dataSource " + e); throw new javax.ejb.EJBException("Cannot lookup dataSource "); } } return dataSource.getConnection(); } But while executing the method i am getting
following error Can you
please tell me what is the
reson.
Error
java.lang.ClassCastException:
student.JOnASStuBeanHome
at student.StudentBean.getConnection(StudentBean.java:59) at student.StudentBean.getStudent(StudentBean.java:79) at student.StudentBean.ejbCreate(StudentBean.java:39) at student.JOnASStuBeanBean.ejbCreate(JOnASStuBeanBean.java:60) at student.JOnASStuBeanHome.create(JOnASStuBeanHome.java:113) at student.JOnASStuBeanHome_Skel.send(JOnASStuBeanHome_Skel.java:40) at org.objectweb.david.libs.protocols.giop.GIOPProtocol$ServerSession_Lo w.send(GIOPProtocol.java:621) at org.objectweb.jonathan.libs.protocols.tcpip.TcpIpProtocol$Session.run (TcpIpProtocol.java:396) at org.objectweb.jonathan.libs.resources.JScheduler$JJob.run(JScheduler. java:265) System exc. => Rollback the transaction. JEntityHome.removeEJBObject: pk = null postinvoke: System Exception in a home method:javax.ejb.EJBException: Cannot lo okup dataSource Regards
Surendra
|
- Re: Database connection in CMP Surendra
- Re: Database connection in CMP H�l�ne JOANIN
- Re: Database connection in CMP Surendra
- Re: Database connection in CMP H�l�ne JOANIN
