From: | Guy Rouillier <guyr-ml1(at)burntmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Cannot create JDBC driver of class '' for connect URL 'null' |
Date: | 2009-03-02 23:53:23 |
Message-ID: | 49AC7173.606@burntmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Stanley Wong wrote:
> Hi,
>
> I encounter a problem regarding setting up a JNDI Datasource at Tomcat
> with PostgreSQL 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'
Using your sample works for me with the changes indicated below.
>
> 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">
Take out path and docBase. Since you are defining a context, Tomcat
knows those.
> 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");
You are missing a decimal point between initCtx and lookup.
Where are you running this code? I created a sample JSP page dbtest.jsp
and placed it in the root directory of the context. I called my context
text, so under that I had dbtest.jsp, META-INF and WEB-INF. Since you
are creating the datasource within the context, only Java code running
within the context has access to it.
--
Guy Rouillier
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2009-03-03 00:02:51 | Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ? |
Previous Message | Hannu Krosing | 2009-03-02 22:17:28 | Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ? |