Java Utililty Methods JDBC Sqlite Connection

List of utility methods to do JDBC Sqlite Connection

Description

The list of methods to do JDBC Sqlite Connection are organized into topic(s).

Method

booleancheckConnection()
Checks if connection is supposed to be present and attempts to reconnect if there was previously an error.
if (connection != null) {
    try {
        return (!errorCondition) || connect(userName, password, null);
    } catch (IOException ioe) {
        return false;
return false;
...
voidcreateTable(final String databaseName, final String statement)
create Table
Connection c = null;
Statement stmt = null;
try {
    c = DriverManager.getConnection("jdbc:sqlite:" + databaseName + ".db");
    System.out.println("Opened database successfully");
    stmt = c.createStatement();
    stmt.executeUpdate(statement);
    stmt.close();
...
voidcreateTable(String database, String sqlScript)
create Table
Connection c = null;
Statement stmt = null;
try {
    Class.forName("org.sqlite.JDBC");
    c = DriverManager.getConnection("jdbc:sqlite:" + database);
    stmt = c.createStatement();
    stmt.executeUpdate(sqlScript);
    stmt.close();
...
ConnectiongetConnection()
get Connection
try {
    Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.exit(-1);
Connection connection = DriverManager.getConnection("jdbc:sqlite:test.db", "", "");
connection.setAutoCommit(false);
...
ConnectiongetConnection(final String databaseName)
get Connection
sb.setLength(0);
sb.append(JDBC_PREFIX).append(databaseName).append(DB_SUFFIX);
Connection conn = null;
conn = DriverManager.getConnection(sb.toString());
sb.setLength(0);
return conn;
ConnectiongetConnection(String dbFile)
get Connection
try {
    Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
Properties connectionProps = new Properties();
connectionProps.setProperty("flags", "READONLY");
Connection connection = DriverManager.getConnection("jdbc:sqlite:" + new File(dbFile).toURI().getPath(),
...
ConnectiongetConnection(String dbFilePath)
get Connection
Connection conn = null;
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) {
...
ConnectiongetConnection(String dbName)
get Connection
if (mConn == null) {
    try {
        Class.forName(mdbDriver);
        String connDbName = mdbName;
        if (dbName != null) {
            connDbName = dbName;
        mConn = DriverManager.getConnection(mdbUrl + connDbName, mdbUser, mdbPwd);
...
ConnectiongetNewConnection(File dbFile)
get New Connection
Connection c;
try {
    Class.forName("org.sqlite.JDBC");
    c = DriverManager.getConnection("jdbc:sqlite:" + dbFile.getAbsolutePath());
    return c;
} catch (Exception e) {
    return null;
TreeMapgetSenatorProp(String topicId)
get Senator Prop
Connection c = null;
Statement stmt = null;
TreeMap<String, Double> output = new TreeMap<String, Double>();
try {
    Class.forName("org.sqlite.JDBC");
    c = DriverManager.getConnection("jdbc:sqlite:dbs/newpress.db");
    c.setAutoCommit(false);
    System.out.println("Opened database successfully");
...