我正在实施一个简单的教程
使用 NetBeans 7 IDE 将 java 程序连接到 java DB。这是教程的链接。
http://www.homeandlearn.co.uk/java/connect_to_a_database_using_java_code.html
但是当我运行该项目时,NetBeans 给了我以下错误:
run:
java.lang.VerifyError: Constructor must call super() or this() before return in method database_console.DBConnect.<init>()V at offset 0
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:492)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:484)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 12 seconds)
下面是项目的代码
package database_console;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public static void main(String[] args) {
try {
String host = "jdbc:derby://localhost:1527/Employees";
String uName="faisal";
String uPass="password";
Connection con=DriverManager.getConnection(host, uName, uPass);
}
catch ( SQLException err ) {
System.out.println( err.getMessage( ) );
}
}
}
解决此问题的任何可用建议