I am trying to connect to MySQL in JBoss and have problems in getting the DataSource from the JNDI. I can connect to MySQL from the command line (mysql) though.
The MySQL JDBC driver jar file is copied to server/default/lib directory.
I have a mysql-ds.xml copied over to server/default/deploy directory of JBoss with the following entry:
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/MySQLDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/foodb</connection-url>
<driver-class>org.gjt.mm.mysql.Driver</driver-class>
<user-name>foo</user-name>
<password>foo</password>
</local-tx-datasource>
</datasources>
The JBoss Console at http://localhost:8080/jmx-console/index.jsp does show jdbc/MySQLDB:
name=jdbc/MySQLDS,service=LocalTxCM
name=jdbc/MySQLDS,service=ManagedConnectionFactory
name=jdbc/MySQLDS,service=ManagedConnectionPool
My Java code snippet (which is in an EJB implementation) has:
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,
"jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "localhost:1099");
Context ctx = new InitialContext(env);
DataSource ds = (DataSource)ctx.lookup("jdbc/MySQLDS");
I get the following exception.
javax.naming.NameNotFoundException: jdbc not bound
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
-
Problem getting MySQL DataSource in JBoss (2 messages)
- Posted by: Rahul Kumar
- Posted on: March 04 2004 21:09 EST
Threaded Messages (2)
- Problem getting MySQL DataSource in JBoss by vineet bhatia on March 05 2004 08:40 EST
- That doesn't help... by Dave Lilley on April 01 2004 14:57 EST
-
Problem getting MySQL DataSource in JBoss[ Go to top ]
- Posted by: vineet bhatia
- Posted on: March 05 2004 08:40 EST
- in response to Rahul Kumar
The JBoss site has a Datasource configuration forum.
This has been discussed several times there.
- vineet -
That doesn't help...[ Go to top ]
- Posted by: Dave Lilley
- Posted on: April 01 2004 14:57 EST
- in response to vineet bhatia
I have the same question. I looked in the JBoss forums, and somebody posted a smart @ss remark, "look it up with google." I did a search with google, which took me to this page. If you know the answer or have a link to the JBoss thread, please post it.