com.j2mvc.framework.dao.callback.CallbackInteger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of j2mvc-framework-app Show documentation
Show all versions of j2mvc-framework-app Show documentation
强烈建议使用J2mvc 2.1以后的版本。
version 2.1.01
1.更换JSON依赖包.
version 2.1.02
1.移除com.j2mvc.StringUtils.getUtf8()方法调用.
更改为getCharset()
version 2.1.03
1.更新JNDI连接设置
version 2.1.04
1.修改works.xml配置url-pkg-prefixes改为pkg
package com.j2mvc.framework.dao.callback;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* 预编译语句返回数值
* @author 杨朔
* 2014年1月13日
*/
public class CallbackInteger extends PreparedStatementCallBack {
private int executeType;
public CallbackInteger(int executeType) {
this.executeType = executeType;
}
@Override
public Integer execute(PreparedStatement pstmt) throws SQLException{
int num = 0;
if(executeType == EXECUTE_UPDATE){
num = pstmt.executeUpdate();
}
if(executeType == EXECUTE_QUERY){
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
num = rs.getInt(1);
}
rs.close();
}
pstmt.close();
return num;
}
}