Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- public class Main {
- static final String JDBC_DRIVER = "org.h2.Driver";
- static final String DB_URL = "jdbc:h2:~/test";
- // Database credentials
- static final String USER = "sa";
- static final String PASS = "";
- public static void main(String[] args) {
- System.out.println("Hello, friend.");
- Connection conn = null;
- Statement stmt = null;
- try {
- Class.forName(JDBC_DRIVER);
- System.out.println("Connecting to database...");
- conn = DriverManager.getConnection(DB_URL, USER, PASS);
- System.out.println("Creating table in given database...");
- stmt = conn.createStatement();
- conn.close();
- stmt.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement