>
Estou com uma problema para inserir dados no banco, o mesmo está dando seguinte erro:
HTTP Status 500 ? Internal Server Error
Message java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Segue código JAVA abaixo.
try {
Class.forName("com.mysql.jdbc.Driver");
String SQLInsert = "INSERT INTO chamados (titulo, conteudo) , values (";
SQLInsert += " ' " + titulo + "' , '" + conteudo + " ');";
try {
Connection conect = DriverManager.getConnection("jdbc:mysql://localhost/chamados", "root" , "alegria1991");
Statement stm = conect.createStatement();
stm.executeQuery(SQLInsert);
stm.close();
conect.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
} catch (ClassNotFoundException e1) {
throw new RuntimeException(e1);
}
}
Olá
O comando está diferente do curso, você precisa usar um PreparedStatement para comandos INSERT, DELETE etc.