?? addfightutil.java
字號(hào):
/**
*
*/
package com.air.backend.util;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.air.exceptions.AirException;
import com.air.form.FightForm;
import com.air.persistence.DataSrcUtil;
import com.air.persistence.IsqlDataSource;
/**
* @author jelly_yang
*
*/
public class AddFightUtil {
private static Log log = LogFactory.getLog(QueryFightUtil.class);
private AddFightUtil() {
// TODO Auto-generated constructor stub
}
public static class AddFightUtilHolder{
static AddFightUtil addFightUtil = new AddFightUtil();
}
public static AddFightUtil getInstance(){
return AddFightUtilHolder.addFightUtil;
}
public boolean addFight(FightForm fightForm)throws AirException{
int result = 0;
String sSql = "insert into fights(fight_name,fight_no,leave_city,arrive_city,leave_time,arrive_time," +
"price,fuel_rate,build_rate,leave_date,special_num,economic_num,business_num,head_num) " +
" values('"+fightForm.getFightName()+"','"+fightForm.getFightNo()+"','"+
fightForm.getLeaveCity()+"','"+fightForm.getArriveCity()+"','"+fightForm.getLeaveTime()+"','"+
fightForm.getArriveTime()+"',"+Double.parseDouble(fightForm.getPrice())+","+Double.parseDouble(fightForm.getFuelRate())+","+
Double.parseDouble(fightForm.getBuildRate())+",'"+fightForm.getLeaveDate()+"',"+
Integer.parseInt(fightForm.getSpecialNum())+","+Integer.parseInt(fightForm.getEconomicNum())+","+
Integer.parseInt(fightForm.getBusinessNum())+","+Integer.parseInt(fightForm.getHeadNum())+")";
IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
Connection conn = null;
log.debug("retrieveFight() -- sSql["+ sSql+ "]");
try
{
conn = src.getConnection();
Statement stmt = conn.createStatement();
result = src.executeUpdate(stmt, sSql);
}
catch(SQLException se)
{
log.error("retrieveFight() caught SQLException: " + se);
}
catch(Exception ex)
{
log.error("retrieveFight() caught Exception: " + ex);
}
finally
{
src.closeConn(conn);
}
if(result==0){
return false;
}
return true;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -