0
try {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
   System.out.println("Error loading driver " + e);
}

但是netbeans给出的错误是

未报告的异常 java.lang.ClassNotFoundException; 必须被捕获或声明为抛出
,另外两个错误在 try 块和 catch 块的开头,即

类型的非法开始所以可能是什么问题请指导我有关 tis

4

2 回答 2

0

There are lot more consideration needed to your code rather than just putting in Class.forName. You may refer to example below as a start up:

JdbcOdbcDriver

于 2012-06-06T10:31:52.250 回答
0

您的代码的其他部分可能有问题。请仔细检查您的代码。

public class Sample
{
  public static void main(String []args)
   {
     try {
       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     }catch(ClassNotFoundException e){
       System.out.println("Error loading driver "+e);
     }
   }
}
于 2012-06-06T04:22:36.750 回答