How to specify JDBC Oracle url using deployment tool - Entity Bean
Hello I'am new to EJB.
When creating a entity bean-managed persistence and you need to specify the jdbc url with user name
and password to establish a connection object, how does one specify that in the deployment
tool?
Heres an example of what has in the J2EE tutorial has in AccountEJB to get an connection object
private String dbName = "java:comp/env/jdbc/AccountDB";
private void makeConnection() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
}
Now if my oracle jdbc url is to be jdbc:oracle:thin:@Abe:1521:dev
ie My host is Abe, port number 1521 and database name of dev and username/password will be system/manager.
what would my dbName be at the top?
Would my JNDI lookup of a DataSource resource "java:comp/env/jdbc/AccountDB" become "java:comp/env/jdbc/dev" for starters?
In the Resource Factories Reference Code I've add a reference of
Coded Name: jdbc/dev
Type: javax.sql.DataSource
Authentication: Container
and down the bottom of the I've put JNDI Name: MyAccount
according to the AccountClient code of:
Context initial = new InitialContext();
Object objref = initial.lookup("MyAccount");
and put User Name of "system" and Password of "manager"
I'am sure in the source code I have to put
Class.forName("oracle.jdbc.driver.OracleDriver")
else you would get that no sutitable driver error, maybe you don't have to if ejb server is smart enough?
What I'am confuse about is where to specify the jdbc url of "jdbc:oracle:thin:@Abe:1521:dev" ?
Know it won't work because of this vital part. Do you have to put that somewhere else in the deployment tool or properties file, or some other tool?
Please help
Thanks
Abraham Khalil
[1989 byte] By [
akhalil100] at [2007-9-26 4:52:14]

Hi,
I have been using Oracle OCI as my driver and Iplanet as my application server and Web server and i have been using a props file to register the JNDI name with the application server and execute the dsreg command and th eserver registers the database server with the application server for that data source.
The prop files contains the following thing.
DataBase=<Oracle SID>
DataSource=<instance name>
UserName=<username>
PassWord=<password>
DriverType=ORACLE_OCI
command used is as follows
dsreg <lookup name> abc.props.
eg <lookup name>=jdbc/AccountDB
Bye.
To specify drivers in Deploytool -
Go to Tools Menu
Select Server Configuration
Select DataSources/Standard
Under JDBC Drivers add "oracle.jdbc.thin.OracleDriver"
Under JNDI names add "jdbc/dev"
Under JDBC URL add "jdbc:oracle:thin:@Abe:1521:dev"
add the full path of the OracleDriver (classes12.zip) to the environment variable "J2EE_CLASSPATH"
When running the client after successful deployment with jdbc, I'am getting
javax.naming.CommunicationException: java.rmi.MarshalException: CORBA MARSHAL 1398079699 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :minor code: 1398079699 completed: Maybe
org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge :minor code: 1398079699 completed: Maybe
at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:923)
at com.sun.corba.ee.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:281)
at com.sun.corba.ee.internal.corba.TCUtility.unmarshalIn(TCUtility.java:274)
at com.sun.corba.ee.internal.corba.AnyImpl.read_value(AnyImpl.java:554)
at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:605)
at com.sun.corba.ee.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:252)
at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.readAny(Util.java:203)
at javax.rmi.CORBA.Util.readAny(Unknown Source)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lookup(Unknown Source)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:133)
at javax.naming.InitialContext.lookup(Unknown Source)
at AccountClient.main(AccountClient.java:21)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:151)
at javax.naming.InitialContext.lookup(Unknown Source)
at AccountClient.main(AccountClient.java:21)
One thing I don't like about EJB is that everything is transparent which is good! But its much
harder to debug! :( Tried to see if I can figure it out. Hope someone has seen this problem before?
Ignore my last error message.
If you get this error when deploying. What would be roughly causing it?
Compilation failed.
at com.sun.ejb.codegen.GeneratorDriver.compileClasses(GeneratorDriver.java:319)
at com.sun.ejb.codegen.GeneratorDriver.compileAndRmic(GeneratorDriver.java:203)
at com.sun.ejb.codegen.GeneratorDriver.preDeploy(GeneratorDriver.java:872)
at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployEjbs(JarInstallerImpl.java:709)
at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:216)
at com.sun.enterprise.tools.deployment.backend.JarInstallerImpl.deployApplication(JarInstallerImpl.java:124)
at org.omg.stub.com.sun.enterprise.tools.deployment.backend._JarInstallerImpl_Tie._invoke(Unknown Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:334)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:272)
at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)