Here you can find the source of removeById(int Id)
public static void removeById(int Id)
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static Statement statement = null; private static PreparedStatement preparedStatement = null; private static ResultSet resultSet = null; private static Connection conn = null; public static void removeById(int Id) { try {// www . ja va 2s . c o m //establish connection conn = DriverManager.getConnection("jdbc:mysql://localhost/sbs_db?" + "user=root&password="); preparedStatement = conn.prepareStatement("DELETE FROM sbs_userdata WHERE Id=" + Id); // Result set get the result of the SQL query preparedStatement.executeUpdate(); } catch (SQLException e) { System.err.println("Error occurs while delete entry from database!"); e.printStackTrace(); } finally { close(); } } private static void close() { try { if (resultSet != null) { resultSet.close(); } if (statement != null) { statement.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { System.err.println("Error occurs while close DB connection"); } } }