这种错误用金山词霸翻译看看 exception java.sql.SQLException is never thrown in body of corresponding try statement SQLException 永远都不会抛出variable stmt might not have been initialized 变量没有初始化 public void execute(String SQLCommand){ url+=dbName; Connection con; Statement stmt; 改为 public void execute(String SQLCommand){ url+=dbName; Connection con=null; Statement stmt=null;
public static Class forName(String className)
throws ClassNotFoundException {
}
它只可能会抛出ClassNotFoundException,而不会抛出SQLException,所以编译你都通不过!只需要捕获ClassNotFoundException就可以了!2、你的con及stmt在声明的只是简单的
Connection con;
只不过声明了一个变量,它实际上并没有被指向一个类,所以报错,
但你的con或stmt并不一定可以成功指向一个类,
如果这样的话就会产生错误了。
exception java.sql.SQLException is never thrown in body of corresponding try statement
SQLException 永远都不会抛出variable stmt might not have been initialized
变量没有初始化
public void execute(String SQLCommand){
url+=dbName;
Connection con;
Statement stmt;
改为
public void execute(String SQLCommand){
url+=dbName;
Connection con=null;
Statement stmt=null;