Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Need help urgent

 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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: m_chisty@hotmail.com
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, have a look at the JMX console (i don't remember exactly the URL). It helps you a lot to check all your services and MBeans. You should be able to check whether your jdbc is bound or not.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Natkin Nat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic