I want to move all data that last 7 days before current date to other database, therefore i'm using two connection to select and insert the data. The problem is I can't insert datetime type into the table, it appears as 0000-00-00 00:00:00 when I checked it. I tried to parse using SimpleDateFormat but still not working. This is the snippet
Sometimes it's hard to guess the cause of problem. Can you possibly include the stack trace of the exception you've got? That way, we'll easily pin point where the problem is coming from, hence possible solution can be provided.
But initially, you might not be getting any results at all in your ResultSet object. Besides, you can simply use Statement, rather than PreparedStatement because you're not using or setting any parameters to your query anyway.
The problem is I can't insert datetime type into the table, it appears as 0000-00-00 00:00:00 when I checked it. I tried to parse using SimpleDateFormat but still not working.
Is there any specific reason for which you are inserting date as string after converting it to specific format. Are you sure there is no exception.
I guess you data type of column is date not String
Shailesh
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
The column value is dateTime, I use string to insert the data because it didn't work with with the value coming from rs.getDate() This is the output from my console
Originally posted by pingkan paula: The column value is dateTime, I use string to insert the data because it didn't work with with the value coming from rs.getDate()
Could you explain this, What I can guess is when you are calling rs.getDate() you are loosing time part of your date? Or is there something else which didn't work for you.
database errorjava.sql.SQLException: Duplicate entry '628151308255020050901000153496-nRn2Rkp4c01' for key 1
Did you try to trace for this error ? you are inserting a duplicate key in your table. What is primary keys on your table.