Lists: | pgsql-jdbc |
---|
From: | jamesohara <johara(at)energyts(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | JNDI Tomcat and PostgreSQL Error |
Date: | 2008-12-10 22:16:30 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Hi,
I am getting the following error: java.lang.RuntimeException: Cannot load
JDBC driver class 'org.postgresql.Driver'
when trying to connect to a postgreSQL database using JNDI with Tomcat. My
configuration file and code is below.
try {
InitialContext context = new InitialContext();
Context envContext = (Context)context.lookup("java:/comp/env");
DataSource dataSource = (DataSource)envContext.lookup("jdbc/eb");
thisConnection = dataSource.getConnection();
//Register it, as we now have a connection
request.setAttribute(ServletUtils.STATEMENT_ATTRIBUTE_NAME, this);
statement = thisConnection.createStatement();
} catch (Exception e)
XML:
<Context path="/eBench8" docBase="C:\Documents and
Settings\johara.ETS.000\workspace\eB\eB" debug="1" reloadable="true">
<Resource name="jdbc/eb" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost/eb"
username="user" password="pass" maxActive="40" maxIdle="10" maxWait="1000"
accessToUnderlyingConnectionAllowed="true" />
</Context>
Does anyone know why I could be getting this error. As far as I know
everything is in its right place. ANy help would be appreciated.
Thanks,
James
--
View this message in context: http://www.nabble.com/JNDI-Tomcat-and-PostgreSQL-Error-tp20945255p20945255.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
From: | Lucas <lucas75(at)gmail(dot)com> |
---|---|
To: | jamesohara <johara(at)energyts(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: JNDI Tomcat and PostgreSQL Error |
Date: | 2008-12-16 10:24:31 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Basically
The .jar from postgresql is not loaded.
Put it inside the tomcat lib dir (not the WEB-INF/lib).
jamesohara escreveu:
> Hi,
>
> I am getting the following error: java.lang.RuntimeException: Cannot load
> JDBC driver class 'org.postgresql.Driver'
>
> when trying to connect to a postgreSQL database using JNDI with Tomcat. My
> configuration file and code is below.
>
> try {
>
> InitialContext context = new InitialContext();
> Context envContext = (Context)context.lookup("java:/comp/env");
> DataSource dataSource = (DataSource)envContext.lookup("jdbc/eb");
> thisConnection = dataSource.getConnection();
>
> //Register it, as we now have a connection
> request.setAttribute(ServletUtils.STATEMENT_ATTRIBUTE_NAME, this);
> statement = thisConnection.createStatement();
> } catch (Exception e)
>
> XML:
>
> <Context path="/eBench8" docBase="C:\Documents and
> Settings\johara.ETS.000\workspace\eB\eB" debug="1" reloadable="true">
> <Resource name="jdbc/eb" auth="Container" type="javax.sql.DataSource"
> driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost/eb"
> username="user" password="pass" maxActive="40" maxIdle="10" maxWait="1000"
> accessToUnderlyingConnectionAllowed="true" />
> </Context>
>
> Does anyone know why I could be getting this error. As far as I know
> everything is in its right place. ANy help would be appreciated.
>
> Thanks,
> James
>