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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
PreparedStatement使用之JDBC存儲過程調(diào)用的代碼實例

PreparedStatement使用方法JDBC存儲過程調(diào)用的代碼實例是本文我們主要要介紹的內(nèi)容,接下來就讓我們一起來了解一下下面的代碼實例吧。

代碼實例如下:

 
 
 
  1. package datebase;  
  2.  
  3. import java.sql.*;     
  4.  
  5. public class mypreparedstatement {      
  6. private final String db_driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";      
  7. private final String url = "jdbc:sqlserver://localhost:1433;DatabaseName=ZC_NmSoft";      
  8. public mypreparedstatement()       
  9. {      
  10. }      
  11. public void query() throws SQLException{      
  12. Connection conn = this.getconnection();  
  13.  
  14. //*********************************************查詢********************  
  15. String strsql = "select * from ZC_Attendanceregister where AR_ID = ?";      
  16. PreparedStatement pstmtq = conn.prepareStatement(strsql);      
  17. pstmtq.setInt(1, 587);      
  18. ResultSet rs = pstmtq.executeQuery();      
  19. while(rs.next()){      
  20. String fname = rs.getString("AR_AdmissionID");  
  21. System.out.println("the fname is " + fname);      
  22. }  
  23.  
  24.  
  25. //************************************************刪除******************  
  26. String strsqld= "delete from ZC_Attendanceregister where AR_ID = ?";  
  27. PreparedStatement pstmtd = conn.prepareStatement(strsqld);  
  28. pstmtd.setInt(1, 587);  
  29. int dd = pstmtd.executeUpdate();  
  30.  
  31.  
  32. //***********************************************添加*******************  
  33. String strsqladd = "insert into ZC_Attendanceregister(AR_RegistrationDate,AR_AdmissionID,AR_Attendance,AR_Notes,AR_Mealssettlement) values(?,?,?,?,?)";  
  34. PreparedStatement pstmta = conn.prepareStatement(strsqladd);  
  35. pstmta.setString(1, "2010-07-26");  
  36. pstmta.setString(2, "260");  
  37. pstmta.setString(3, "出勤");  
  38. pstmta.setString(4, "備注");  
  39. pstmta.setString(5, "應(yīng)該繳費");  
  40.  
  41. int add = pstmta.executeUpdate();  
  42.  
  43. rs.close();      
  44. pstmta.close();      
  45. conn.close();      
  46. }  
  47.  
  48. private Connection getconnection() throws SQLException{      
  49. // class.      
  50. Connection conn = null;      
  51. try {      
  52.  Class.forName(db_driver);      
  53. conn = DriverManager.getConnection(url,"sa","sa");  
  54. }      
  55. catch (ClassNotFoundException ex) {}      
  56. return conn;      
  57. }  
  58. //main 測試      
  59. public static void main(String[] args) throws SQLException {      
  60.  mypreparedstatement jdbctest1 = new mypreparedstatement();      
  61.  jdbctest1.query();      
  62.  }  
  63. }    

以上就是PreparedStatement使用之JDBC存儲過程調(diào)用的代碼實例,本文我們就介紹到這里了,希望本次的介紹能夠?qū)δ兴斋@!

【編輯推薦】

  1. SQL Server數(shù)據(jù)庫多表關(guān)聯(lián)匯總查詢的問題解決
  2. 設(shè)置SQL Server數(shù)據(jù)庫AWE機制使其支持大內(nèi)存
  3. SQL Server 2008數(shù)據(jù)庫被標(biāo)記為可疑的解決方法
  4. SQL Server數(shù)據(jù)庫中FOR XML AUTO的使用詳解續(xù)
  5. SQL Server使用UNION代替OR提升查詢性能的實例

新聞標(biāo)題:PreparedStatement使用之JDBC存儲過程調(diào)用的代碼實例
文章分享:http://m.5511xx.com/article/djoihpc.html