• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bad format for Time  RSS feed

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a query like this select TIMEDIFF(TIME(al.login_time),CURTIME()) AS currDuration ") ;

It return correct time diffrence when i run this query in mysql prompt.

But when i use query in java code :
and try to get time difference

like this resultSet.getString("currDuration");

Its show excpetion :

java.sql.SQLException: java.sql.SQLException: Bad format for Time '-10:02:47' in column 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)

Please tell me where i am wrong.


 
author & internet detective
Marshal
Posts: 37714
579
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pankaj,
It is good practice to use one of getDate(), getTime() and getTimeStamp() rather than getString(). That way your database can handle the conversion for you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!