mysql - A datetime equivalent in java.sql ? (is there a java.sql.datetime ?) -


so far, have not found clear answer this.

i'd know equivalent sql type datetime , java type, using preparedstatement.

i have found: http://www.java2s.com/code/java/database-sql-jdbc/standardsqldatatypeswiththeirjavaequivalents.htm

but states sql type "datetime" same sql.date, when looking @ sql date docs (http://download.oracle.com/javase/7/docs/api/java/sql/date.html), says time truncated (all zeros).

what want able specify preparedstatement.setdatetime() or sort.

the other way see using timestamp, require me change column type, while cannot imagine else never had problem before?

any hints?

edit: using mysql.

the java.sql package has 3 date/time types:

you want last one: java.sql.timestamp.

if using these types, don't need call specific setter; use:

java.util.date date = new date(); object param = new java.sql.timestamp(date.gettime()); // jdbc driver knows java.sql type: preparedstatement.setobject(param);  

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -