title: SQL connection : can't connect to database in java
body: <p>I have added JAR file "mysql-connector-java-5.1.36-bin" and have created database "UserScore" and under that table "ScoreSheet".I have added a row in ScoreSheet (Name,Score) value ('Kamal',40) to verify but the code throws a lot of exceptions on connection.I am using Eclipse + Xampp.</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  
  public class SQLDriver{
      public static void main(String[] args){
          try{
              //Accessing driver from jar file
              Class.forName("com.mysql.jdbc.Driver");
  
              //Get connection through creating a variable 'myConn'
              Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/UserScores");
  
              //Create statement
              PreparedStatement statement = myConn.prepareStatement("select * from 'scoresheet'");
  
              //Execute SQL Query
              ResultSet result = statement.executeQuery();
  
              //Process the result set
              while(result.next()){
                  System.out.println(result.getString(1)+" "+result.getString(2));
              }
          }
          catch(Exception e){
              e.printStackTrace();
          }
      }
  }
  </code></pre>