How to insert Current time in TIMESTAMP column(Oracle) from java class using jdbc

i have tryed many things but not able to insert data in my timestamp column. from toad its possible using this

UPDATE SUPPORTSTAFF 
     SET SUPPSTAFFJOINDATE=to_timestamp('27/02/2002 15:51.12.539880', 'dd/mm/yyyy hh24:mi.ss.ff') 
 where JDBCUSERID='5700';

its working

but how can i insert data from java class using create statment and execute query its giving me invalid month error

Answers


Use a PreparedStatement with a parameter for the timestamp, e.g.

UPDATE SUPPORTSTAFF SET SUPPSTAFFJOINDATE = ? where JDBCUSERID = ?

and then set the parameters:

statement.setTimestamp(1, new Timestamp(System.currentTimeMillis());
statement.setString(2, "your ID");

(Then execute the statement, obviously.)


Need Your Help

How to store data in cookies of browser

php codeigniter session-cookies

In codeigniter, how do I store data in the cookies of the browser?

Mithril ajax wrapper, m.request, converts failures to success

javascript ajax mithril.js

This may well be some newbie thing about JS and or Mithril that I am unaware of, but I have written a caching wrapper around Mithril's m.request() to track multiple pending requests with the intent...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.