wood burning stoves 2.0*
The moose likes JDBC and the fly likes Want to show the TimeStamp on the form, but needs to save it back later 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 "Want to show the TimeStamp on the form, but needs to save it back later" Watch "Want to show the TimeStamp on the form, but needs to save it back later" New topic
Author

Want to show the TimeStamp on the form, but needs to save it back later

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
When a complaint form shows up, I'd like to show the timestamp, do I get this from Java or MariaDB,

If from Java, I need to update this value and set the field type to DateTime

If from MariaDB, I need a stored procedure to generate a TimeStamp and display it on the form and save it back later.

Both seems very inlogical, what is the proper way of doing this?
Thanks
Jack
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

In Java, "new java.sql.Date()" creates the current date/time. You can then call stmt.setDate(1, new java.sql.Date()) to insert it in your database table.

I'm not familiar with stored procedures in MariaDB, but I'm sure it is possible. "now()" is often a database way of getting the current time.


[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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Want to show the TimeStamp on the form, but needs to save it back later
 
Similar Threads
f:convertDateTime and data type conversion
How would I do a all-round searching for all tables of the database?
MariaDb vs Mysql from java developers view!
jframe form issue
TimeStamp.toString() does not work as expected