Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String code;
- private String name;
- private CallableStatement myCall = null;
- private Connection connection = null;
- public DbConn() {
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:dev", "root", "root");
- }catch(Exception e){
- System.out.println("Exception is ;"+e);
- }
- }
- // ... Set and get methods
- public void insert(){
- try {
- myCall = connection.prepareCall("{call temp_package.insert_temp(?, ?)}");
- myCall.setString(1, code);
- myCall.setString(2, name);
- myCall.execute();
- }catch(Exception e){
- System.out.println("Exception is ;"+e);
- } finally {
- try { if (connection != null) connection.close(); } catch (Exception e) {};
- try { if (myCall != null) myCall.close(); } catch (Exception e) {};
- }
- }
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <jsp:useBean id = "beanme" class = "stored_procedure_call.DbConnTag" scope = "session" />
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head></head>
- <body>
- <jsp:setProperty name = "beanme" property="code" value = "5" />
- <jsp:setProperty name = "beanme" property="name" value = "Jane" />
- <% beanme.insert(); %>
Add Comment
Please, Sign In to add comment