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");


}



上一篇:maven 中添加postgresql依赖,阿里云镜像,add as library
下一篇:Davinci配置postgresql数据源

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