Thank you. I can tell this is an error related to Tomcat/JNDI set-up, as I can make a JDBC connection, as the codes state below.
Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql:testdb"; Properties props = new Properties(); props.setProperty("user","username"); props.setProperty("password","password"); conn = DriverManager.getConnection(url, props); I change the following url setting url="jdbc:postgresql://127.0.0.1:5432/testdb" to url="jdbc:postgresql:testdb" and I have the same error. I remove the META-INF/context.xml, and modify the <Host> node of tge server.xml as shown below: <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/someApp" docBase="someApp" debug="0" reloadable="true"> <Resource name="jdbc/postgres" type="javax.sql.DataSource" password="linux4draco" driverClassName="org.postgresql.Driver" maxIdle="2" maxWait="5000" validationQuery="SELECT 1" username="gepguser" url="jdbc:postgresql://localhost/testdb" maxActive="4"/> </Context> </Host> And, I have the same error. What else could I try? Stanley -----Original Message----- From: David Smith [mailto:d...@cornell.edu] Sent: Tuesday, March 03, 2009 12:44 PM To: Tomcat Users List Subject: Re: FW: Cannot create JDBC driver of class '' for connect URL 'null' Stanley Wong wrote: > Hi, > > I encounter a problem regarding setting up a JNDI Datasource at Tomcat > 6.0 with PostgreSQL 8.1 under Linux Suse 10.3 environment. This is the > exception: > > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC > driver of class '' for connect URL 'null' > > I wonder if there are some additional settings that I may have > forgotten. > > Would you give me a hand here? > > Stanley > > > > Here is what I do: > > 0) Ensure the postgreSQL.jar is stored inside the tomcat/lib > > 1) Create a context.xml in the META-INF. The context.xml defines the > context below: > > <?xml version="1.0" encoding="UTF-8"?> > <Context path="/someApp" docBase="someApp" > crossContext="true" reloadable="true" debug="1"> > > <Resource name="jdbc/postgres" auth="Container" > type="javax.sql.DataSource" > driverClassName="org.postgresql.Driver" > url="jdbc:postgresql://127.0.0.1:5432/testdb" > username="gepguser" password="password" maxActive="20" > maxIdle="10" > maxWait="-1"/> > </Context> > > Where testdb is the database inside PostgreSQL. > > 2) Add the following entry in web.xml: > > <resource-ref> > <description>postgreSQL Datasource example</description> > <res-ref-name>jdbc/postgres</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > 3) Use the following code to get the connection: > > public Connection getConnection() { > Connection conn = null; > Context initCtx; > try { > initCtx = new InitialContext(); > DataSource ds = (DataSource) initCtx > > .lookup("java:comp/env/jdbc/postgres"); > > conn = ds.getConnection(); > } catch (NamingException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (SQLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > return conn; > } > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > We just had a thread regarding this. Can you describe what you have done so far to diagnose it? --David --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org