mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-07-06 23:33:03 +00:00
Init
This commit is contained in:
50
Commons/src/main/java/me/totalfreedom/sql/SQLProperties.java
Normal file
50
Commons/src/main/java/me/totalfreedom/sql/SQLProperties.java
Normal file
@ -0,0 +1,50 @@
|
||||
package me.totalfreedom.sql;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
public interface SQLProperties
|
||||
{
|
||||
Properties getProperties(File propertiesFile);
|
||||
|
||||
default Properties getDefaultProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("driver", "sqlite");
|
||||
properties.setProperty("host", "localhost");
|
||||
properties.setProperty("port", "3306");
|
||||
properties.setProperty("database", "database.db");
|
||||
properties.setProperty("username", "root");
|
||||
properties.setProperty("password", "password");
|
||||
return properties;
|
||||
}
|
||||
|
||||
String getDriver();
|
||||
|
||||
String getHost();
|
||||
|
||||
String getPort();
|
||||
|
||||
String getDatabase();
|
||||
|
||||
String getUsername();
|
||||
|
||||
String getPassword();
|
||||
|
||||
default String toURLPlain() {
|
||||
return String.format("jdbc:%s://%s:%s/%s",
|
||||
this.getDriver(),
|
||||
this.getHost(),
|
||||
this.getPort(),
|
||||
this.getDatabase());
|
||||
}
|
||||
|
||||
default String toURLWithLogin() {
|
||||
return String.format("jdbc:%s://%s:%s/%s?user=%s&password=%s",
|
||||
this.getDriver(),
|
||||
this.getHost(),
|
||||
this.getPort(),
|
||||
this.getDatabase(),
|
||||
this.getUsername(),
|
||||
this.getPassword());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user