I am using SQL Server 2000 database and using a Java DAO class executing an SQL query using preparedStatement.The issue is that intermittently i get the following exception: "SQLException:Invalid column name". I checked the filed name in the table and the filed name i gave in the resultset.getInt("field_name")and both are matching.The parameter values for the query are fetched from a JSP report and the surprsing issue is that this exception comes on & off. So iam unable to find the cause of this exception.Can anyone help me out? Thanks Raghu
Thanks for your response. The table from which we query is USERS table and the column name which is giving the sqlexcetion is user_id. user_id field is a int data type.We are using the SQL server database.
FROM USERS usrs LEFT OUTER JOIN extended_user_attributes uedis ON (usrs.user_id = uedis.user_id AND usdis.attrib_id=?), user_permission uperm WHERE usrs.user_id = uperm.user_id AND uperm.name=? AND some other conditions ...
and the code snippet is as follows: Load the driver create the connection... make the preparedStatement and setting the parameters ResultSet rs = preparedStatement.executeQuery();
UserID userid = new UserID(); userid.setUserID(rs.getInt("user_id")); .....
The exception i.e coming is
(java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid column name: user_id)
Joined: Aug 26, 2004
Hi , What i would like to add here is the issue doesnt seem to be with either the SQL query or the code because we get these exception only sometimes.Otherwise the code works fine. I want to know whether there is some issue with the SQL server JDBC driver or something else.
Joined: Aug 15, 2004
no this is something you wrote it here, not the actual code. please paste the actual code. otherwise it would be difficult to figure out the issue.
may be driver issue, not sure about that?? [ October 15, 2004: Message edited by: adeel ansari ]