• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kevin Mukhar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic