Results 1 to 1 of 1
  1. #1
    s3ib is offline Member
    Join Date
    Dec 2010
    Rep Power

    Default [SOLVED] PostgreSQL, Eclipse, Tomcat problem

    I have a problem connecting to my postgres database from a servlet.
    I added PostgreSql to my databases in eclipse and it is connected. I made a new Dynamic web project, created a servlet in there and in doGet method i wrote:

    Java Code:
    PrintWriter out = response.getWriter();
    } catch (ClassNotFoundException cnfe){       
    	out.println("Could not find the JDBC driver!");          
    Connection conn = null; 
    try {     
    	conn = DriverManager.getConnection("jdbc:postgresql:mydb", "myUsername", "myPassword");
    			out.println("It works!");
    } catch (SQLException sqle) {       
    			out.println("Could not connect");
    On my bowser it writes: Could not find the JDBC driver.
    I added the driver as an external jar to my project from eclipse and when i look at my project then under referenced libraries there it is but still no use.

    When I make a usual Java project and make a usual main class there, and use the same code except ja substitute the out.println with System.out.println then it works well and no exceptions are thrown and the it writes "It works" on console.
    I really cant understand where I'm going wrong :/. Help would really be appreciated.

    When I manually copyed the driver in my WEB-INF/lib folder it started to work fine. No more help needed :)
    Last edited by s3ib; 04-26-2011 at 11:00 PM. Reason: SOLVED

Similar Threads

  1. Problem inserting String into postgresql.
    By ciglesias in forum JDBC
    Replies: 6
    Last Post: 04-13-2011, 07:09 PM
  2. Problem publishing in Tomcat using eclipse
    By bodepudi in forum Eclipse
    Replies: 2
    Last Post: 01-23-2011, 09:57 PM
  3. Problem in eclipse with tomcat
    By amitabh in forum Eclipse
    Replies: 0
    Last Post: 04-01-2010, 08:36 AM
  4. Tomcat with eclipse problem
    By mos33 in forum Eclipse
    Replies: 4
    Last Post: 12-30-2009, 07:44 PM
  5. Tomcat In Eclipse - Sysdeo Tomcat Plug-in
    By JavaForums in forum Eclipse
    Replies: 1
    Last Post: 02-13-2008, 11:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts