Results 1 to 5 of 5
  1. #1
    techsing14 is offline Member
    Join Date
    Oct 2010
    Posts
    24
    Rep Power
    0

    Default Problem in inserting values into Oracle DB

    Hi

    I am trying to insert values into DB, am not getting anythg in my page..this is my code

    AddServlet.java
    Java Code:
    package AddNewTransaction;
    
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    
    
    public class AddServlet extends HttpServlet {
       
       public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            out.println("<title>Add New Transaction</title>" + "<h1 align=\"center\"></h1>" + "<body bgcolor=#FFFFCC>");
                    out.println("<center><td  width=\"37\"> <strong><img title=\"Go back\" src=\"Undo.gif\" width=\"20\" height=\"20\" onClick=\"javascript:history.back()\" style=\"vertical-align:middle;\" onMouseOver=\"this.style.cursor='hand';\"></strong></td></center><br>");
            System.out.println("Oracle 10g Connect Example.");
            String ID = request.getParameter("ID");
            String PartNo = request.getParameter("PartNo");
            String SerialNo = request.getParameter("SerialNo");
           String Material_Number = request.getParameter("Material_Number");
           String Material_desc = request.getParameter("Material_desc");
           String ProjectNo = request.getParameter("ProjectNo");
           String Order_Qty = request.getParameter("Order_Qty");
           String Date_of_Order = request.getParameter("Date_of_Order");
           String Date_of_Issue = request.getParameter("Date_of_Issue");
           String Inventory_Qty = request.getParameter("Inventory_Qty");
           String Inventory_ID = request.getParameter("Inventory_ID");
           String Inventory_Status = request.getParameter("Inventory_Status");
           String Vendor = request.getParameter("Vendor");
           String Location = request.getParameter("Location");
           String Transaction_Status = request.getParameter("Transaction_Status");
           String Remarks = request.getParameter("Remarks");
           String Default_Qty = request.getParameter("Default_Qty");
            Connection conn = null;
            String url = "jdbc:oracle:thin:@localhost:1521:demo";
            String driver = "oracle.jdbc.driver.OracleDriver";
            String user = "root";
            String pass = "root";
            PreparedStatement pstatement = null;
            int updateQuery = 0;
    if(ID!=null && PartNo!=null && SerialNo!=null && Material_Number!=null && Material_desc!=null && ProjectNo!=null && Order_Qty!=null && Date_of_Order!=null && Date_of_Issue!=null && Inventory_Qty!=null && Inventory_ID!=null && Inventory_Status!=null && Vendor!=null && Location!=null && Transaction_Status!=null && Remarks!=null && Default_Qty!=null){
        if(ID!="" && PartNo!="" && SerialNo!="" && Material_Number!="" && Material_desc!="" && ProjectNo!="" && Order_Qty!="" && Date_of_Order!="" && Date_of_Issue!="" && Inventory_Qty!="" && Inventory_ID!="" && Inventory_Status!="" && Vendor!="" && Location!="" && Transaction_Status!="" && Remarks!="" && Default_Qty!="") {
                     try {
                          Class.forName(driver).newInstance();
                          conn = DriverManager.getConnection(url, user, pass);
    String queryString = "INSERT INTO batchfile(ID,PartNo,SerialNo,Material_Number,Material_desc,ProjectNo,Order_Qty,Date_of_Order,Date_of_Issue,Inventory_Qty,Inventory_ID,Inventory_Status,Vendor,Location,Transaction_Status,Remarks,Default_Qty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
    
                              pstatement = conn.prepareStatement(queryString);
                              pstatement.setString(1, ID);
                              pstatement.setString(2, PartNo);
                              pstatement.setString(3, SerialNo);
    			  pstatement.setString(4, Material_Number);
    			  pstatement.setString(5, Material_desc);
                              pstatement.setString(6, ProjectNo);
                              pstatement.setString(7, Order_Qty);
                              pstatement.setString(8, Date_of_Order);
                              pstatement.setString(9, Date_of_Issue);
                              pstatement.setString(10, Inventory_Qty);
                              pstatement.setString(11, Inventory_ID);
                              pstatement.setString(12, Inventory_Status);
                              pstatement.setString(13, Vendor);
                              pstatement.setString(14, Location);
                              pstatement.setString(15, Transaction_Status);
                              pstatement.setString(16, Remarks);
                              pstatement.setString(17, Default_Qty);
                int i = pstatement.executeUpdate();
                  if (i != 0) {
                      out.print("<br>");
                       out.print("<table  align=\"center\" font=\"18\" style=\"background-color:#CC9933\"width=\"50%\" border=\"1\">");
                       out.print("<tr><th>Data Inserted Successfully</th></tr>");
                       out.print("</table>");
                  }
                  
                    pstatement.close();
                    System.out.println("Disconnected from database");
                 }
                    catch (Exception ex) {
                out.println("Unable to connect to database.");
    
                }
                     finally {
    // Always close the database connection.
    try {
    if (conn != null)
        conn.close();
    }
    catch (SQLException ignored){
    out.println(ignored);
    }
    
                 }
           }
        }
    }
    }
    I dont knw wat's wrong with this code...please can anyone help me out. I am not getting anythg except back icon...please help me

  2. #2
    only_java is offline Member
    Join Date
    Mar 2011
    Posts
    16
    Rep Power
    0

    Post ive me that exception stack trace

    Hi techsing14,

    You must be getting exception, that's why you are getting only back button.
    Can you give me that exception stack trace.

  3. #3
    techsing14 is offline Member
    Join Date
    Oct 2010
    Posts
    24
    Rep Power
    0

    Default

    Java Code:
    2011-04-01T09:50:28.471+0800|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=31;_ThreadName=Thread-1;|Oracle 10g Connect Example.|#]
    
    [#|2011-04-01T09:53:32.624+0800|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_ThreadID=20;_ThreadName=Thread-1;|WEB9053: Invalid URLClassLoader path component: [/C:/Documents and Settings/Administrator/My Documents/NetBeansProjects/InvenApplication/build/web/WEB-INF/lib/classes12.zip] is neither a JAR file nor a directory|#]
    
    [#|2011-04-01T09:53:33.296+0800|INFO|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=20;_ThreadName=Thread-1;|Loading application InvenApplication at /InvenApplication|#]
    
    [#|2011-04-01T09:53:33.296+0800|INFO|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=20;_ThreadName=http-thread-pool-4848-(2);|Loading application InvenApplication at /InvenApplication|#]
    
    [#|2011-04-01T09:53:33.296+0800|INFO|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=20;_ThreadName=http-thread-pool-4848-(2);|Loading application InvenApplication at /InvenApplication|#]
    
    [#|2011-04-01T09:53:33.624+0800|INFO|glassfish3.0.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=20;_ThreadName=Thread-1;|InvenApplication was successfully deployed in 9,218 milliseconds.|#]
    
    [#|2011-04-01T09:53:45.546+0800|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=30;_ThreadName=Thread-1;|Oracle 10g Connect Example.|#]
    This is the thing am getting in my glassfish logs, Please help me out.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,997
    Rep Power
    19

    Default

    It appears not to be able to find the classes12.zip file.

    However, that's so out of date now, and you're using Oracle 10g (according to the trace) so you should be using (and you ought to check this on the Oracle site) odbc14.jar.

  5. #5
    techsing14 is offline Member
    Join Date
    Oct 2010
    Posts
    24
    Rep Power
    0

Similar Threads

  1. Problem in retrieving values from Oracle 10g database
    By techsing14 in forum JavaServer Pages (JSP) and JSTL
    Replies: 9
    Last Post: 04-13-2011, 01:50 AM
  2. inserting values in to array
    By Dayanand in forum New To Java
    Replies: 8
    Last Post: 03-05-2011, 04:23 PM
  3. inserting date in oracle database
    By jackjosh_in in forum Advanced Java
    Replies: 6
    Last Post: 05-23-2010, 06:38 PM
  4. Replies: 2
    Last Post: 04-01-2010, 04:35 AM
  5. Replies: 0
    Last Post: 12-24-2007, 09:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •