This content has been marked as final. Show 1 reply
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/mySQLDS");
Probably you know that this code you can use only if your client is using local interface. It does not work if you want to access it through remote interface!
If your mysql-ds.xml file looks like:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>MySqlDS</jndi-name> <connection-url>jdbc:mysql://brby:3306/jbossdb</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>sbrbot</user-name> <password>...</password> </local-tx-datasource> </datasources>
then your datasource is registered in JBoss JNDI tree as java:/MySqlDS not any other variant.
BTW, use com.mysql.jdbc.Driver, MM's driver is obsolete!