One - One Code All

Blog Content

java与postgresql链接示例

Java PostgreSQL   2020-04-11 20:55:58

java与postgresql连接示例,可以测试postgresql驱动加的对不对。

public static void postgre() {
    Connection c = null;
    try {
        Class.forName("org.postgresql.Driver");
        c = DriverManager
                .getConnection("jdbc:postgresql://localhost:5432/postgres",
                        "postgres", "post");
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println(e.getClass().getName()+": "+e.getMessage());
        System.exit(0);
    }
    System.out.println("Opened database successfully");


}



上一篇:docker安装并持久化postgresql数据库
下一篇:同一个sql语句中返回多个count,count(1),count(null)

The minute you think of giving up, think of the reason why you held on so long.