J
jonck
Hi all,
I would like to set up a DBCP connection pool for my stand-alone
application (so not in Tomcat, for which documentation is abundant).
However, I keep getting an "javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context" exception. I have tried everything I
could think of and I'm stumped.
First of all, I tried following the tutorial at
http://jakarta.apache.org/commons/dbcp/guide/jndi-howto.html
After replacing the driverClassName, url, username and password with
real values, this code gives me the NameNotFoundException when I try to
rebind however. So I tried adding the line
ref.add(new StringRefAddr("dataSourceName", "jdbc/sender")); (before
rebinding)
but this improved nothing. So I then tried creating a BasicDataSource
by hand as follows:
BasicDataSource ds = new BasicDataSource();
ds.setUrl("jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useUnicode=true");
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setUsername("xxxxxxxxxx");
ds.setPassword("xxxxxxxxxx");
Context ctx = new InitialContext();
ctx.bind("jdbc/test", ds);
It gives exactly the same error. Obviously I'm missing something
crucial here, but many hours of Googling have not turned up an answer
for me.
Could someone please point me in the right direction?
Thanks very much, Jonck
I would like to set up a DBCP connection pool for my stand-alone
application (so not in Tomcat, for which documentation is abundant).
However, I keep getting an "javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context" exception. I have tried everything I
could think of and I'm stumped.
First of all, I tried following the tutorial at
http://jakarta.apache.org/commons/dbcp/guide/jndi-howto.html
After replacing the driverClassName, url, username and password with
real values, this code gives me the NameNotFoundException when I try to
rebind however. So I tried adding the line
ref.add(new StringRefAddr("dataSourceName", "jdbc/sender")); (before
rebinding)
but this improved nothing. So I then tried creating a BasicDataSource
by hand as follows:
BasicDataSource ds = new BasicDataSource();
ds.setUrl("jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useUnicode=true");
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setUsername("xxxxxxxxxx");
ds.setPassword("xxxxxxxxxx");
Context ctx = new InitialContext();
ctx.bind("jdbc/test", ds);
It gives exactly the same error. Obviously I'm missing something
crucial here, but many hours of Googling have not turned up an answer
for me.
Could someone please point me in the right direction?
Thanks very much, Jonck