Estou fazendo uma consulta porém está dando erro quando tento pegar valores do tipo Time. Esse é o erro:
java.sql.SQLException: java.sql.SQLException: Bad format for Time '13:00:00.000' in column 5
A linha que está disparando a exceção é essa:
linha.setHoraInicial(resultado.getTime("hora_inicio"));
Salvo a hora no banco de tal maneira:
DateFormat dateFormat = new SimpleDateFormat("hh:mm");
java.sql.Time timeValue = new java.sql.Time(dateFormat.parse(txtHoraInicial.getText()).getTime());
System.out.println("Time: " + timeValue);
c.setHoraInicial(timeValue);
E faço isso no método salvar que fica no DAO:
comando.setTime(4, a.getHoraInicial());
E esse é o StackTrace
completo:
java.sql.SQLException: java.sql.SQLException: Bad format for Time '13:00:00.000' in column 5 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910) at com.mysql.jdbc.ResultSet.getTimeFromBytes(ResultSet.java:6164) at com.mysql.jdbc.ResultSet.getTimeInternal(ResultSet.java:6198) at com.mysql.jdbc.ResultSet.getTime(ResultSet.java:5779) at com.mysql.jdbc.ResultSet.getTime(ResultSet.java:5814) at com.agenda.dao.AgendaDAO.buscar(AgendaDAO.java:84) at com.agenda.view.FrmAgendaController.atualizarNome(FrmAgendaController.java:138) at com.agenda.view.FrmAgendaController.init(FrmAgendaController.java:127) at com.agenda.view.FrmAgendaController.initialize(FrmAgendaController.java:83) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2552) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101) at com.agenda.view.Agenda.start(Agenda.java:22) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863) at com.sun.javafx.application.LauncherImpl$$Lambda$53/681110827.run(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl$$Lambda$46/355629945.run(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295) at com.sun.javafx.application.PlatformImpl$$Lambda$48/1296242029.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294) at com.sun.javafx.application.PlatformImpl$$Lambda$47/1915503092.run(Unknown Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101) at com.sun.glass.ui.win.WinApplication$$Lambda$36/1963387170.run(Unknown Source) at java.lang.Thread.run(Thread.java:745)
java.sql.Time
getTime()
não aceita nenhum tipo de argumento. Veja: docs.oracle.com/javase/7/docs/api/java/util/Date.html#getTime() Você não quis usar osetTime()
?