Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.myapp.struts;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- /**
- *
- * @author 1337
- */
- public class ProductDAO {
- public void insertData(String orderNumber, String customerID ,
- String quantity, String shippingCost, String salesDate, String shippingDate) throws Exception {
- System.out.println("jdbc connection");
- Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
- Connection con = DriverManager.getConnection(
- "jdbc:derby://localhost:1527/myDatabase;user=mis320;password=mis320");
- try {
- try {
- Statement st = con.createStatement();
- int value = st
- .executeUpdate("INSERT INTO PRODUCT (Order_Num,Customer_ID,Quantity,Shipping_cost,Sales_date,Shipping_date) VALUES('"
- + orderNumber
- + "','"
- + customerID
- + "','"
- + quantity
- + "','"
- + shippingCost + "','" + salesDate + "','"+ shippingDate + "')");
- System.out.println("1 row affected" + value);
- } catch (SQLException ex) {
- System.out.println("SQL statement is not executed!" + ex);
- }
- con.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement