Olá Não estou conseguindo inserir no Banco de Dados.
package JDBC;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import com.mysql.jdbc.PreparedStatement;
public class Insercao {
/**
* Programa que exclui
*
* @param args
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
String nome = "Ricardo Moraes";
String telefoneCelular = "85 0000-8888";
String descricaoServ = "Unha";
Integer codigo_funcionario = 7;
Date data = new Date();
Date hora = new Date();
Connection connection = DataBase.getConnection();
String sql = "insert into agendamento(nome,telefoneCelular,descricaoServ,codigo_funcionario,data,hora) "
+ "values(?,?,?,?,?,?)";
PreparedStatement statement = (PreparedStatement) connection.prepareStatement(sql);
statement.setString(1, nome);
statement.setString(2, telefoneCelular);
statement.setString(3, descricaoServ);
statement.setInt(4, codigo_funcionario);
statement.setDate(5, (java.sql.Date) data);
statement.setDate(6, (java.sql.Date) hora);
statement.executeQuery();
connection.close();
statement.close();
}
}
Erro
Conectado Exception in thread "main" java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)
at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:472)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1387)
at JDBC.
`Insercao.main(Insercao.java:21)