Tuesday 15 July 2014

java - Setting a particular date into a prepared statement -


I am trying to put any date in my prepared statement in this format (like 11/08/1989, 04 / 15/1955)

This is my code:

  pstmnt = conn.prepareStatement ("Include user_info values ​​(?,?,?,?,?, ?) "); Pstmnt.setInt (1, max_id); Pstmnt.setString (2, f_name); Pstmnt.setString (3, l_name); Pstmnt.setString (4, email); Pstmnt.setString (5, user name); Pstmnt.setDate (6,?); Pstmnt.addBatch ();   

I am sure how many metrics have been deprecated to complete this process.

Any thoughts?

you java.sql.Date object to setDate () is required to pass the method.

  pstmt.setDate (6, new java.sql.Date ((new simplified format ("MM / dd / yyyy"). Pars ("11/08/1989"). Time Remove ()));    

No comments:

Post a Comment