Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when executing a java program 2

Status
Not open for further replies.

pjeypal

Programmer
Apr 17, 2006
36
US
I am trying to compile this class
Code:
import java.sql.*;  

class JdbcTest1 {  
      
    public static void main (String[] args) {  
        try {  

            // Step 1: Load the JDBC driver.  
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  

            // Step 2: Establish the connection to the database.  
            String url = "jdbc:odbc:data413";  
            Connection conn = DriverManager.getConnection(url,"pilatdba","p1latdba");   
            Thread.currentThread.sleep(2000);
             conn.close();
        } catch (Exception e) {  
            System.err.println("Got an exception! ");  
            System.err.println(e.getMessage());  
        }  
    }  
}
i keep getting this error

C:\>javac JdbcTest.java
JdbcTest.java:14: cannot resolve symbol
symbol : variable currentThread
location: class java.lang.Thread
Thread.currentThread.sleep(2000);
^
1 error
 
Hi

The lang package is by default imported into the class. Therefore the issue is something else. I tried with the import statement but still the same error
 
<code>
Thread.currentThread.sleep(2000);

should be Thread.currentThread().sleep(2000);

</code>
 
Please do not post about the same problem in two posts.

In any case, You do not need to get the current thread, because this call :

Thread.sleep(x);

sleeps the currently executing thread - so the call to currentThread() is superfluous.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
feherke, you don't need to import Thread since it is in the java.lang package whose members are automatically available.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top