"Cannot find symbol" problem when using Class.forName()
<p>I'm getting the <code>cannot find symbol</code> error from my code. Does anyone know what can cause this problem?</p>

<p>The code is:</p>

<pre><code>// Register JDBC driver
Class.forName("net.sourceforge.jtds.jdbc.Driver");
</code></pre>

<p>and the error output is:</p>

<pre><code>blah.java:314: cannot find symbol
symbol  : method forName(java.lang.String)
location: class java.lang.Class
                Class.forName("net.sourceforge.jtds.jdbc.Driver");
                     ^
1 error
</code></pre>

<hr>

<pre><code>//STEP 1. Import required packages
import java.sql.*;

public class JDBCExample {
   // JDBC driver name and database URL
   static final String JDBC_DRIVER = "com.sql.jdbc.Driver";

   static final String DB_URL = (":jdbc:jtds:sqlserver://localhost:1433/tempdb" );





   //  Database credentials
   static final String USER = "username";
   static final String PASS = "password";

   public static void main(String[] args) {
   Connection conn = null;
   Statement stmt = null;
   try{
      //STEP 2: Register JDBC driver
      Class.forName("net.sourceforge.jtds.jdbc.Driver");

      //STEP 3: Open a connection

      System.out.println("Connecting to database...");
      conn = DriverManager.getConnection(DB_URL, USER, PASS);

      //STEP 4: Execute a query
      System.out.println("Creating database...");
      stmt = conn.createStatement();

      String sql = "CREATE DATABASE ";
      stmt.executeUpdate(sql);
      System.out.println("Database created successfully...");
   }catch(SQLException se){
      //Handle errors for JDBC
      se.printStackTrace();
   }catch(Exception e){
      //Handle errors for Class.forName
      e.printStackTrace();
   }finally{
      //finally block used to close resources
      try{
         if(stmt!=null)
            stmt.close();
      }catch(SQLException se2){
      }// nothing we can do
      try{
         if(conn!=null)
            conn.close();
      }catch(SQLException se){
         se.printStackTrace();
      }//end finally try
   }//end try
   System.out.println("Goodbye");
}//end main
}//end JDBCExample
</code></pre>
