下面的代码:
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)
这是如何引起的,我该如何解决?