get Connection to h2 database - Java java.sql

Java examples for java.sql:h2

Description

get Connection to h2 database

Demo Code


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

import java.sql.SQLException;

public class Main {
    private static final String DB_CONN_URL = "jdbc:h2:file:~/h2db";
    private static final String USERNAME = "surya";
    private static final String PASSWORD = "kiran";

    public static Connection getConnection() throws SQLException,
            ClassNotFoundException {
        Class.forName("org.h2.Driver");
        Connection conn = DriverManager.getConnection(DB_CONN_URL,
                USERNAME, PASSWORD);//from w w w .ja v a2 s . co  m

        return conn;
    }
}

Related Tutorials