title: How to connect MySQL to Java program
body: <p>I ve installed MySQL (last update). 
  I need to code, that ll create &amp; establish a connection with SQL DB
  &amp; manage the DB(using SELECT, INSERT, CREATE).</p>
  
  <p>I did everything but, I am not able to create connection. I've also installed the MySQL/J connector, I just extracted the <code>.zip</code> pack in a folder &amp; added the folder path in <em>Variables</em>).</p>
  
  <p>Can anyone tell me wat is meant by URL in the below line?</p>
  
  <pre><code>Connection connection = DriverManager.getConnection(url, username, password);
  </code></pre>
  
  <p>I ve tried this:</p>
  
  <pre><code>String url = "jdbc:odbc:sqlserver://localhost:3306/myfirstdb";
  Connection con = DriverManager.getConnection(url, "root", "1234");
  </code></pre>
  
  <p>But it's not working. I am unable able to understand the term 'URL'.
  Can anyone explain, the meaning of 'url' and wat should be done to connect to a SQL server from Java.</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>This is the Full code. It still cannot connect.</p>
  
  <pre><code>import java.sql.*;
  
  public class TestDriver {
  
  public static void main(String[] args) {
  try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//This s wat actually i did for connection
      System.out.println("Driver Loaded Succesfully");
  }
  catch (Exception e){
      System.out.println("Unable to Load Driver!!!");
  }
  
  try {
      Class.forName(com.mysql.jdbc.Driver");  // initialise the driver
      String url ="jdbc:mysql://localhost:3306/myfirstdb";
      Connection con = DriverManager.getConnection(url, "root", "1234");
      System.out.println("connection Established");
      }
      catch(Exception e) {
                  System.out.println("Couldnt get connection");
      }
      }
  }
  </code></pre>
  
  <p>Can you tell me wat is the purpose of MySQL Connector/J?</p>