java中连接postgresql基本代码

try 
         {
           Class.forName( "org.postgresql.Driver" ).newInstance();
           String url = "jdbc:postgresql://localhost:5432/postgres" ;
           Connection con = DriverManager.getConnection(url, "postgres" , "123" );
           Statement st = con.createStatement();
          return st;
       } 
        catch (Exception ee)
        {
           System.out.print(ee.getMessage());
           return null; 
       }

 

转载于:https://www.cnblogs.com/RenameWang/p/3771140.html

你可能感兴趣的:(java中连接postgresql基本代码)