No suitable driver found for jdbc:postgresql://192.168.1.8:5432/NexentaSearch

后端 未结 3 967
臣服心动
臣服心动 2020-12-17 17:08

I wrote following the java program

import java.io.*;
import java.util.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet         


        
相关标签:
3条回答
  • 2020-12-17 17:27

    Just use the jar command to extract the files your application needs to make the connection with the database server. e.g. jar -xf jdbc_file. Compile it with the javac -cp . and run it with the java -cp .

    And that's it. It will work.

    0 讨论(0)
  • 2020-12-17 17:31

    You are using a JDBC 3 driver. JDBC 4 drivers are loaded automatically loaded by the DriverManager whereas JDBC 3 drivers are not. Therefore you need to invoke

    Class.forName("org.postgresql.Driver");
    

    once in your application, (prior to invoking DriverManager#getConnection).


    Alternatively, you can use the JDBC 4 PostgreSQL driver from here which will not require the above method call.

    0 讨论(0)
  • 2020-12-17 17:42

    Use DriverManager.registerDriver(new org.postgresql.Driver());

    0 讨论(0)
提交回复
热议问题