Here you can find the source of truncateTable(Connection conn, String table_name)
public static void truncateTable(Connection conn, String table_name)
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { public static void truncateTable(Connection conn, String table_name) { Statement truncateStmt = null; Statement countStmt = null; String truncateSQL = "TRUNCATE TABLE " + table_name; String countSQL = "SELECT COUNT(*) as count FROM " + table_name; try {/* w w w. j a va 2 s . c o m*/ truncateStmt = conn.createStatement(); truncateStmt.executeUpdate(truncateSQL); countStmt = conn.createStatement(); ResultSet rs = countStmt.executeQuery(countSQL); System.out.println("Truncated " + table_name); while (rs.next()) { System.out.println(rs.getInt("count") + " rows"); } } catch (SQLException ex) { System.out.println(ex.getMessage()); } } }