This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes  Bad format for Time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark " Bad format for Time" Watch " Bad format for Time" New topic
Author

Bad format for Time

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30070
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: Bad format for Time
 
Similar Threads
JBM-Tables not created.
query is not getting executed
JDBC throws exception on java app detach from console
Mysql driver fails on connection
Queries and "column not found" error