Hi, I am trying to connect to Jboss3.2 & Mysql 3 .I have modified the mysql-ds.xml such that it now reads <jndi-name>jdbc/MySqlDS</jndi-name> Have pasted the mysql driver in appropriate places. When I see the web-console i see the jdbc/MySqlDS under jboss.jca. The log file also shows JNDI name bound to 'java:/jdbc/MySqlDS' However when i try to use i from the client as: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "localhost"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces" ); Context ctx = new InitialContext(env); System.out.println(ctx); DataSource ds = (DataSource) ctx.lookup("java:/jdbc/MySqlDS"); I get a NameNotBound :jdbc not bound Exception
I also tried this: DataSource ds = (DataSource) ctx.lookup("jdbc/MySqlDS"); Still i get the same exception. Please help.
1. First check that your mysql-ds.xml file is configured as follows (assuming that your database name is "XYZ"): <datasources> <local-tx-datasource> <jndi-name>DefaultDS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/XYZ</connection-url> <driver-class>org.gjt.mm.mysql.Driver</driver-class> <user-name>root</user-name> <password>123</password> </local-tx-datasource> </datasources> Note the tags <jndi-name> and <connection-url> (just put DefaultDS rather than jdbc/MySqlDS if you want MySQL as your default database and simply delete the hsqldb-ds.xml file) 2. Within your code, just include the lines: InitialContext ictx=new InitialContext(); DataSource ds=(DataSource)ictx.lookup("java:comp/env/jdbc/mydb"); Please note the standard enc format "java:comp/env". Also, note that the datasource name format "jdbc/mydb". Don't worry about the "mydb" part, just place any arbitrary name you like with the prefix "jdbc/" Now deploy the whole thing. I hope it, should work now. M. M. Islam Chisty Dhaka, Bangladesh Email: email@example.com
M. M. Islam Chisty<br />Sr. J2EE Engineer<br />M&H Informatics<br />Ph. 8802-7121293<br />Dhaka, Bangladesh
I have similar problem. I checked my mysql-ds.xml - it's ok. When I'm trying to get dataSource reference the error I get is the following: javax.naming.NameNotFoundException: comp not bound My code is as follows: Context ctx = new InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/mydb"); As there's no free docs available on this topic (at least I haven't found any), can anyone give me a peace of valuable advice? One more question. How to redirect output of jboss console in Windows bat file? I cannot check the console output - it's too long.
Joined: Oct 09, 2003
I want to run jboss3.2 with mysql4.0. I've copied the mysql-ds.xml from examples to default/deploy directory, changed <jndi-name> to DefaultDS in this file and removed hsqldb-ds.xml.
The output I have from jboss3.2 startup shows that it starts & binds hypersonic & tries to use hsqldb-ds.xml (which couldn't be found because I removed it). Is there any configuration file in jboss where i can indicate that i want to use mysql-ds.xml & mysql database instead of hypersonic. Please, help me to deal with this problem!
Take a look at the notes available here. I had to tweak them a bit, but was able to do all of the various activities eventually. Using MySql is covered for the CMP example. [ October 09, 2003: Message edited by: Barry Gaunt ]