Я пытаюсь обновить строку в базе данных.Все остальное работает нормально, удаляя, создавая, перечисляя, но редактирование строки дает мне исключение createSQLFeatureNotSupportedException
@Override
public Boolean editarUsuario(Usuario usuario) throws SQLException {
try(Connection connection = MySqlConnection.abrirConexao()){
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet resultSet = statement.executeQuery("select * from usuario where idUsuario = " + usuario.getIdUsuario());
if (resultSet.first()) {
resultSet.updateInt("IdUsuario", usuario.getIdUsuario());
resultSet.updateString("Login", usuario.getLogin());
resultSet.updateString("Senha", usuario.getSenha());
resultSet.updateBoolean("Admin",usuario.isAdmin());
resultSet.updateBoolean("Operador",usuario.isOperador());
resultSet.updateBoolean("Cliente",usuario.isCliente());
resultSet.updateRow();
return resultSet.rowUpdated();
}
}catch (SQLException e) {
e.printStackTrace();
}
return false;
}
Эта строка [return resultSet.rowUpdated();
] дает мне это исключение.Я просто хочу обновить строку.
Что я делаю не так?
Вот мой MySqlConnection
public class MySqlConnection {
public static String url = "jdbc:mysql://localhost:3306/webticket?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
public static String usuario = "root";
public static String senha = "123456";
public static Connection abrirConexao() throws SQLException {
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
return DriverManager.getConnection(url, usuario, senha);
}
}
А вот и исключение:
04-Dec-2018 09:00:36.294 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\DevTools\apache-tomcat-9.0.12\webapps\manager]
04-Dec-2018 09:00:36.344 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\DevTools\apache-tomcat-9.0.12\webapps\manager] has finished in [49] ms
java.sql.SQLFeatureNotSupportedException
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLFeatureNotSupportedException(SQLError.java:236)
at com.mysql.cj.jdbc.result.UpdatableResultSet.rowUpdated(UpdatableResultSet.java:1183)
at br.edu.fapi.webticket.usuario.dao.impl.UsuarioDAOImpl.editarUsuario(UsuarioDAOImpl.java:125)
at br.edu.fapi.webticket.usuario.dao.impl.OperadorDAOImpl.editarUsuario(OperadorDAOImpl.java:22)
at br.edu.fapi.webticket.usuario.web.OperadorEditar.doPost(OperadorEditar.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Есть идеи, как ее решить?