📄 opersystemdao.java
字号:
//---------------------------------------------------------
// Application: service of System
// Author : eSingle
// File : OpersystemDAO.java
//
// Copyright 2003 landsoft Corp.
// Generated at Wed Nov 26 09:26:02 CST 2003
// created by 曹广鑫
// mailto:bandsoft@163.com
//---------------------------------------------------------
package com.landsoft.service.dao;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import com.landsoft.service.model.*;
import com.landsoft.service.util.CacheManager;
public class OpersystemDAO extends DAO {
public OpersystemDAO(DataSource ds) {
super(ds);
}
public void insert(Opersystem opersystem) throws SQLException {
String sql;
sql = "INSERT INTO opersystem (opersystemcode, opersystemname) VALUES (?, ?)";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = ds.getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, opersystem.getOpersystemcode());
pstmt.setString(2, opersystem.getOpersystemname());
pstmt.executeUpdate();
pstmt.close();
conn.commit();
} catch (SQLException sqle) {
close(rs);
close(pstmt);
rollback(conn);
sqle.printStackTrace();
throw sqle;
} finally {
close(conn);
}
}
public void update(Opersystem opersystem) throws SQLException {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = ds.getConnection();
String sql = "UPDATE opersystem SET opersystemname=? WHERE opersystemcode=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, opersystem.getOpersystemname());
pstmt.setString(2, opersystem.getOpersystemcode());
pstmt.executeUpdate();
close(pstmt);
conn.commit();
} catch (SQLException e) {
close(pstmt);
rollback(conn);
e.printStackTrace();
} finally {
close(conn);
}
}
public void delete(String opersystemcode) throws SQLException {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = ds.getConnection();
String sql = "DELETE FROM opersystem WHERE opersystemcode=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, opersystemcode);
pstmt.executeUpdate();
close(pstmt);
conn.commit();
} catch (SQLException e) {
close(pstmt);
rollback(conn);
e.printStackTrace();
} finally {
close(conn);
}
String[] objKeys = {"Opersystem", String.valueOf(opersystemcode)};
String objKey = CacheManager.createKey(objKeys);
DAOCacheManager.invalidate(objKey);
}
public Opersystem retrieve(String opersystemcode) throws SQLException {
String[] objKeys = {"Opersystem", String.valueOf(opersystemcode)};
String objKey = CacheManager.createKey(objKeys);
Opersystem opersystem = (Opersystem) DAOCacheManager.getCache(objKey);
if (opersystem != null)
return opersystem;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = ds.getConnection();
String sql = "SELECT * FROM opersystem WHERE opersystemcode=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, opersystemcode);
rs = pstmt.executeQuery();
if (rs.next()) {
opersystem = new Opersystem();
opersystem.setOpersystemcode(rs.getString(1));
opersystem.setOpersystemname(rs.getString(2));
populate(opersystem, rs);
}
close(rs);
close(pstmt);
} catch (SQLException e) {
close(rs);
close(pstmt);
rollback(conn);
e.printStackTrace();
} finally {
close(conn);
}
DAOCacheManager.putCache(opersystem, objKey, 1);
return opersystem;
}
public List list() throws SQLException {
String[] objKeys = {"Opersystem", "list"};
String objKey = CacheManager.createKey(objKeys);
ArrayList list = (ArrayList) DAOCacheManager.getCache(objKey);
if (list != null)
return list;
list = new ArrayList();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = ds.getConnection();
String sql = "SELECT opersystemname, opersystemcode FROM opersystem";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()) {
Opersystem opersystem = new Opersystem();
opersystem.setOpersystemname(rs.getString(1));
opersystem.setOpersystemcode(rs.getString(2));
populate(opersystem, rs);
list.add(opersystem);
}
close(rs);
close(pstmt);
} catch (SQLException e) {
close(rs);
close(pstmt);
rollback(conn);
e.printStackTrace();
} finally {
close(conn);
}
DAOCacheManager.putCache(list, objKey, 1);
return list;
}
public List list(int offset, int limit) throws SQLException {
String[] objKeys = {"Opersystem", "list", String.valueOf(offset), String.valueOf(limit)};
String objKey = CacheManager.createKey(objKeys);
ArrayList list = (ArrayList) DAOCacheManager.getCache(objKey);
if (list != null)
return list;
list = new ArrayList();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = ds.getConnection();
String sql = "SELECT opersystemname, opersystemcode FROM opersystem";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(offset > 0) rs.absolute(offset);
int recCount = 0;
while((recCount++ < limit) && rs.next()) {
Opersystem opersystem = new Opersystem();
opersystem.setOpersystemname(rs.getString(1));
opersystem.setOpersystemcode(rs.getString(2));
populate(opersystem, rs);
list.add(opersystem);
}
close(rs);
close(pstmt);
} catch (SQLException e) {
close(rs);
close(pstmt);
rollback(conn);
e.printStackTrace();
} finally {
close(conn);
}
DAOCacheManager.putCache(list, objKey, 1);
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -