Getting the following error - No suitable driver found for jdbc:postgresql://localhost: 5432/testDBMS

前端 未结 4 1024
野趣味
野趣味 2021-01-29 13:07

I get back an error indicating java.sql.SQLException: No suitable driver found for
jdbc:postgresql://localhost: 5432/testDBMS

import java.sql.*;
impo         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-29 14:10

    java -cp . JdbcPostgresqlConnection
    

    So, clearly, the only thing that is in the classpath is the current directory (.). The postgresql driver jar is not. You need to add it to the classpath:

    java -cp .:/path/to/driver.jar JdbcPostgresqlConnection
    

    on Linux/MacOS, or

    java -cp .;c:\path\to\driver.jar JdbcPostgresqlConnection
    

    on Windows.

提交回复
热议问题