Java examples for JDBC:Table
Deleting All Rows from a Database Table
import java.sql.Connection; import java.sql.Statement; public class Main { public void m() throws Exception { Connection connection = null; Statement stmt = connection.createStatement(); // Use TRUNCATE String sql = "TRUNCATE my_table"; // Use DELETE sql = "DELETE FROM my_table"; // Execute deletion stmt.executeUpdate(sql);/*www . j a v a2 s . c o m*/ } }