- This topic has 2 replies, 2 voices, and was last updated 18 years, 1 month ago by Greg.
-
AuthorPosts
-
augustfoxMemberMy environment is myeclipse4.1.1+jboss4.0.1sp1+DB28.2.
When I wanna get a database connection,i meet with a problem,the error as follows:
14:38:06,343 INFO [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: jdbc not bound]
14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:999)
14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:658)
14:38:06,343 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:520)
14:38:06,343 INFO [STDOUT] at javax.naming.InitialContext.lookup(InitialContext.java:347)My code like this:
Context context = new InitialContext();
return (DataSource) context.lookup(“java:comp/env/jdbc/test”);I can get connecton via context.lookup(“java:jdbc/test”),
but i still want to know why context.lookup(“java:comp/env/jdbc/test”) not works?
I want to get your help eagerly!my db2-ds.xml:
<local-tx-datasource>
<jndi-name>jdbc/test</jndi-name>
<connection-url>jdbc:db2:tempdb</connection-url>
<driver-class>COM.ibm.db2.jdbc.app.DB2Driver</driver-class>
<user-name>test</user-name>
<password>test</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size><metadata>
<type-mapping>DB2</type-mapping>
</metadata>
</local-tx-datasource>my web.xml:
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>my jboss-web.xml:
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<jndi-name>jdbc/test</jndi-name>
</resource-ref>I also tried resource-env-ref in my web.xml and jboss-web.xml,it still not works.
augustfoxMemberThe problem has solved as follows:
change jboss-web.xml:
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<jndi-name>java:jdbc/test</jndi-name>
</resource-ref>
GregMemberGlad you got it working.
-
AuthorPosts