相关代码如下:(其中num设置为text和ntext或者varchar和nvarchar问题依然存在)希望懂的大哥大姐帮帮忙,我QQ897830717:谢谢了。
class ActionHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String str1,str2,sqlStr;
Object obj = e.getSource();
//获得文本框和密码框的数据
str1 = jtflduser.getText().trim();
str2 = new String(jtpwdfld.getPassword()).trim();
try{
//单击[确定]按钮
if(obj.equals(OK_btn)){
if(obj.equals(""))
{
JOptionPane.showMessageDialog(frame,"用户不能为空!");
return;
}
//创建数据库连接
Jdbcfile conn = new Jdbcfile();
//产生登入SQL语句
sqlStr = "select * from Admin where num = '" + str1 + "' and password = '" + str2 + "' ";
ResultSet result = conn.executeQuery(sqlStr);
if(result.next())
class ActionHandler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String str1,str2,sqlStr;
Object obj = e.getSource();
//获得文本框和密码框的数据
str1 = jtflduser.getText().trim();
str2 = new String(jtpwdfld.getPassword()).trim();
try{
//单击[确定]按钮
if(obj.equals(OK_btn)){
if(obj.equals(""))
{
JOptionPane.showMessageDialog(frame,"用户不能为空!");
return;
}
//创建数据库连接
Jdbcfile conn = new Jdbcfile();
//产生登入SQL语句
sqlStr = "select * from Admin where num = '" + str1 + "' and password = '" + str2 + "' ";
ResultSet result = conn.executeQuery(sqlStr);
if(result.next())
记得要导入数据库驱动包