Anver Anver - 27 days ago 10
SQL Question

Java (netbeans): The database is connected to SQL Server, i need to update, and delete data from the netbeans interface

the data is being view for this code by the interface:

private void distable() {
try {
String url="jdbc:sqlserver://localhost:1433;databaseName=77OOP062;user=sa;password=hnd";
Connection conn= DriverManager.getConnection(url);
String sql ="Select * from Customer";
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);

and this is my update button code:
// i dont know how the code work over here
and this is my delete button code:

String query =
"DELETE FROM 'Customer' WHERE CustomerName="
+ jTextFieldCustomerName.getText();
executeSQLQuery(query,"Delete"); //error on this executeSQLQuery code

Answer Source

try this one instead of using executeSqlQuery, use this:

Statement statement = connection.createStatement();