?? sqlservermobiledao.java
?? 中國移動管理系統
?? JAVA
字號:
??
package com.chinamobile.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import com.chinamobile.bean.MobileBean;
import com.chinamobile.bean.OperatorBean;
public class SQLServerMobileDAO implements MobileDAO {
private final String INSERT_AN_MOBILE = "insert into TMobile values(?,?,?,?)";
private final String GET_AN_MOBILE = "select * from TMobile where Mobile_Number=?";
public boolean createMobile(MobileBean mobile) {
Connection conn =null;
PreparedStatement pstmt=null;
boolean tmp=true;
try{
conn=SQLServerDAOFactory.getConnection();
pstmt=conn.prepareStatement(INSERT_AN_MOBILE);
pstmt.setString(1, mobile.getMobile_Number());
pstmt.setString(2, mobile.getMobile_Type());
pstmt.setString(3, mobile.getCard_Number());
pstmt.setString(4, mobile.getIs_Available());
int result=pstmt.executeUpdate();
if(result!=1)
tmp = false;
}catch(SQLException e){
tmp = false;
e.printStackTrace();
}finally{
SQLServerDAOFactory.closeStatement(pstmt);
SQLServerDAOFactory.closeConnection(conn);
}
return tmp;
}
public boolean isExists(MobileBean mobile) {
Connection conn =null;
PreparedStatement pstmt=null;
boolean tmp=true;
try{
conn=SQLServerDAOFactory.getConnection();
pstmt=conn.prepareStatement(GET_AN_MOBILE);
pstmt.setString(1, mobile.getMobile_Number());
ResultSet result=pstmt.executeQuery();
if(result.next()){
tmp = true;
}else{
tmp = false;
}
}catch(SQLException e){
e.printStackTrace();
}finally{
SQLServerDAOFactory.closeStatement(pstmt);
SQLServerDAOFactory.closeConnection(conn);
}
return tmp;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -