• Welcome to Valhalla Legends Archive.
 

SQL/Java Interaction

Started by iago, February 13, 2004, 01:57 PM

Previous topic - Next topic

iago

I'm having a problem with timestamps.  Calling an INSERT with a java.sql.Timestamp.toString() works fine, but when I pull it back out I end up with a string that looks like this:
20040213132931
And java.sql.Timestamp.valueOf(20040213132931) gives me this error:
Exception in thread "main" java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
       at java.sql.Timestamp.valueOf(Timestamp.java:128)
       at db.Assignment.set(Assignment.java:43)
       at db.DB.get(DB.java:130)
       at db.DB.main(DB.java:187)

Is there some way to convert it to a format like that, or am I stuck using a pile of yucky substrs?  

Thanks!
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


iago

Solved: I was using ResultSet.getString(), which was converting it to a sttring.  Now I'm using ResultSet.getObject() and taking care of it that way.  Note that it is also possible to do ResultSet.getTimestamp(), but objects work better for me since i'm putting them in a Vector anyway.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*