- public class Customer {
- /更新序列号使其加1/
- public void sequencePlus(){
- Connection conn=null;
- Statement stmt =null;
- ……//将T_SEQUENCE的序列号当前值加1;
- }
- /获取当前序列号/
- public int getSequenceCurrentVal(){
- Connection conn=null;
- Statement stmt=null;
- ResultSet rset =null;
- ……// 获取当前的序列号值;
- }
- /新增一条Customer记录,自动根据序列号生成主键/
- public void addCustomer(String name) {
- Connection conn=null;
- PreparedStatement stmt = null;
- ResultSet rset=null;
- sequencePlus();// 序列号加1;
- int id = getSequenceCurrentVal(); // 得到当前序列号;
- …….// 将最新序列号作为新的T_Customer记录的主键插入;
- }
- }
复制代码 |