I am making a query but it is giving error when I try to get values of type Time. This is the error:
java.sql.SQLException: java.sql.SQLException: Bad format for Time '13: 00: 00.000 'in column 5
The line that is firing the exception is this:
linha.setHoraInicial(resultado.getTime("hora_inicio"));
Save time on the bank in such a way:
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);
And I do this in the save method that stays in DAO:
comando.setTime(4, a.getHoraInicial());
And this is StackTrace
complete:
java.sql.SQLException: java.sql.SQLException: Bad format for Time '13 at 00:00 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.search (AgendaDAO.java:84) at com.agenda.view.FrmAgendaController.updateName (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)