Java JDBC Sqlite Connection getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection() throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Connection getConnection() throws SQLException {
        try {/*w  ww. j a v a  2s  .c om*/
            Class.forName("org.sqlite.JDBC");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.exit(-1);
        }

        Connection connection = DriverManager.getConnection("jdbc:sqlite:test.db", "", "");
        connection.setAutoCommit(false);
        return connection;
    }
}

Related

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