| Author |
storing date in mysql
|
Jyoti Jadhav
Greenhorn
Joined: Nov 15, 2007
Posts: 18
|
|
hi in my program i am entering a string parsing it to date and storing it in table. i am not getting any error but the table is not upfdating.. code is... con2=GetConnection(); PreparedStatement st=con2.prepareStatement("INSERT INTO employee VALUES(?,?,?,?,?,?)"); String s="12/03/2007"; SimpleDateFormat df=new SimpleDateFormat("mm/dd/yyyy"); java.util.Date p=df.parse(s); st.setString(1,"7"); st.setString(2,"manasi"); st.setString(3,"tilak"); st.setDate(4,(Date) p); st.setString(5,"400000"); st.setString(6,"n"); st.executeUpdate();
|
 |
Paul Campbell
Ranch Hand
Joined: Oct 06, 2007
Posts: 338
|
|
|
are you in auto-commit mode?
|
 |
Jyoti Jadhav
Greenhorn
Joined: Nov 15, 2007
Posts: 18
|
|
Originally posted by Paul Campbell: are you in auto-commit mode?
how to check the auto commit mode?and i should or should not in auto commit mode.. thanks
|
 |
Jyoti Jadhav
Greenhorn
Joined: Nov 15, 2007
Posts: 18
|
|
Originally posted by Paul Campbell: are you in auto-commit mode?
yes i am in autocommit mode because executing select @@autocommit; giving me value 1.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
Are you sure you are not getting a ClassCastException? Here, you are casting a java.util.Date object as java.sql.Date. The object isn't an instance of java.sql.Date however. To create a java.sql.Date from a java.util.Date you have to do the following: The same goes for Time and Timestamp.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jyoti Jadhav
Greenhorn
Joined: Nov 15, 2007
Posts: 18
|
|
thanks it worked.
|
 |
 |
|
|
subject: storing date in mysql
|
|
|