?? jdbcfacade.java
字號(hào):
/*
* Created on 2007-05-31
* Last modified on 2007-05-31
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.passport.conn;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import com.yeqiangwei.util.Validator;
public class JDBCFacade {
private static final Logger logger = Logger.getLogger(JDBCFacade.class);
private PreparedStatement preparedStatement = null;
private ResultSet resultSet = null;
public void closeAll(){
ConnectionManager.close(resultSet);
ConnectionManager.close(preparedStatement);
ConnectionManager.closeConnection();
}
public boolean next() throws SQLException{
return resultSet.next();
}
public void setString(int i, String value) throws SQLException{
preparedStatement.setString(i,value);
}
public String getString(int i) throws SQLException{
return this.getResultSet().getString(i);
}
public String getString(String string) throws SQLException {
return this.getResultSet().getString(string);
}
public void setInt(int i, int value) throws SQLException{
preparedStatement.setInt(i,value);
}
public int getInt(String s) throws SQLException{
return this.getResultSet().getInt(s);
}
public int getInt(int i) throws SQLException{
return this.getResultSet().getInt(i);
}
public void setLong(int i, long value) throws SQLException{
preparedStatement.setLong(i,value);
}
public long getLong(int i) throws SQLException{
return this.getResultSet().getLong(i);
}
public void executeUpdate() throws SQLException{
preparedStatement.executeUpdate();
}
public PreparedStatement getPreparedStatement() {
return preparedStatement;
}
public void setPreparedStatement(PreparedStatement preparedStatement) {
this.preparedStatement = preparedStatement;
}
public void preparedStatementInstance(String sql) throws SQLException {
Connection conn = ConnectionManager.currentConnection();
if(!Validator.isEmpty(conn)){
preparedStatement = conn.prepareStatement(sql);
}else{
logger.error("數(shù)據(jù)庫鏈接未初始化!");
}
}
public void executeQuery() throws SQLException{
this.resultSet = preparedStatement.executeQuery();
}
public void executeQuery(String sql) throws SQLException{
this.resultSet = preparedStatement.executeQuery(sql);
}
public ResultSet getResultSet() throws SQLException {
return this.resultSet;
}
public void setResultSet(ResultSet object) {
this.resultSet = object;
}
public byte getByte(String s) throws SQLException{
return this.getResultSet().getByte(s);
}
public byte getByte(int i) throws SQLException{
return this.getResultSet().getByte(i);
}
public void setByte(int i, byte value) throws SQLException{
preparedStatement.setByte(i,value);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -