Accessing mysql database on a remote machine
Hi!
I have some problems connecting to a mysql databse on a remote machine.
Connecting with the mysql console works fine.
Trying to access the db over AppServer 7 results in a NameNotFoundException. Here are some code snippets and configuration details:
Configuration of connection pool:
Driver -> com/mysql/jdbc/jdbc2/optional/MysqlDataSource
serverName -> <SERVERNAME>
portNumber -> 3306
networkProtocol -> tcp
user -> <USERNAME>
password -> <PASSWORD>
databaseName -> <DATABASE>
getConnection() method in my EJBs:
private Connection getConnection()throws SQLException{
try{
Context jndiCntx =new InitialContext();
DataSource ds = (DataSource)jndiCntx.lookup("java:comp/env/jdbc/<DATABASE>");
return ds.getConnection();
}
catch (NamingException ne){
thrownew EJBException(ne);
}
}
Exception when trying to login:
[22/Oct/2003:12:15:51] WARNING (13304): CORE3283: stderr: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[22/Oct/2003:12:15:51] WARNING (13304): CORE3283: stderr:java.rmi.RemoteException: nested exception is: javax.naming.NameNotFoundException; nested exception is:
[22/Oct/2003:12:15:51] WARNING (13304): CORE3283: stderr:javax.naming.NameNotFoundException
[22/Oct/2003:12:15:51] WARNING (13304): CORE3283: stderr:at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:364)
[22/Oct/2003:12:15:51] WARNING (13304): CORE3283: stderr:at javax.rmi.CORBA.Util.wrapException(Util.java:277)
...
Trying a local database (AS 7 and mysql on the same machine) also works fine.
Where is the problem? Do I have to register the jndi name in any factory and when, how?
Can anyone help me please?
Thx,
j.k.

