Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a small change in code and fix the error.

 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am writing a code to enter datas from a jsp where in the table created consists of 3 cols Query_ID, Query_Raised and TR. here Query_ID is to be assigned automatically, Query_Raised is to be taken from another page where the field name is txt2, and TR is the system time. please help me with the below code. And also i am receiving an error as java.sql.SQLException: Invalid column index .
 
Wendy Gibbons
Bartender
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and welcome to the ranch.
I added code tags to your post doesn't it look prettier and easier to read. it made it a 2 second job to spot the bug in your code.

The index for the ps.set... methods starts at 1 (not zero like everything else), it isn't refering to the column in your SQL but to which '?' it refers to, the 1st one the 2nd one etc.

And for future reference you really should get used to using a servlet for your database code. pleae read this very helpful page: why not use scriptlets
 
chris webster
Bartender
Posts: 2407
32
Linux Oracle Postgres Database Python Scala
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Read the error message. It talks about an invalid column index in your SQL call so you know where to start looking.
2. So look at your SQL and count the parameters you want to pass in.
3. Look at the lines where you set these parameters and see if you can figure out where the problem is.

By the way, you shouldn't data access code in your JSPs anyway.
 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris and Wendy,
Thanks for your answers. my previous error was solved, but the problem i'm getting is that i'm able to see both time and date but i want only time and it should be system time. here i'm unable to get system time it is showing 12:00:00:00 AM. And thanks for suggesting me to use servlets instead of JSPs and could you also suggest me some good sites to learn servlets as i'm totally new to J2EE.

Thanks,
Rakesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic