📄 specdatedao.java
字号:
package com.jasson.business.system;
/**
* <p>Title: SpecDateDAO</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 SpecDateDAO {
private String SpecDate;
private String Time1;
private String Time2;
private String Time3;
private String Time4;
public SpecDateDAO( String SpecDate, String Time1, String Time2, String Time3, String Time4 ){
this.SpecDate = SpecDate;
this.Time1 = Time1;
this.Time2 = Time2;
this.Time3 = Time3;
this.Time4 = Time4;
}
public SpecDateDAO() {
}
public String getSpecDate(){
return SpecDate;
}
public void setSpecDate(String SpecDate){
this.SpecDate = SpecDate;
}
public String getTime1(){
return Time1;
}
public void setTime1(String Time1){
this.Time1 = Time1;
}
public String getTime2(){
return Time2;
}
public void setTime2(String Time2){
this.Time2 = Time2;
}
public String getTime3(){
return Time3;
}
public void setTime3(String Time3){
this.Time3 = Time3;
}
public String getTime4(){
return Time4;
}
public void setTime4(String Time4){
this.Time4 = Time4;
}
public static SpecDateDAO find(int SpecDate){
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
SpecDateDAO result = null;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select SpecDate, Time1, Time2, Time3, Time4 from TSpecDate where SpecDate = ?");
ps.setInt(1, SpecDate);
rs = ps.executeQuery();
if (rs.next()) {
result = new SpecDateDAO( ExStr.dbDecode(rs.getString(1)), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)), ExStr.dbDecode(rs.getString(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 SpecDateDAO[] findAll() {
ExtendString ExStr = new ExtendString();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
SpecDateDAO result = null;
Collection results = new ArrayList();
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
ps = con.prepareStatement("select SpecDate, Time1, Time2, Time3, Time4 from TSpecDate");
rs = ps.executeQuery();
while (rs.next()) {
result = new SpecDateDAO( ExStr.dbDecode(rs.getString(1)), ExStr.dbDecode(rs.getString(2)), ExStr.dbDecode(rs.getString(3)), ExStr.dbDecode(rs.getString(4)), ExStr.dbDecode(rs.getString(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 (SpecDateDAO[])results.toArray(new SpecDateDAO[0]);
}
public long insert() {
Connection con = null;
PreparedStatement ps = null;
long lngSQLReturn = -1;
long lngReturn = -1;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("insert into TSpecDate ( SpecDate, Time1, Time2, Time3, Time4) values ( ?, ?, ?, ?, ?)");
ps.setString(1, getSpecDate());
ps.setString(2, getTime1());
ps.setString(3, getTime2());
ps.setString(4, getTime3());
ps.setString(5, getTime4());
lngSQLReturn = ps.executeUpdate();
lngReturn = lngSQLReturn;
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 lngReturn;
}
public boolean delete(int SpecDate) {
Connection con = null;
PreparedStatement ps = null;
boolean blnReturn = false;
try {
DbConn dbConn = new DbConn();
con = dbConn.getConnection();
if (con != null) {
ps = con.prepareStatement("delete TSpecDate where SpecDate = ?");
ps.setInt(1, SpecDate);
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 TSpecDate set SpecDate = ?, Time1 = ?, Time2 = ?, Time3 = ?, Time4 = ? where SpecDate = ?");
////todo:where
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -