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.

[2397 byte] By [JuergenKlein] at [2007-11-25 10:28:24]
# 1

Solved the problem by myself:

Application Server's borwser interface didn't insert the database URL of jdbc conection pool in server.xml by the correct way. Instead of

jdbc:mysql:@SERVERNAME:PORT/DATABASENAME

it inserted

jdbc:mysql:@SERVERNAME:PORT:DATABASENAME

, so the connection pool couldn't find the database. After editing server.xml it workes!

Juergen Klein at 2007-7-1 20:52:40 > top of Java-index,Application & Integration Servers,Application Servers...