⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addfightutil.java

📁 主要是航空预订系统
💻 JAVA
字号:
/**
 * 
 */
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;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -