This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem in getting date from JSP Form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in getting date from JSP Form" Watch "Problem in getting date from JSP Form" New topic
Author

Problem in getting date from JSP Form

mohsin sheikh
Greenhorn

Joined: Mar 28, 2007
Posts: 22
Hi,
I am implenting a project on Library Management System(Web application).
I have a form as New User Registration Form in which user enters his/her information.There is one field as DateOfBirth which takes input as string(i.e date of birth of the user).Now I am extracting this inputs in Servlet.
My aim is to insert these inputs in a user table.I am using SQL Server 2000.
I am using Prepared Statement for Insert query.I convert the date of birth which is in string to java.sql.Date object using the following code:-

java.util.Date d=null;
java.sql.Date dateofbirth=null;

try {
SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
dateofbirth = new java.sql.Date(formatter.parse(dob).getTime());

} catch(Exception e) {
e.printStackTrace();}

Now the problem arises when i am doing this:-

query="Insert into USERDETAILS values(?,?,?,?,?,?,?,?,?,?,?)";

pstmt=con.prepareStatement(query);
pstmt.setString(1, userid);
pstmt.setString(2, name);
******* pstmt.setDate(3, dateofbirth);
pstmt.setString(4, gender);
pstmt.setString(5, address);
pstmt.setString(6, city);
pstmt.setString(7, state);
pstmt.setString(8, country);
pstmt.setString(9, phone);
pstmt.setString(10, email);
pstmt.setString(11, occupation);
i=pstmt.executeUpdate();

I am getting error in "pstmt.setDate(3, dateofbirth);".
It gives error like "java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented"

This is the error i m getting.Please help me in this matter.I will be very thankful to you.

Regards,
Mohsin
 
wood burning stoves
 
subject: Problem in getting date from JSP Form
 
Similar Threads
Problem in getting date from JSP Form
getting java.sql.Timestamp exception
Database Insert With java.util.Date
Database Insert With java.util.Date
Problem in getting date from JSP Form