Java JDBC Sqlite Connection getConnection(String dbFilePath)

Here you can find the source of getConnection(String dbFilePath)

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection(String dbFilePath) 

Method Source Code


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

public class Main {
    private static String default_db_name = "data";

    public static Connection getConnection(String dbFilePath) {
        Connection conn = null;//from www.j  av a  2 s.  co m
        try {
            if (dbFilePath == null || "".equals(dbFilePath.trim())) {
                dbFilePath = default_db_name;
            }
            Class.forName("org.sqlite.JDBC");
            conn = DriverManager.getConnection("jdbc:sqlite:" + dbFilePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }
}

Related

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