Home java No suitable driver found for jdbc: postgresql: //

No suitable driver found for jdbc: postgresql: //




According to the response @Barmaley, given the issue of driver Installation for postgresql on linux , I created Sample.jar the same file Sample.java , illustrated in the above page, with manifest file

Manifest-Version: 1.0
Created-By: 1.7.0_06 (Oracle Corporation)
Main-Class: Sample
Class-Path: /folder/postgresql-8.4-703.jdbc3.jar

and the file /folder/postgresql-8.4-703.jdbc3.jar and has started using the jar c


./ java -jar -Djava.library.path = / opt / jdk1.7.0_06 / lib / Samplejavaprogram / Sample. jar

and as a result received the following message

Connection Failed! Check output console
java.sql.SQLException: No suitable driver found for jdbc: postgresql: // 5432 / NexentaSearch
  at java.sql.DriverManager.getConnection (DriverManager.java:604)
  at java.sql.DriverManager.getConnection (DriverManager.java:221)
  at org.myorg.Sample.main (Sample.java:33)

I ran the file from the host with the address , but the host it worked fine.

(I changed the program by removing the first 2 lines:

package org.myorg;


Help to correct the error.

Answer 1, Authority 100%

It looks like the problem is that you do not load the JDBC driver.

See instructions on loading the JDBC driver. The magic is in class.forName ()

p.s. Download Statement Intellij IDEA Community Edition and work in it – life becomes a lot easier

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions