Configuring jdbc-pool (tomcat 7)

Posted by john on Server Fault See other posts from Server Fault or by john
Published on 2011-01-20T16:19:09Z Indexed on 2012/09/25 3:40 UTC
Read the original article Hit count: 489

Filed under:
|

i'm having some problems with tomcat 7 for configuring jdbc-pool : i`ve tried to follow this example: http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency

so i have:

conf/server.xml

 <GlobalNamingResources>
  <Resource type="javax.sql.DataSource"
            name="jdbc/DB"
            factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/mydb"
            username="user"
            password="password"
/>
 </GlobalNamingResources>

conf/context.xml

<Context>
  <ResourceLink type="javax.sql.DataSource"
                name="jdbc/LocalDB"
                global="jdbc/DB"
/>
 <Context>

and when i try to do this:

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource datasource = (DataSource)envContext.lookup("jdbc/LocalDB");
Connection con = datasource.getConnection();

i keep getting this error:

javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
 at org.apache.naming.NamingContext.lookup(NamingContext.java:803)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:159)

pls help tnx

© Server Fault or respective owner

Related posts about tomcat

Related posts about jdbc