title: How to make a MySQL Connection in JAVA
body: <p>I can't seem to get a connection made on my Java program to java, I have started the MySQL Server, made a database in phpMyAdmin. But I'm confused on how I should use the JDBC Driver that I downloaded from MySQL.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>    private void startConnection()
  {
  Connection conn = null;
  String url = "jdbc:mysql://localhost/";
  String dbName = "bank";
  String driver = "com.mysql.jdbc.Driver";
  String userName = "root";
  String password = "password";
  try {
    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName,userName,password);
    System.out.println("Connected to the database");
    conn.close();
    System.out.println("Disconnected from database");
  } catch (Exception e) {
      System.out.println("NO CONNECTION =(");
  }
  }
  </code></pre>
  
  <p>I had included the jar file in my JDK - jre\lib\ext folder but nothing. Any ideas?</p>
  
  <p>Thanks in advance.</p>