Java JDBC Sqlite Connection getConnection(final String databaseName)

Here you can find the source of getConnection(final String databaseName)

Description

get Connection

License

Apache License

Declaration

public static Connection getConnection(final String databaseName) throws SQLException 

Method Source Code

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

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

import java.sql.SQLException;

public class Main {
    private final static StringBuilder sb = new StringBuilder();
    private static final String JDBC_PREFIX = "jdbc:sqlite:";
    private static final String DB_SUFFIX = ".db";

    public static Connection getConnection(final String databaseName) throws SQLException {
        sb.setLength(0);//from  ww  w .j  a v a2  s .co m
        sb.append(JDBC_PREFIX).append(databaseName).append(DB_SUFFIX);
        Connection conn = null;
        conn = DriverManager.getConnection(sb.toString());
        sb.setLength(0);
        return conn;
    }
}

Related

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