public class Database extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Database.DatabaseType |
Modifier and Type | Field and Description |
---|---|
static boolean |
hasCustom |
Constructor and Description |
---|
Database() |
Modifier and Type | Method and Description |
---|---|
static void |
close()
Close the connection if not null
|
static void |
connect(String url,
String username,
String password)
Create a connection to the database
|
static Connection |
getConnection()
Get the database connection
If null or closed, it will re-connect.
|
static void |
init()
Load database
Don't try to connect if has custom is on false
|
public static void connect(String url, String username, String password)
url
- the database URL such as 127.0.0.1/mySchemausername
- the database usernamepassword
- the user passwordpublic static Connection getConnection() throws SQLException
SQLException
- if the connection cannot be re-openIllegalStateException
- if your are trying to use DB without active itpublic static void close()
public static void init()