aspose file tools
The moose likes JDBC and the fly likes Class.forName(String class) not in jdk1.4? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Class.forName(String class) not in jdk1.4?" Watch "Class.forName(String class) not in jdk1.4?" New topic
Author

Class.forName(String class) not in jdk1.4?

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hello world,
I am trying to connect to a Microsoft Access Data base using the below syntax.
The problem is it works fine with jdk1.3 but it gives a compilation error with jdk1.4.
Could you please let me know what I have to do to overcome this.
A correct code would be much appriciated.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
The error is this ;
stockIT.java [315:1] No method found matching forName(String)
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
stockIT.java [352:1] No method found matching forName(String)
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
Thanks


SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Kevin Mukhar
Ranch Hand

Joined: Nov 28, 2000
Posts: 83
Originally posted by ransika desilva:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
The error is this ;
stockIT.java [315:1] No method found matching forName(String)
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
stockIT.java [352:1] No method found matching forName(String)
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
Thanks

All questions dealing with the API can most easily be answered by consulting the API documentation. Not sure why you would be getting that error message, because the API docs (http://java.sun.com/j2se/1.4.2/docs/api/index.html) for the class Class do indicate that the forName(String) method still exists in JDK 1.4.2.
Since this is a compilation error, I would suspect that the compiler cannot find the library that contains the java.lang classes. To check that, try using some of the other java.lang classes and see if the compiler can find them.
Another possibility is that at sometime you created a class named Class without the forName(String) method, and that new Class overrides the java.lang.Class. To check that, use the fully qualified name in your code.
 
jQuery in Action, 2nd edition
 
subject: Class.forName(String class) not in jdk1.4?
 
Similar Threads
Class.forName error
how to connect java with oracle rdb
Connecting to remote database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") not working !
Why do we do Class.forName(....) ?