| Author |
problem with integer values
|
gaurav chhabra
Ranch Hand
Joined: Jul 24, 2004
Posts: 109
|
|
sir i m using MS ACCESS and JSP........i want to interconnect the both....but i m facing problem while inserting the values of the integer........the code is that............. String lastused = request.getParameter("last_used"+i); int last_used = Integer.parseInt(lastused); String query = "insert into skills values(1 , '" + skill_type + "' , '" + skill_name + "', '" + version + "', '" + last_used + "' , '" + proficiency_level + "', '" + exp_in_years + "' ,'" + exp_in_months + "')"; please tell me the error thank you gaurav
|
 |
Horatio Westock
Ranch Hand
Joined: Feb 23, 2005
Posts: 221
|
|
You haven't told us what error you are getting. If you tell us what the problem is, then perhaps we can help. In general, if you use PreparedStatement, then set the parameters using the appropriate methods (setInt(int, int), setString(int, String)), then you will have neater code, and be less likely to encounter these kinds of errors.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26241
|
|
Gaurav, I agree with Horatio that you should use PreparedStatement. (You should also try to keep JDBC out of your JSP, but that's another story.) Given that, it is still useful to understand the error because it applies to pure SQL queries too. Last used is a numeric field. Therefore, it shouldn't have quotes around it. The quotes tell your database that last used is a string. Then it has errors comparing two different types.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: problem with integer values
|
|
|