Java技巧:Java串連資料庫技巧全攻略(1)

來源:互聯網
上載者:User

編者在本文將主要為大家介紹Java與Oracle、DB2、Sql Server、Sybase、MySQL、PostgreSQL等資料庫連接的方法。

1、Oracle資料庫

 
  1. Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
  2.  
  3. String url="jdbc:oracle:thin:@localhost:1521:orcl";  
  4.  
  5. //orcl為資料庫的SID  
  6.  
  7. String user="test";  
  8.  
  9. String password="test";  
  10.  
  11. Connection conn= DriverManager.getConnection(url,user,password);  
  12.  


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.