📄 docspeeddao.java
字号:
package com.jasson.business.system;
/**
* <p>Title: DocSpeedDAO</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003,by wingroup</p>
* <p>Company: wingroup</p>
* @author jarrywen
* @version 1.0
*/
import java.io.*;
import java.sql.*;
import java.util.Properties;
import java.util.Collection;
import java.util.ArrayList;
import com.jasson.business.common.DbConn;
import com.jasson.common.*;
public class DocSpeedDAO {
private int SpeedID;
private String SpeedNO;
private String SpeedName;
private String ActiveTag;
private int SpeedDays;
public DocSpeedDAO( int SpeedID, String SpeedNO, String SpeedName, String ActiveTag, int SpeedDays ){
this.SpeedID = SpeedID;
this.SpeedNO = SpeedNO;
this.SpeedName = SpeedName;
this.ActiveTag = ActiveTag;
this.SpeedDays = SpeedDays;
}
public DocSpeedDAO() {
}
public int getSpeedID(){
return SpeedID;
}
public void setSpeedID(int SpeedID){
this.SpeedID = SpeedID;
}
public String getSpeedNO(){
return SpeedNO;
}
public void setSpeedNO(String SpeedNO){
this.SpeedNO = SpeedNO;
}
public String getSpeedName(){
return SpeedName;
}
public void setSpeedName(String SpeedName){
this.SpeedName = SpeedName;
}
public String getActiveTag(){
return ActiveTag;
}
public void setActiveTag(String ActiveTag){
this.ActiveTag = "0";
if (ActiveTag != null) {
if (ActiveTag.equals("1")) {
this.ActiveTag = ActiveTag;
}
}
}
public int getSpeedDays(){
return SpeedDays;
}
public void setSpeedDays(int SpeedDays){
this.SpeedDays = SpeedDays;
}
public static DocSpeedDAO find(int SpeedID){
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocSpeedDAO result = null;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select SpeedID, SpeedNO, SpeedName, ActiveTag, SpeedDays from TSpeed where SpeedID = ?");
ps.setInt(1, SpeedID);
rs = ps.executeQuery();
if (rs.next()) {
result = new DocSpeedDAO( rs.getInt(1), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)), rs.getInt(5));
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return result;
}
public static DocSpeedDAO[] findSelectAll() {
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocSpeedDAO result = null;
Collection results = new ArrayList();
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select SpeedID, SpeedNO, SpeedName, ActiveTag, SpeedDays from TSpeed");
rs = ps.executeQuery();
while (rs.next()) {
result = new DocSpeedDAO( rs.getInt(1), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)), rs.getInt(5));
results.add(result);
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return (DocSpeedDAO[])results.toArray(new DocSpeedDAO[0]);
}
public static DocSpeedDAO[] findAll() {
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
DocSpeedDAO result = null;
Collection results = new ArrayList();
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select SpeedID, SpeedNO, SpeedName, ActiveTag, SpeedDays from TSpeed where ActiveTag = 1");
rs = ps.executeQuery();
while (rs.next()) {
result = new DocSpeedDAO( rs.getInt(1), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)), rs.getInt(5));
results.add(result);
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return (DocSpeedDAO[])results.toArray(new DocSpeedDAO[0]);
}
public long insert() {
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
long lngSQLReturn = -1;
long lngReturn = -1;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("select MAX(SpeedID) from TSpeed");
rs = ps.executeQuery();
if (rs.next()){
int maxSpeedID = rs.getInt(1)+1;
this.setSpeedID(maxSpeedID);
}
ps = con.prepareStatement("insert into TSpeed ( SpeedID, SpeedNO, SpeedName, ActiveTag, SpeedDays) values ( ?, ?, ?, ?, ?)");
ps.setInt(1, getSpeedID());
ps.setString(2, getSpeedNO());
ps.setString(3, getSpeedName());
ps.setString(4, getActiveTag());
ps.setInt(5, getSpeedDays());
lngSQLReturn = ps.executeUpdate();
lngReturn = lngSQLReturn;
}
rs.close();
rs = null;
ps.close();
ps = null;
con.close();
con = null;
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqlException) {
}
rs = null;
}
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return lngReturn;
}
public boolean delete(int SpeedID) {
Connection con = null;
PreparedStatement ps = null;
boolean blnReturn = false;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("delete TSpeed where SpeedID = ?");
ps.setInt(1, SpeedID);
blnReturn = (ps.executeUpdate() == 1);
ps.close();
}
con.close();
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return blnReturn;
}
public boolean update() {
Connection con = null;
PreparedStatement ps = null;
boolean blnReturn = false;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("update TSpeed set SpeedID = ?, SpeedNO = ?, SpeedName = ?, ActiveTag = ?, SpeedDays = ? where SpeedID = ?");
ps.setInt(1, getSpeedID());
ps.setString(2, getSpeedNO());
ps.setString(3, getSpeedName());
ps.setString(4, getActiveTag());
ps.setInt(5, getSpeedDays());
ps.setInt(6, getSpeedID());
blnReturn = (ps.executeUpdate() == 1);
ps.close();
}
con.close();
}
catch (SQLException sqlException) {
System.out.println(sqlException.getMessage());
}
finally {
if (ps != null) {
try {
ps.close();
}
catch (SQLException sqlException) {
}
ps = null;
}
if (con != null) {
try {
con.close();
}
catch (SQLException sqlException) {
}
con = null;
}
}
return blnReturn;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -