webtier@glassfish.java.net

Re: Unable to get JDBC connection

From: <webtier_at_javadesktop.org>
Date: Wed, 01 Oct 2008 09:02:05 PDT

hi

have you try the jndi name in ordeer to connect
java:comp/env/jdbc/bang/readOnly

also my code in order to obtain a connection is :

Context initCtx,envCtx;
DataSource ds = null;
try {
        initCtx = new InitialContext();
        envCtx = (Context) initCtx.lookup("java:comp/env");
        // Look up our data source
        ds = (DataSource) envCtx.lookup("jdbc/Ora_mensajes");
 } catch (NamingException e)
{
        e.printStackTrace();
}

i used tomcat 6.0.18 , oracle jdbc 10g

---- web.xml----
<resource-ref>
  <res-ref-name>jdbc/Ora_mensajes</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
 </resource-ref>

---context.xml----
<Resource driverClassName="oracle.jdbc.OracleDriver" maxActive="20"
   maxIdle="6" maxWait="5000" name="jdbc/Ora_mensajes" password=*********
   type="javax.sql.DataSource"
   url="jdbc:oracle:thin:@esbasint002.lan.eds.es:1521:EXPLODES"
   username="manuales" />

i hope it helps
[Message sent by forum member 'xsi' (xsi)]

http://forums.java.net/jive/thread.jspa?messageID=302753