Java JDBC Sqlite Connection createTable(String database, String sqlScript)

Here you can find the source of createTable(String database, String sqlScript)

Description

create Table

License

Apache License

Declaration

public static void createTable(String database, String sqlScript) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Connection;
import java.sql.DriverManager;

import java.sql.Statement;

public class Main {
    public static void createTable(String database, String sqlScript) {
        Connection c = null;//from   w  w  w .  j  a  v a2  s.c  o m
        Statement stmt = null;
        try {
            Class.forName("org.sqlite.JDBC");
            c = DriverManager.getConnection("jdbc:sqlite:" + database);

            stmt = c.createStatement();

            stmt.executeUpdate(sqlScript);
            stmt.close();
            c.close();
        } catch (Exception e) {
            System.err.println(e.getClass().getName() + ": " + e.getMessage());
            System.exit(0);
        }
    }
}

Related

  1. checkConnection()
  2. createTable(final String databaseName, final String statement)
  3. getConnection()
  4. getConnection(final String databaseName)
  5. getConnection(String dbFile)
  6. getConnection(String dbFilePath)