📄 conditionquery.java
字号:
/*
* Created on 2006-9-23
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.skyhawk.richeng.conditionquery;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import com.skyhawk.db.ConnectionFactory;
import com.skyhawk.db.DatabaseUtils;
import com.skyhawk.richeng.updataplan.DayPlan;
/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class ConditionQuery {
public ArrayList condition(String startime,String endtime,String person,String place,String content,String empid) throws SQLException{
System.out.println("condition"+empid);
Statement stmt = null;
ResultSet rs1 = null;
ArrayList arraylist = new ArrayList();
Connection conn = ConnectionFactory.getConnection();
try {
stmt=conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
if(!startime.equals("")){
String sel="select content,starttime,endtime,person,place,settime,remarker from O_dayplan where starttime<to_date('"+startime+" 23:59:59','yyyy-mm-dd HH24:MI:SS') and starttime>to_date('"+startime+" 00:00:00','yyyy-mm-dd HH24:MI:SS') and empid='"+empid+"'";
try {
System.out.println("=sel="+sel);
stmt.execute(sel);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
else {
String sel2="select content,starttime,endtime,person,place,settime,remarker from o_dayplan where empid='"+empid+"'";
if(!endtime.equals("")){
sel2=sel2+"and endtime='"+endtime+"'";
}
if(!person.equals("")){
sel2=sel2+"and person='"+person+"'";
}
if(!place.equals("")){
sel2=sel2+"and place='"+place+"'";
}
if(!content.equals("")){
sel2=sel2+"and content='"+content+"'";
}
else{
sel2=sel2+"";
}
System.out.println("=sql2="+sel2);
try {
rs1=stmt.executeQuery(sel2);
}
catch (SQLException e1) {
e1.printStackTrace();
}
if(rs1.next()){
try {
while(rs1.next()){
DayPlan dayplan = new DayPlan();
dayplan.setEMPID(empid);
dayplan.setCONTENT(rs1.getString("CONTENT"));
dayplan.setStartTime(dayplan.cutTime(rs1.getString("STARTTIME")));
System.out.println("==="+rs1.getString("STARTTIME"));
dayplan.setENDTIME(dayplan.cutTime(rs1.getString("ENDTIME")));
dayplan.setPERSON(rs1.getString("PERSON"));
dayplan.setPLACE(rs1.getString("PLACE"));
dayplan.setSETTIME(dayplan.cutTime(rs1.getString("SETTIME")));
dayplan.setREMARKER(rs1.getString("REMARKER"));
arraylist.add(dayplan);
}
} catch (SQLException e2) {
e2.printStackTrace();
} finally{
DatabaseUtils coldat =new DatabaseUtils();
DatabaseUtils.closeObject(rs1,stmt,conn);
System.out.println("+++++close+++++");
}
}
else{
Object response = null;
}
}
return arraylist;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -