*
The moose likes JDBC and the fly likes JDBC on postgres Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC on postgres" Watch "JDBC on postgres" New topic
Author

JDBC on postgres

Joe Williams
Greenhorn

Joined: Oct 18, 2005
Posts: 6
I'm not able to connect Postgres 8.0 & the same code with change in the driver & URL runs for SQL server.



javax.servlet.ServletException: Backend start-up failed: FATAL: database "TestPG" does not exist.
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.postgresql.util.PSQLException: Backend start-up failed: FATAL: database "TestPG" does not exist.
org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:443)
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:98)
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:117)
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
org.postgresql.Driver.connect(Driver.java:235)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
coreservlets.DBConnection.CreateConnection(DBConnection.java:25)
coreservlets.UserRegistrationAction.execute(UserRegistrationAction.java:34)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


This is my code for the DB connection.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41045
    
  43
Are you certain that the local server contains a database called "TestPG"?


Ping & DNS - my free Android networking tools app
Joe Williams
Greenhorn

Joined: Oct 18, 2005
Posts: 6
I gave the wrong DB,

Here is the code still giving another error



java.lang.ClassNotFoundException: org.postgresql.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at coreservlets.DBConnection.CreateConnection(DBConnection.java:24)
at coreservlets.UserRegistrationAction.execute(UserRegistrationAction.java:34)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)


Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Joe,
Now it looks like the driver isn't in the classpath. Can you show the classpath you are using?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Joe Williams
Greenhorn

Joined: Oct 18, 2005
Posts: 6
Thanks for your reply

Here is the classpath in my system variable


[added line breaks so page doesn't wrap right so much]
[ October 20, 2005: Message edited by: Jeanne Boyarsky ]
 
 
subject: JDBC on postgres
 
Similar Threads
getting error of sockets
problem in commiting the transaction
MS Access NullPointerException
no ocijdbc9 in java.library.path
Struts Configuration problem