📄 bankaccount.java
字号:
package aa;
import java.io.*;
import java.sql.*;
public class BankAccount {
private String sAccountID="";
private String sPin="";
private boolean AccountValidte;
Connection con = null;
Statement st = null;
ResultSet result = null;
public void setsAccountID(String sAccountID) {
this.sAccountID = sAccountID;
}
public void setsPin(String sPin) {
this.sPin = sPin;
}
public String getsAccountID() {
return this.sAccountID;
}
public String getsPin() {
return sPin;
}
public BankAccount() throws ClassNotFoundException {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
public boolean AccountValidate () {
boolean validate = false;
String sPinNo = "";
try {
sAccountID = getsAccountID();
sPin = getsPin();
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test","sa","");
String strQuery = "select sPin from Info where sAccount="+sAccountID+"";
st = con.createStatement();
ResultSet result = st.executeQuery(strQuery);
while(result.next()) {
sPinNo = result.getString(1);
}
sPinNo = sPinNo.trim();
sPin = sPin.trim();
if(sPinNo.equals(sPin))
{
validate = true;
}
} catch(Exception e) {
e.printStackTrace();
}
return validate;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -