How do I pass a Timestamp from JDBC to a database? Give me some database specific examples (MS Access etc.).

Richard Katz

Use the setTimestamp() method to load your timestamp into a PreparedStatement. First create a connection to the database and then:

String upsql="UPDATE MYTABLE SET MYDATETIME = ? WHERE MYTABLEID=100";
PreparedStatement pstmt = con.prepareStatement(upsql);
pstmt.setTimestamp(1,mytimestampvar);
pstmt.execute();

This method can be used with any database that supports timestamps and any driver that supports PreparedStatement.

For Windows desktop databases, the JDataConnect driver (and a number of other Windows specific type 3 drivers) support PreparedStatement. If the JDBC-ODBC bridge isn't doing what you need, try a more industrial strength driver. You can obtain a copy of JDataConnect from http://www.softsyn.com/.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact