Java JDBC H2 Connection deleteDatabaseH2()

Here you can find the source of deleteDatabaseH2()

Description

delete Database H

License

Open Source License

Declaration

public static void deleteDatabaseH2() throws SQLException 

Method Source Code


//package com.java2s;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {
    public static final String JDBC_URL = "jdbc:sqlite:C:/Users/timothyi/mta/database/development.sqlite3";

    public static void deleteDatabaseH2() throws SQLException {
        Connection conn = DriverManager.getConnection(JDBC_URL, "sa", "");

        Statement stmt = conn.createStatement();

        try {// w  w w  .  jav a 2  s.c  om
            stmt.execute("DROP ALL OBJECTS DELETE FILES");
            // stmt.execute("SHUTDOWN"); TODO: db files get removed if this line
            // is uncommented
        } finally {
            stmt.close();
            conn.close();
        }
    }
}

Related

  1. createDBWithTB(String db)
  2. deleteDatabase()
  3. getConnection()
  4. getH2Connection(String dbname)
  5. getH2Connection(String filename)
  6. isH2DbAlreadyRunning()