Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    3

    Unanswered: java.sql.SQLException: ORA-00904: invalid column name.

    Hi
    I have IBM Visualage for java for windows version 4.0,web sphere 4.0 and database Oracle 8.1.7.I want to insert one record into database using servlet.My main logic related to database connection,prepared statement,result set in this servlet,

    pStmt = conn.prepareStatement
    ("INSERT INTO EMPLOYEE(ENO,ENMAE,SALARY,JOINDATE,ADDRESS,PHONE,D EPTNO) VALUES(?,?,?,?,?,?,?)");
    pStmt.setInt(1,eno);
    pStmt.setString(2,ename);
    pStmt.setFloat(3,sal);
    pStmt.setString(4,date);
    pStmt.setString(5,add);
    pStmt.setLong(6,ph);
    pStmt.setInt(7,dept);
    rs = pStmt.executeQuery();

    ResultSet rs = pStmt.executeQuery(); is giving the following error:java.sql.SQLException: ORA-00904: invalid column name.

    kindly, let me know how to correct this error. expecting your immediate reply.

    Regards,
    Rajendra
    mgr_raj9@yahoo.com

  2. #2
    Join Date
    May 2002
    Posts
    3
    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement pStmt = null;
    javax.sql.DataSource ds = null;

    int eno =Integer.parseInt( request.getParameter("eno"));
    String ename =request.getParameter("ename");
    float sal = Float.parseFloat(request.getParameter("sal"));
    //java.sql.Date date = (java.sql.Date)request.getParameter("date");
    String date = request.getParameter("date");
    String add = request.getParameter("add");
    long ph = Long.parseLong(request.getParameter("ph"));
    int dept = Integer.parseInt(request.getParameter("dept"));

    try
    {
    java.util.Hashtable env = new java.util.Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.ibm.ejs.ns.jndi.CNInitialContextFactory") ;

    Context ctx = new InitialContext(env);
    ds = (DataSource)ctx.lookup("jdbc/myData");
    ctx.close();

    conn = ds.getConnection("userid", "password");
    pStmt = conn.prepareStatement
    ("INSERT INTO NARSIMHA.EMPLOYEE(ENO,ENMAE,SALARY,JOINDATE,ADDRES S,PHONE,DEPTNO) VALUES(?,?,?,?,?,?,?)");
    pStmt.setInt(1,eno);
    pStmt.setString(2,ename);
    pStmt.setFloat(3,sal);
    pStmt.setString(4,date);
    pStmt.setString(5,add);
    pStmt.setLong(6,ph);
    pStmt.setInt(7,dept);
    rs = pStmt.executeQuery();
    }catch(Exception es)
    {
    es.printStackTrace();
    }

  3. #3
    Join Date
    May 2002
    Posts
    3
    Hi Friends,
    I'm extremely sorry to say this to all.I given wrong cloumn name,so i got java.sql.Exception. Right now my application runing OK.

    Thank you.

    Regards,
    Rajendra

Posting Permissions

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