gpt4 book ai didi

java.sql.SQLException : [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

转载 作者:行者123 更新时间:2023-12-02 07:02:55 24 4
gpt4 key购买 nike

下面的代码:

public void insertNewStudent(int id, String pass, String fname, String lname, String   street, String city, String state, int Zip, String Email, double GPA) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:RegistrationDB", "", "");
String query = "INSERT INTO Students (ID, Password, FirstName, LastName, Street, City, State, Zip, EMail, GPA)" + "VALUES (?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps = conn.prepareStatement(query);
ps.setInt(1, id);
ps.setString(2, pass);
ps.setString(3, fname);
ps.setString(4, lname);
ps.setString(5, street);
ps.setString(6, city);
ps.setString(7, state);
ps.setInt(8, Zip);
ps.setString(9, Email);
ps.setDouble(10, GPA);
ps.executeUpdate();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

抛出以下异常:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an     architecture mismatch between the Driver and Application
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3072)
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
java.sql.DriverManager.getConnection(DriverManager.java:579)
java.sql.DriverManager.getConnection(DriverManager.java:221)
business.studentDB.insertNewStudent(studentDB.java:53)
controller.registercontrol.doPost(registercontrol.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

这是怎么造成的,如何解决?

最佳答案

因此,更改异常处理发现了真正的问题,这似乎是:

The specified DSN contains an architecture mismatch between the Driver and Application

这基本上表明您拥有针对 64 位访问的 32 位驱动程序或其他方式。您需要找出哪一种并使用正确的。有关此问题的更多信息,请访问 this thread ,例如。

关于java.sql.SQLException : [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16425063/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com