日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
淺談如何利用Java的JDBC操作Oracle數(shù)據(jù)庫

參考 http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html Java JDBC中操作Oracle數(shù)據(jù)庫,經(jīng)過以下幾個(gè)步驟,

1.將OracleHome/jdbc/lib/目錄的所有文件添加到j(luò)re/lib/ext目錄;(配置Java JDBC驅(qū)動(dòng))

2.創(chuàng)建odbc源,在控制面板=》管理工具=》數(shù)據(jù)源(odbc)中添加DSN,比如取名為OracleDSN,選擇一個(gè)Service,輸入用戶名密碼,測試連接,若通過說明成功;

3.在程序中加載jdbc驅(qū)動(dòng)(下面的例子用的是JdbcOdbc驅(qū)動(dòng)),建立連接,執(zhí)行Query.

下面是連接OracleDSN ODBC data source的一個(gè)類,方法Test()連接數(shù)據(jù)庫后,讀取tbljob的內(nèi)容,并顯示所有記錄。

 
 
 
  1. import java.sql.*;  
  2. class OracleConnect {  
  3. public static void Test() { //connection by JdbcOdbcDriver  
  4.  try {  
  5.  //load the driver:  
  6.  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  
  7.  //connect the Database,OracleDSN is the ODBC data source ;  
  8.  String url = "jdbc:odbc:OracleDSN";  
  9.  Connection conn = DriverManager.getConnection(url, "system",  
  10.  "system_passwd");  
  11.  // Create a Statement  
  12.  Statement stmt = conn.createStatement();  
  13.  // Select first_name and last_name column from the employees table  
  14.  ResultSet rset = stmt.executeQuery("select * from tbljob;");  
  15.  // Iterate through the result and print the employee names  
  16.  while (rset.next())  
  17.  System.out.println(rset.getString(1) + " " + rset.getString(2));  
  18.  // Close the RseultSet2  
  19.  rset.close();  
  20.  // Close the Statement  
  21.  stmt.close();  
  22.  // Close the connection  
  23.  conn.close();  
  24.  } catch (Exception e) {  
  25.  // TODO Auto-generated catch block  
  26.  e.printStackTrace();  
  27.  }  
  28. }  

【責(zé)任編輯:彭凡 TEL:(010)68476606】


文章題目:淺談如何利用Java的JDBC操作Oracle數(shù)據(jù)庫
瀏覽路徑:http://m.5511xx.com/article/copesoi.html