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; 
       }

 

posted @ 2014-06-05 21:06  功夫小子1917  阅读(342)  评论(0编辑  收藏  举报