gpt4 book ai didi

java - SQLException错误

转载 作者:行者123 更新时间:2023-12-01 13:18:10 24 4
gpt4 key购买 nike

我已经建立了 ODBC 连接,但它仍然无法工作。

请一路指导,谢谢

下面是我的代码:

<小时/>
package payrollapplication;
import java.sql.*;
import javax.swing.*;


/**
*
* @author Admin
*/
public class DBConnection {
boolean ISCONN=false;
boolean ISSUCC=false;
boolean ISCONFIRM=false;


private String NextNumber="";

Connection Conn;
PreparedStatement ps;
ResultSet rs;
Statement st;
/** Creates a new instance of DBConnection */
public DBConnection()
{
ConnectToDatabase();
}

public boolean ConnectToDatabase()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Conn=DriverManager.getConnection("jdbc:odbc:Employee");
ISCONN=true;

}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex,"CONNECTION",JOptionPane.ERROR_MESSAGE);
}

return ISCONN;
}

public String getNumber()
{
return NextNumber;
}

public void setNumber(String NXTNO)
{
int n;
n=Integer.parseInt(NXTNO)+1;


NextNumber="" + n + "";
}

public void LoadEmpNo()
{
String SQLMax;
try
{
SQLMax="SELECT Max(Emp_No) FROM MS_Employee";
st=Conn.createStatement();
rs=st.executeQuery(SQLMax);

if (rs.next())
{
setNumber(rs.getString(1));

}

}
catch(Exception ex)
{

}
}

public boolean FindEmployee(String SQLFIND)
{
try
{
st=Conn.createStatement();
rs=st.executeQuery(SQLFIND);

if (rs.next())
{
ISCONFIRM=true;
}
else
{
ISCONFIRM=false;
}

}
catch(Exception ex)
{
ISCONFIRM=false;
}
return ISCONFIRM;
}

public boolean Add_Update_EmpMaster(String SQL,boolean ISADD_OR_UPDATE)
{
try
{
ps=Conn.prepareStatement(SQL);
ps.executeUpdate();
ISSUCC=true;
}
catch(Exception ex)
{
// JOptionPane.showMessageDialog(null,ex,"CONNECTION",JOptionPane.ERROR_MESSAGE);
ISSUCC=false;
}

return ISSUCC;
}

}

这是弹出的错误:

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

最佳答案

如果您的 Java 是 64 位,您将需要 64 位驱动程序。

关于java - SQLException错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22294443/

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