I'm stuck here. Please Help me!

I've created a feedback form which takes name, Email Id & Comments from users.
On submit button, i want to save the entered details along with the current date to the UserDetails table, so that, when admin logs in and wants to see the forms, he can see the date of post also.

Can you please guide me, how to get the system date and how to store it in database?
I'm using JSP.

Thank you!

9 Years
Discussion Span
Last Post by ~s.o.s~
java.util.Date newTime;
newTime = new java.util.Date(session.getLastAccessedTime());
out.println(new java.util.Date(session.getLastAccessedTime()));

Then store it by doing:

String sql1 = "Update table set lastAccessedTime = "+ newTime+";";
con = DriverManager.getConnection("jdbcdbc:laGuardia","","");
Statement stmt1 =con.createStatement();
int rs1 = stmt1.executeUpdate(sql1);

Don't use statement, use PreparedStatement. Date can be stored database table using either java.sql.Date (only for dates) or java.sql.Timestamp (for date along with time). Read the JDBC tutorials for more details.

Also each SQL implementation (i.e. each database) has it's own specific way of generating the current date, so if you know you are going to stick to one implementation, you can make use of that feature. For e.g. with Oracle, it's sysdate. insert into mytable(name, lastAccessed) values('sos', sysdate);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.