• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set auto increment field value ?

 
Raga Jana
Ranch Hand
Posts: 35
Google Web Toolkit Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This is my below code working perfectly. If i give the value for auto incremented field. But normally we should not specify any value for this auto incremented field. How i can rewrite this code?



Presently i'm not included the value for auto incremented filed. Could any one can explain me how to set the value for auto increment value. The above code showing Column count doesn't match value count at row 1..


 
Stephan van Hulst
Bartender
Pie
Posts: 6503
83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried inserting the value NULL for the the auto incremented column?
 
Raga Jana
Ranch Hand
Posts: 35
Google Web Toolkit Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.. It's working. And i have a one more doubt, I have four jsp pages. All are interacting with the Database. Presently i written the connection code in all the 4 JSP pages. Is it possible to write the connection code in a single page and utilizing in all the jsp page in the project??
 
Markas Korotkovas
Greenhorn
Posts: 21
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should never put database code in a jsp. Very bad practice and a nightmare to maintain. In general you should avoid putting any Java code in a JSP using the JSTL or something similar instead. All the Java code should be in the Controller (Servlet, DataAccess classes and etc.). This will allow for a cleaner implementation and more code reuse.
 
sarbjeet sidhu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You should create a DBConnection class, that handles all the connectiion related stuff, for example getConnection(),releaseConnection()... etc and use it in the db layer to perform database operations. And send the result of the operation to jsp page for displaying the result.

Thanks
 
Raga Jana
Ranch Hand
Posts: 35
Google Web Toolkit Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!! I understand i have to create a Database Connection class in the servlet. But what about the ResultSet and Statement Creation? For this also i can create a function in the Database Connection class or in the Jsp Page??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic