No Suitable Driver found Postgres JDBC

前端 未结 1 642
忘掉有多难
忘掉有多难 2021-01-18 14:46

I am receiving a \"no suitable driver found\" error when I test my web service on tomcat. I have the JDBC .jar in the lib folder as various tutorials says to do. Here is my

相关标签:
1条回答
  • 2021-01-18 14:50

    The proper Driver name is: org.postgresql.Driver and not org.postgres.Driver

    Update:

    Check this page give it a bit os study and you should be fine :) http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

    Than instead of using DriverManager, you should just do a lookup(you did already) and than get a connection from the DataSource(You can remove pwd, user, and other unused stuff from your code):

    Context initContext = new InitialContext();
    Context envContext  = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/UptonDB");
    Connection conn = ds.getConnection();
    
    0 讨论(0)
提交回复
热议问题