📄 lian.java~5~
字号:
package accp.gq.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.*;
/**
* <p>Title: 修改密码</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author 郭庆
* @version 1.0
*/
public class Lian {
public Lian() {
super();
}
public Connection getcon() {
Connection con = null;
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
try {
con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test",
"sa", "");
} catch (SQLException ex1) {
ex1.printStackTrace();
}
return con;
}
public boolean select(Frame1 frm) {
Connection con = this.getcon();
PreparedStatement pre = null;
ResultSet res = null;
String a = frm.txtid.getText();
String b = frm.txtoldpassword.getText();
String sql = "select * UserInfo where LoginName=? and PassWord=?";
try {
pre = con.prepareStatement(sql);
pre.setString(1, a);
pre.setString(2, b);
res = pre.executeQuery();
if (res.next()) {
return true;
}
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
res.close();
pre.close();
con.close();
} catch (SQLException ex1) {
ex1.printStackTrace();
}
}
return false;
}
public boolean update(Frame1 frm) {
Connection con = this.getcon();
PreparedStatement pre = null;
ResultSet res = null;
String a = frm.txtid.getText();
String b = frm.txtnewpassword.getText();
String sql = "update UserInfo set PassWord=? where LoginName=?";
try {
pre = con.prepareStatement(sql);
pre.setString(1, b);
pre.setString(2, a);
res = pre.executeQuery();
if (res.next()) {
return true;
}
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
res.close();
pre.close();
con.close();
} catch (SQLException ex1) {
ex1.printStackTrace();
}
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -