在 Java 独立客户端服务器应用程序(使用 Netbeans)中,我使用静态方法连接到 SQL 服务器:但如果我使用第二个连接,则会收到错误消息:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: Utili.StaticConnessione.getConnessione2()Ljava/sql/Connection;
有人能帮我吗?谢谢
public class StaticConnessione {
// first coonection
public static Connection getConnessione1() throws SQLException {
String s = System.getProperty("user.name");
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
return DriverManager.getConnection("jdbc:jtds:sqlserver://localhost;databaseName=FIRST_DB;user=sa; password = abc");
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, e.toString(), "msg", 2);
}
return null;
}
// second connection
public static Connection getConnessione2() throws SQLException {
// first coonection
String s = System.getProperty("user.name");
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
return DriverManager.getConnection("jdbc:jtds:sqlserver://localhost;databaseName=SECOND_DB;user=sa;password = abc");
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, e.toString(), "msg", 2);
}
return null;
}
}