title: Java DB Connection Manager Best Practice
body: <p>I have a connection manager code as follows:</p>
  
  <pre><code>public class ConnectionManager {
  
      private final String driverName = "com.mysql.jdbc.Driver";
      private final String connectionUrl = "jdbc:mysql://localhost:3306/student";
      private final String userName = "root";
      private final String userPass = "root";
  
      private Connection con = null;
  
      public ConnectionManager() {
          try {
              Class.forName(driverName);
          } catch (ClassNotFoundException e) {
              System.out.println(e.toString());
          }
      }
  
      public Connection createConnection() {
          try {
              con = DriverManager.getConnection(connectionUrl, userName, userPass);
          } catch (SQLException e) {
              e.printStackTrace();
          }
          return con;
      }
  
      public void closeConnection() {
          try {
              this.con.close();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>How can I improve this? I am thinking the following improvement:</p>
  
  <ol>
  <li>) create a connection.properties. What is the best way to implement this? Should I put it the call of the property file on a singleton?</li>
  <li>) Make the connection singleton.</li>
  </ol>
  
  <p>Thank you.</p>