Unable to access MySQL datasource
offline Apr 22, 2004 1:37 AMAlright, I'm going to admit right off that i am *learning* J2EE programming, and i am currently at a very elementary stage of it. So, if answering questions that seem really obvious to you isn't your bag, i'd stop reading about... now.
On to the question(s?):
I'm trying to go through the IBM DeveloperWorks tutorial for EJBs without installing yaeas (Yet Another Enterprise Application Server) on my poor little machine. I currently have JBoss (3.2.??) installed with Tomcat as the web container. I use Eclipse and the MyEclipse plugin to develop.
I have configured the MySQL datasource and deployed it, with the following XML:
<datasources> <local-tx-datasource> <jndi-name>MySQLDS</jndi-name> <connection-url>jdbc:mysql://192.168.1.50:3306/webapp</connection-url> <driver-class>org.gjt.mm.mysql.Driver</driver-class> <user-name>usename</user-name> <password>******</password> </local-tx-datasource> </datasources>
And i am trying to access it in a client application like so:
ic = new InitialContext(env); ds = (DataSource)ic.lookup( sJNDIdbName ); con = ds.getConnection(); stmt = con.createStatement();
And i get a:
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
(many more...)
So, much as i'd like to get up and running trying to code examples, i'm stuck trying to figure out what braindead mistakes i've made setting it up. Is there someone here that can help me, or better yet, help me to help myself?
It's worth noting that this program is not a bean, it's a command line app that i just want to run to insert the tables for a tutorial. It should do nothing but connect to the database. I mention this because i actually have no idea whatsoever *yet) how to do JBoss deployment descriptors, but it's my belief that they're not relevant to this problem. I welcome being disabused, however.
Thanks in advance for the help.