mercredi 27 juillet 2016

The contents in my MS Access database are not getting deleted using query in Java

However, the update query works fine.

import java.sql.*;
class MyDbDel
{
    public static void main(String arg[])throws ClassNotFoundException ,   SQLException
    {
    Connection con=null;
    Statement stmt;
    ResultSet rs=null;

    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        con=DriverManager.getConnection("jdbc:odbc:Database1");
        System.out.println("Connected To My Database");
    }catch(ClassNotFoundException ce){
        System.out.println(ce);
    }

    try{
        stmt=con.createStatement();
       //deletequery 

        stmt.executeUpdate("DELETE FROM Customers WHERE FirstName='Bob'");
        stmt.close();
    }catch (SQLException e){
        System.out.println(e);
    }
}
}

Aucun commentaire:

Enregistrer un commentaire