Skip to content

Instantly share code, notes, and snippets.

@colinbut
Created August 4, 2018 21:41
Show Gist options
  • Save colinbut/71842595a8eb0c1cda9ee496825f49d4 to your computer and use it in GitHub Desktop.
Save colinbut/71842595a8eb0c1cda9ee496825f49d4 to your computer and use it in GitHub Desktop.
private static final String DB_DRIVER = "org.h2.Driver";
private static final String DB_CONNECTION = "jdbc:h2:~/test";
private static final String DB_USER = "";
private static final String DB_PASSWORD = "";
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
try {
dbConnection = DriverManager.getConnection(DB_CONNECTION, DB_USER,DB_PASSWORD);
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return dbConnection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment