我正在尝试在 NetBeans 上操作 Apache Derby DB,但连接起来很困难。
它看起来很简单,但它就是无法连接。
请帮忙。提前致谢!
import java.sql.*;
public class JDBCtutorial {
private static String tableName = "Diseases";
private static Connection conn = null;
private static Statement stmt = null;
public static void createConnection() {
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
} catch(ClassNotFoundException cnfe) {
System.out.println(cnfe);
}
try {
conn = DriverManager.getConnection("jdbc:derby://localhost:1527/DBName", "user", "password");
} catch (Exception e) {
System.out.println("Cannot connect. . .");
}
}
public static void main(String[] args) {
createConnection();
}
}