各種資料庫JDBC參數配置

來源:互聯網
上載者:User
  1. MySQL:      
  2.     String Driver="com.mysql.jdbc.Driver"
    ;    
    //驅動程式
      
  3.     String URL="jdbc:mysql://localhost:3306/db_name"
    ;    //串連的URL,db_name為資料庫名      
  4.     String Username="username"
    ;    
    //使用者名稱
      
  5.     String Password="password"
    ;    
    //密碼
      
  6.     Class.forName(Driver).new
     Instance();  
  7.     Connection con=DriverManager.getConnection(URL,Username,Password);  
  8. Microsoft SQL Server 2.0
    驅動(
    3
    個jar的那個):  
  9.     String Driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
    ;    
    //串連SQL資料庫的方法
      
  10.     String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"
    ;    //db_name為資料庫名  
  11.     String Username="username"
    ;    
    //使用者名稱
      
  12.     String Password="password"
    ;    
    //密碼
      
  13.     Class.forName(Driver).new
     Instance();    
    //載入資料可驅動
      
  14.     Connection con=DriverManager.getConnection(URL,UserName,Password);    //
      
  15. Microsoft SQL Server 3.0
    驅動(
    1
    個jar的那個): 
    // 老紫竹完善
      
  16.     String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    ;    
    //串連SQL資料庫的方法
      
  17.     String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"
    ;    //db_name為資料庫名  
  18.     String Username="username"
    ;    
    //使用者名稱
      
  19.     String Password="password"
    ;    
    //密碼
      
  20.     Class.forName(Driver).new
     Instance();    
    //載入資料可驅動
      
  21.     Connection con=DriverManager.getConnection(URL,UserName,Password);    //
      
  22. Sysbase:  
  23.     String Driver="com.sybase.jdbc.SybDriver"
    ;    
    //驅動程式
      
  24.     String URL="jdbc:Sysbase://localhost:5007/db_name"
    ;    //db_name為資料可名  
  25.     String Username="username"
    ;    
    //使用者名稱
      
  26.     String Password="password"
    ;    
    //密碼
      
  27.     Class.forName(Driver).newInstance();      
  28.     Connection con=DriverManager.getConnection(URL,Username,Password);  
  29. Oracle(用thin模式):  
  30.     String Driver="oracle.jdbc.driver.OracleDriver"
    ;    
    //串連資料庫的方法
      
  31.     String URL="jdbc:oracle:thin:@loaclhost:1521:orcl"
    ;    
    //orcl為資料庫的SID
      
  32.     String Username="username"
    ;    
    //使用者名稱
      
  33.     String Password="password"
    ;    
    //密碼
      
  34.     Class.forName(Driver).newInstance();    //載入資料庫驅動
      
  35.     Connection con=DriverManager.getConnection(URL,Username,Password);      
  36. PostgreSQL:  
  37.     String Driver="org.postgresql.Driver"
    ;    
    //串連資料庫的方法
      
  38.     String URL="jdbc:postgresql://localhost/db_name"
    ;    //db_name為資料可名  
  39.     String Username="username"
    ;    
    //使用者名稱
      
  40.     String Password="password"
    ;    
    //密碼
      
  41.     Class.forName(Driver).newInstance();      
  42.     Connection con=DriverManager.getConnection(URL,Username,Password);  
  43. DB2:  
  44.     String Driver="com.ibm.db2.jdbc.app.DB2.Driver"
    ;    
    //串連具有DB2用戶端的Provider執行個體
      
  45.     //String Driver="com.ibm.db2.jdbc.net.DB2.Driver";    //串連不具有DB2用戶端的Provider執行個體
      
  46.     String URL="jdbc:db2://localhost:5000/db_name"
    ;    //db_name為資料可名  
  47.     String Username="username"
    ;    
    //使用者名稱
      
  48.     String Password="password"
    ;    
    //密碼
      
  49.     Class.forName(Driver).newInstance();      
  50.     Connection con=DriverManager.getConnection(URL,Username,Password);  
  51. Informix:  
  52.     String Driver="com.informix.jdbc.IfxDriver"
    ;      
  53.     String URL="jdbc:Informix-sqli://localhost:1533/db_name:INFORMIXSER=myserver"
    ;    //db_name為資料可名  
  54.     String Username="username"
    ;    
    //使用者名稱
      
  55.     String Password="password"
    ;    
    //密碼
      
  56.     Class.forName(Driver).newInstance();      
  57.     Connection con=DriverManager.getConnection(URL,Username,Password);  
  58. JDBC-ODBC:  
  59.     String Driver="sun.jdbc.odbc.JdbcOdbcDriver"
    ;  
  60.     String URL="jdbc:odbc:dbsource"
    ;    
    //dbsource為資料來源名
      
  61.     String Username="username"
    ;    
    //使用者名稱
      
  62.     String Password="password"
    ;    
    //密碼
      
  63.     Class.forName(Driver).newInstance();      
  64.     Connection con=DriverManager.getConnection(URL,Username,Password); 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.