简体   繁体   中英

Retrieve 'Time' of Database MySQL

I'm trying to recover hours of the database, however is going the following exception:

java.sql.SQLException: java.sql.SQLException: Bad format for Time '13:00:00.000' in column 5

The line of exception is this:

Compromisso line = new Compromisso();
line.setHour (rs.getTime ("hour"));

Class compromisso:

//Using java.sql.Time
private Time hour;

Can anyone help me?

Check the type in the database.

Probably it is a varchar or Date or timestamp . So it is not possible to retrieve it as Time . It must be of type time

Here you can find the conversion table between java types and mysql column types.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM