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

后端 未结 3 1122
臣服心动
臣服心动 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条回答
  •  -上瘾入骨i
    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.

提交回复
热议问题