PDA

View Full Version : java.sql.SQLException: ORA-00904: invalid column name.


mgrmani
05-23-02, 18:54
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

mgrmani
05-23-02, 19:10
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();
}

mgrmani
05-24-02, 01:34
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