Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.sql.pref;
- /**
- *
- * @author Daniel
- */
- public class DefaultMySQLPreferences implements MySQLPreferences {
- /**
- * The default host base.
- */
- public static final String DEFAULT_HOST_BASE = "jdbc:mysql://";
- /**
- * The default driver directory.
- */
- public static final String DEFAULT_DRIVER = "com.mysql.jdbc.Driver";
- /**
- * The default local ip.
- */
- public static final String DEFAULT_HOST = "127.0.0.1";
- /**
- * The default number of threads for the server to use.
- */
- public static final int DEFAULT_THREAD_COUNT = 1;
- /**
- * The default amount of time that it takes for an idle connection to be
- * removed.
- */
- public static final int DEFAULT_IDLE_TIMEOUT = 60000;
- /**
- * The default amount of time between cleanups.
- */
- public static final int DEFAULT_CLEANUP_INTERVAL = 1000;
- /**
- * The max concurrent connections.
- */
- public static final int DEFAULT_CONNECTION_COUNT = 5;
- /**
- * The username to login with.
- */
- private final String USERNAME;
- /**
- * The password for the username set at <CODE>USERNAME</CODE>
- */
- private final String PASSWORD;
- /**
- * The host to connect to.
- */
- private final String HOST;
- /**
- * An array containing all of the database names to connect to.
- */
- private final String[] DATABASES;
- /**
- * This is needed to set name, password and databases.
- * @param username The MySQL username to use.
- * @param password The password for that user.
- * @param databases The database names.
- */
- public DefaultMySQLPreferences(String username, String password,
- String[] databases) {
- this.USERNAME = username;
- this.PASSWORD = password;
- this.HOST = DEFAULT_HOST;
- this.DATABASES = databases;
- }
- /**
- * This is needed to set name, password and databases.
- * @param username The MySQL username to use.
- * @param password The password for that user.
- * @param host The host.
- * @param databases The database names.
- */
- public DefaultMySQLPreferences(String username, String password,
- String host, String[] databases) {
- this.USERNAME = username;
- this.PASSWORD = password;
- this.HOST = host;
- this.DATABASES = databases;
- }
- public String getUsername() {
- return USERNAME;
- }
- public String getPassword() {
- return PASSWORD;
- }
- public String getHost() {
- return HOST;
- }
- public String[] getDatabaseNames() {
- return DATABASES;
- }
- public String getDriver() {
- return DEFAULT_DRIVER;
- }
- public int getThreadCount() {
- return DEFAULT_THREAD_COUNT;
- }
- public int getStaleConnectionTime() {
- return DEFAULT_IDLE_TIMEOUT;
- }
- public int getCleanupInterval() {
- return DEFAULT_CLEANUP_INTERVAL;
- }
- public int getMaxConnections() {
- return DEFAULT_CONNECTION_COUNT;
- }
- @Override
- public String getHostBase() {
- return DEFAULT_HOST_BASE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement