?? carddao.java~14~
字號:
package com.jbaptech.accp.netbar.server.dao;
import com.jbaptech.accp.netbar.server.entity.Card;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.SQLException;
/**
*
* <p>Title: com.jbaptech.accp.netbar.server.dao.CardDAO</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: 北京阿博泰克北大青鳥信息技術(shù)有限公司</p>
*
* @author luohao
* @version 1.0
*/
public class CardDAO {
public CardDAO() {
}
public boolean cardIsValid(Card card) {
boolean cardIsValid = false;
Connection dbConnection = null;
PreparedStatement pStatement = null;
ResultSet res = null;
try {
dbConnection = ConnectionManager.getConnction();
// 查詢數(shù)據(jù)SQL語句
String strSql = "select * from card where id='" + card.getId()
+ "' and password ='" + card.getPassword() + "'";
if (dbConnection != null) {
System.out.println(dbConnection != null);
}
//查詢操作
pStatement = dbConnection.prepareStatement(strSql);
res = pStatement.executeQuery();
if (res.next()) {
cardIsValid = true;
}
}catch (SQLException sqlE) {
sqlE.printStackTrace();
}
finally {
ConnectionManager.closeResultSet(res);
ConnectionManager.closeStatement(pStatement);
ConnectionManager.closeConnection(dbConnection);
}
return cardIsValid;
}
public boolean cardIsHaveBalance(Card card) {
boolean haveBalance = false;
Connection dbConnection = null;
PreparedStatement pStatement = null;
ResultSet res = null;
try {
dbConnection = ConnectionManager.getConnction();
// 查詢數(shù)據(jù)SQL語句
String strSql = "select * from card where id='" + card.getId()
+ "' and password ='" + card.getPassword() + "'";
if (dbConnection != null) {
System.out.println(dbConnection != null);
}
//查詢操作
pStatement = dbConnection.prepareStatement(strSql);
res = pStatement.executeQuery();
if (res.next()) {
int balance = res.getInt("balance");
if(balance>=2)
haveBalance = true;
}
}catch (SQLException sqlE) {
sqlE.printStackTrace();
}
finally {
ConnectionManager.closeResultSet(res);
ConnectionManager.closeStatement(pStatement);
ConnectionManager.closeConnection(dbConnection);
}
return haveBalance;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -