62,614
社区成员
发帖
与我相关
我的任务
分享
csmt.execute();
resaultValue = csmt.getString(3);
private Session session;
/**
* 生成单据号
* @param appId 应用程序编号
* @return 返回单据号
*/
public String autoGeneratePtyNO(int appId) {
String resaultValue = "";
Connection conn = this.createConnection();
try
{
conn.setAutoCommit(false);
CallableStatement csmt = conn.prepareCall("{call getdjno(@FAPPID=?, @FDJDATE=?, @outcode=?)}");
Date date= new Date(new java.util.Date().getTime());
csmt.setInt(1, appId);
csmt.setDate(2, date);
csmt.registerOutParameter(3, Types.VARCHAR);
if (csmt.execute()) {
resaultValue = csmt.getString(3);
}
csmt.getMoreResults();
ResultSet rs = csmt.getResultSet();
if (rs.next()) {
resaultValue = rs.getString(1);
}
else {
resaultValue = csmt.getString(3);
}
conn.commit();
}
catch (SQLException se) {
try
{
conn.rollback();
}
catch (Exception ex){
}
finally {
resaultValue = se.getMessage();
}
}
catch (Exception e) {
try
{
conn.rollback();
}
catch (Exception ex){
}
finally {
resaultValue = e.getMessage();
}
}
finally {
try
{
conn.close();
}
catch (Exception e) {
}
}
return resaultValue;
}
/**
* 构造函数
*/
public StoredProceduresBean() {
}
/**
* 取得当前数据库会话
*
* @return
*/
public Connection createConnection() {
if (session == null) {
session = HibernateSessionFactory.getSessionFactory()
.getCurrentSession();
}
return session.connection();
}