Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. package server.sql.pref;
  2.  
  3. /**
  4. *
  5. * @author Daniel
  6. */
  7. public class DefaultMySQLPreferences implements MySQLPreferences {
  8. /**
  9. * The default host base.
  10. */
  11. public static final String DEFAULT_HOST_BASE = "jdbc:mysql://";
  12.  
  13. /**
  14. * The default driver directory.
  15. */
  16. public static final String DEFAULT_DRIVER = "com.mysql.jdbc.Driver";
  17.  
  18. /**
  19. * The default local ip.
  20. */
  21. public static final String DEFAULT_HOST = "127.0.0.1";
  22.  
  23. /**
  24. * The default number of threads for the server to use.
  25. */
  26. public static final int DEFAULT_THREAD_COUNT = 1;
  27.  
  28. /**
  29. * The default amount of time that it takes for an idle connection to be
  30. * removed.
  31. */
  32. public static final int DEFAULT_IDLE_TIMEOUT = 60000;
  33.  
  34. /**
  35. * The default amount of time between cleanups.
  36. */
  37. public static final int DEFAULT_CLEANUP_INTERVAL = 1000;
  38.  
  39. /**
  40. * The max concurrent connections.
  41. */
  42. public static final int DEFAULT_CONNECTION_COUNT = 5;
  43.  
  44. /**
  45. * The username to login with.
  46. */
  47. private final String USERNAME;
  48.  
  49. /**
  50. * The password for the username set at <CODE>USERNAME</CODE>
  51. */
  52. private final String PASSWORD;
  53.  
  54. /**
  55. * The host to connect to.
  56. */
  57. private final String HOST;
  58.  
  59. /**
  60. * An array containing all of the database names to connect to.
  61. */
  62. private final String[] DATABASES;
  63.  
  64. /**
  65. * This is needed to set name, password and databases.
  66. * @param username The MySQL username to use.
  67. * @param password The password for that user.
  68. * @param databases The database names.
  69. */
  70. public DefaultMySQLPreferences(String username, String password,
  71. String[] databases) {
  72. this.USERNAME = username;
  73. this.PASSWORD = password;
  74. this.HOST = DEFAULT_HOST;
  75. this.DATABASES = databases;
  76. }
  77.  
  78. /**
  79. * This is needed to set name, password and databases.
  80. * @param username The MySQL username to use.
  81. * @param password The password for that user.
  82. * @param host The host.
  83. * @param databases The database names.
  84. */
  85. public DefaultMySQLPreferences(String username, String password,
  86. String host, String[] databases) {
  87. this.USERNAME = username;
  88. this.PASSWORD = password;
  89. this.HOST = host;
  90. this.DATABASES = databases;
  91. }
  92.  
  93. public String getUsername() {
  94. return USERNAME;
  95. }
  96.  
  97. public String getPassword() {
  98. return PASSWORD;
  99. }
  100.  
  101. public String getHost() {
  102. return HOST;
  103. }
  104.  
  105. public String[] getDatabaseNames() {
  106. return DATABASES;
  107. }
  108.  
  109. public String getDriver() {
  110. return DEFAULT_DRIVER;
  111. }
  112.  
  113. public int getThreadCount() {
  114. return DEFAULT_THREAD_COUNT;
  115. }
  116.  
  117. public int getStaleConnectionTime() {
  118. return DEFAULT_IDLE_TIMEOUT;
  119. }
  120.  
  121. public int getCleanupInterval() {
  122. return DEFAULT_CLEANUP_INTERVAL;
  123. }
  124.  
  125. public int getMaxConnections() {
  126. return DEFAULT_CONNECTION_COUNT;
  127. }
  128.  
  129. @Override
  130. public String getHostBase() {
  131. return DEFAULT_HOST_BASE;
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement