Java SQL Table clearTables(Connection conn)

Here you can find the source of clearTables(Connection conn)

Description

Clear the tables.

License

Open Source License

Parameter

Parameter Description
conn Database connection

Exception

Parameter Description
Exception into Junit

Declaration

public static void clearTables(Connection conn) throws Exception 

Method Source Code


//package com.java2s;
import java.sql.Connection;
import java.sql.Statement;

public class Main {
    /**//w  w w  . jav a  2 s .  co  m
     * Clear the tables.
     *
     * @param conn Database connection
     *
     * @throws Exception into Junit
     */
    public static void clearTables(Connection conn) throws Exception {
        Statement stmt = conn.createStatement();

        try {
            stmt.execute("delete from id_sequences where name = 'phase'");

            stmt.execute("delete from phase_dependency");
            stmt.execute("delete from phase_criteria");
            stmt.execute("delete from phase_criteria_type_lu");
            stmt.execute("delete from project_phase");
            stmt.execute("delete from phase_type_lu");
            stmt.execute("delete from phase_status_lu");
            stmt.execute("delete from project");
        } finally {
            stmt.close();
        }
    }
}

Related

  1. clearTables(Connection conn, String[] tables)
  2. clearTables(Connection connection)
  3. columnExist(String table, String column, Connection con)
  4. constructObject(Class theClass, Connection db, int objectId, String tableName, String uniqueField)