title: Error - Could not find or load main class
body: <p>I want to connect my java program to connect with database and retrieve the data.
  its compile perfectly but runtime
  im getting this <code>Error : Could not find or load main class</code></p>
  
  <p>i have installed the Java SQL driver and added the jar path to the Environmental variable as CLASSPATH</p>
  
  <pre><code>import java.sql.*;
  public class Java2Sql{
      public static void main(String args[]){
          String url = "jdbc:mysql://localhost:80/";
          String dbName = "test";
          String driver = "com.mysql.jdbc.Driver";
          String userName = "root";
          String password = "root";
  
          try{
              Class.forName(driver).newInstance();
              Connection conn = DriverManager.getConnection(url+dbName,userName,password);
  
              Statement stmt = conn.createStatement();
              String strsql = "SELECT * FROM student";
  
              ResultSet res = stmt.executeQuery(strsql);
  
              while(res.next()){
                  System.out.println("ID :"+res.getString(1));
                  System.out.println("Name :"+res.getString(2));
                  System.out.println("Tel :"+res.getString(3));
                  System.out.println("City :"+res.getString(4));
              }
              res.close();
              conn.close();
          }catch(Exception e){
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>