This week's book giveaway is in the Android forum.
We're giving away four copies of Android Programming: The Big Nerd Ranch Guide and have Bill Phillips & Chris Stewart on-line!
See this thread for details.
Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bad format for Time  RSS feed

 
pankaj semwal
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.


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36875
481
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!