get sqlite Connection - Java java.sql

Java examples for java.sql:Connection

Description

get sqlite Connection

Demo Code


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

import java.sql.SQLException;

public class Main {
    private static final String DATABASE_URL = "jdbc:sqlite:E:/data.db";

    public static Connection getConnection() {

        try {/*from w  w w .  j  a va 2 s . c o m*/
            Class.forName("org.sqlite.JDBC");
            return DriverManager.getConnection(DATABASE_URL, null, null);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related Tutorials