title: Close connection for singleton connection pattern for MySQL (Java)
body: <p>I was wondering whether I need a closeConnection() method in my DBConnecter class. I know that you would normally close your connection whenever you are done using it, but with the connection being a singleton I am not completely sure. </p>
  
  <p>Here is my DBConnecter class:</p>
  
  <pre><code>public static String driver = "com.mysql.jdbc.Driver";
  public static String URL = "jdbc:mysql://localhost/polygondb";
  public static String ID = "root";
  public static String PW = "root";
  private static Connection connection = null;
  
  public static Connection getConnection() {
      if (connection == null) {
          try {
              Class.forName(driver);
          } catch (ClassNotFoundException ex) {
              Logger.getLogger(DBConnector.class.getName()).log(Level.SEVERE, null, ex);
          }
          try {
              connection = DriverManager.getConnection(URL, ID, PW);
          } catch (SQLException ex) {
              Logger.getLogger(DBConnector.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
      return connection;
  }
  </code></pre>
  
  <p>It might not be such a big deal, but I want to make sure as it is a school project for the exam (:</p>