No suitable driver found for jdbc postgreSQL eclipse

Problem: Suppose you are creating an application using Java and for the backend you are using PostgreSQL, sometimes we face the error as below.
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/postgres
    at java.sql.DriverManager.getConnection(
    at java.sql.DriverManager.getConnection(
    at MyClass.main(
Answer: There may be many reasons to generates this error.
1- First, make sure you have installed the jdbc.
2- It may be incorrect classpath, please check classpath the Dependent Jars should not be included inside your own jar, they should be placed next to your own jar and then be specified in the Class-Path in the MANIFEST.MF.

Eg Your layout could be:


Then the MANIFEST.MF of your.jar should have an entry:

Class-Path: postgresql-9.3-1101.jdbc3.jar

Follow the link for more details:

3- JDBC 3 driver: The driver you are using is a JDBC 3 driver. Driver auto-loading was only introduced with JDBC 4 (Java 6). JDBC 4 autoloading works by drivers declaring what their driver class(es) are, presumably a JDBC 3 driver does not have that file. Your code has the Class.forName... commented out and the driver won't be loaded.

If you are using Java 6 or higher, upgrade to the JDBC 4 (Java 6) or JDBC 4.1 (Java 7) driver.

For the same types of the issue, there are some useful links are given below.

No comments:

Post a Comment

Please do not enter any spam link in the comment box.

Related Posts

What is the Use of isNaN Function in JavaScript? A Comprehensive Explanation for Effective Input Validation

In the world of JavaScript, input validation is a critical aspect of ensuring that user-provided data is processed correctly. One indispensa...