The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
March 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Remote Exception EJB with Mysql

Posted by najmi on March 27, 2001 at 6:01 AM


I am working on a class project and am having a problem connecting between the J2EE Reference
Implementation Server and MySql. I have set-up the defualt.properties file for MySql


# JDBC Driver Examples:
# Oracle thin driver: oracle.jdbc.driver.OracleDriver
# Merant driver: intersolv.jdbc.sequelink.SequeLinkDriver
# Cloudscape driver: COM.cloudscape.core.RmiJdbcDriver
# MySQL driver: org.gjt.mm.mysql.Driver
#
#jdbc.drivers=org.gjt.mm.mysql.Driver
#jdbc.drivers=COM.cloudscape.core.RmiJdbcDriver
jdbc.drivers=org.gjt.mm.mysql.Driver|COM.cloudscape.core.RmiJdbcDriver

# JDBC URL Examples:
# Oracle thin driver:
# jdbc:oracle:thin:@::
# Cloudscape RMI driver:
# jdbc:cloudscape:rmi:;create=true
# Merant driver:
# jdbc:sequelink://:/[SQLServer];Database=
#
# MySQL driver:
# jdbc:mysql://:/
#jdbc.datasources=jdbc/Cloudscape|jdbc:cloudscape:rmi:CloudscapeDB;create=true
#jdbc.datasources=jdbc/Mysql|jdbc:mysql://localhost:3306/ThePackED?
#jdbc.datasources=jdbc/Cloudscape|jdbc:cloudscape:rmi:CloudscapeDB;create=true
jdbc.datasources=jdbc/mysql|jdbc:mysql://localhost:3306/ThePackED|jdbc/Cloudscape|jdbc:cloudscape:rmi:CloudscapeDB;create=true

Here is the code in a sample EJB for making a connection
/**
* a logical database name to be used to access data
* this will be remove after we are able to use
* the connection manager.
*/

private String dbName = "java:comp/env/jdbc/ThePackED";

/**
* make a connection with the MySQL database via a Application Server
*/
private void makeConnection() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup(dbName);
conn = ds.getConnection();
}

And here is the client information

public class GenerateDocumentListClient {
public static void main(String[] args) {
try {
Context initial = new InitialContext();
Object objref = initial.lookup("GenerateDocumentListBean");
GenerateDocumentListHome home = (GenerateDocumentListHome)PortableRemoteObject.narrow(objref,
GenerateDocumentListHome.class);
GenerateDocumentList aGenerateDocumentList = home.create();
// write your test code here
System.out.println("aGenerateDocumentList = " + aGenerateDocumentList);
System.out.println(aGenerateDocumentList.getProjectListTable());
aGenerateDocumentList.remove();
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
}

Here is what the application tells me

// this is the value of aGenerateDocumentList after the home.create method call
aGenerateDocumentList =IOR:0000000000000034524d493a7265706f7274696e672e47656e6572617465446f63756d656e744c6973743a30303030303030303030303030303030000000000100000000000000de000101000000000e3139322e3136382e312e3130320004de00000021afabcafe00000020b25dc41b000000020000000d0000000004000000040000000100000000000002000000010000001400000000000100200000000000010100000000000000001900000076000000000000006e66696c653a2f633a2f6a3273646b6565312e322e312f7265706f7369746f72792f57323030302f6170706c69636174696f6e732f5265706f7274696e67436c69656e742e6a617220687474703a2f2f57323030303a393139312f5265706f7274696e67436c69656e742e6a61720

when I try to execute the business method getProjectList I get this:

Caught an unexpected exception!

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.; nested exception is:
javax.ejb.EJBException

java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.; nested exception is:
javax.ejb.EJBException

javax.ejb.EJBException

<>

If anyone could tell me whats wrong or give me an example or sample code for setting up the bean, client
I would greatly appreciate it!


Thanks!
najmi



Replies:
  • JDBC chris Long July 23, 2001 at 5:16 AM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us