Guest User

Untitled

a guest
Jun 29th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. private String code;
  2. private String name;
  3.  
  4. private CallableStatement myCall = null;
  5. private Connection connection = null;
  6.  
  7. public DbConn() {
  8. try {
  9.  
  10. Class.forName("oracle.jdbc.driver.OracleDriver");
  11.  
  12. connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:dev", "root", "root");
  13. }catch(Exception e){
  14.  
  15. System.out.println("Exception is ;"+e);
  16.  
  17. }
  18. }
  19.  
  20. // ... Set and get methods
  21.  
  22.  
  23. public void insert(){
  24.  
  25. try {
  26. myCall = connection.prepareCall("{call temp_package.insert_temp(?, ?)}");
  27.  
  28. myCall.setString(1, code);
  29. myCall.setString(2, name);
  30. myCall.execute();
  31.  
  32. }catch(Exception e){
  33.  
  34. System.out.println("Exception is ;"+e);
  35.  
  36. } finally {
  37.  
  38. try { if (connection != null) connection.close(); } catch (Exception e) {};
  39. try { if (myCall != null) myCall.close(); } catch (Exception e) {};
  40.  
  41. }
  42.  
  43. }
  44.  
  45. <%@ page language="java" contentType="text/html; charset=UTF-8"
  46. pageEncoding="UTF-8"%>
  47. <jsp:useBean id = "beanme" class = "stored_procedure_call.DbConnTag" scope = "session" />
  48.  
  49.  
  50. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  51. <html>
  52. <head></head>
  53. <body>
  54.  
  55. <jsp:setProperty name = "beanme" property="code" value = "5" />
  56. <jsp:setProperty name = "beanme" property="name" value = "Jane" />
  57.  
  58.  
  59. <% beanme.insert(); %>
Add Comment
Please, Sign In to add comment