📄 billitemdco.java
字号:
/*
* 创建日期 2007-5-20
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package bill.dco;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import bill.vo.BillItemVo;
import util.DBConn;
/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class BillItemDCO {
public String getBillItemId() {
String billItemId = "";
//查询语句
String sql = " select table_bill_item.nextval as bill_item_id from dual ";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
//得到连接
conn = DBConn.getDBConn();
pstmt = conn.prepareStatement(sql);
//执行查询
rs = pstmt.executeQuery();
//得到查询结果
if (rs.next()) {
billItemId = rs.getString("bill_item_id");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {//关闭连接
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
//返回id
return billItemId;
}
public int insertBillItem(BillItemVo billItemVo) {
int flag = 0;
String sql = " insert into table_bill_item(bill_id,dept_id,bill_item_id,bill_item_expense)values(1000,2,bill_item_seq.nextval,2000) ";
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = DBConn.getDBConn();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(sql);
flag = pstmt.executeUpdate();
conn.commit();
} catch (SQLException e) {
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
if (conn != null) {
conn.setAutoCommit(true);
conn.close();
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
return flag;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -