java j2se

package com.neldtv.club.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.neldtv.club.entity.ShuiDianMeiWuTingFei;

/*
 * select f.universal_fee,h.area ,f.standard_no, f.fee_name, b.start_num, b.end_num,  (b.end_num - b.start_num ),b.money, f.fee_kind,f.universal_fee 
from house_info h, bill_info b, fee_type f 
where  h.house_no = b.house_no
and    b.fee_item =f.id 
and  b.fee_date like '2011-03%' and b.house_no= '01-08-03-02'
order by f.standard_no;
 * 
 */
public class JDBCDao {

	public static ShuiDianMeiWuTingFei getShuiFei(Date date, String houseNo,
			String standardNo) {

		ShuiDianMeiWuTingFei sdmwtf = new ShuiDianMeiWuTingFei();

		String stringDate = new SimpleDateFormat("yyyy-MM").format(date);

		Object[] ob = new Object[5];
		Connection conn = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;

		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(
					"jdbc:mysql://61.187.84.71:3306/iptvdb", "root", "123456");
			stmt = conn
					.prepareStatement("select f.standard_no, f.fee_name, b.start_num, b.end_num,  (b.end_num - b.start_num ) as totalamount,b.money,f.universal_fee,h.area"
							+ " from HOUSE_INFO h, BILL_INFO b, FEE_TYPE f "
							+ " where  h.house_no = b.house_no "
							+ " and    b.fee_item =f.id"
							+ " and    b.fee_date like '"
							+ stringDate
							+ "%'"
							+ " and    b.house_no= '"
							+ houseNo
							+ "'"
							+ " and    f.standard_no= '" + standardNo + "'");
			// stmt.setInt(1, 10);
			rs = stmt.executeQuery();
			while (rs.next()) {
				sdmwtf.setStandardNo(rs.getString("standard_no"));
				sdmwtf.setFeeName(rs.getString("fee_name"));
				sdmwtf.setStartNum(rs.getString("start_num"));
				sdmwtf.setEndNum(rs.getString("end_num"));
				sdmwtf.setTotalAmount(rs.getString("totalamount"));
				sdmwtf.setMoney(rs.getString("money"));
				sdmwtf.setUniversalFee(rs.getString("universal_fee"));
				sdmwtf.setArea(rs.getString("area"));

				System.out.println(rs.getString("standard_no"));
				System.out.println(rs.getString("fee_name"));
				System.out.println(rs.getString("start_num"));
				System.out.println(rs.getString("end_num"));
				System.out.println(rs.getString("totalamount"));
				System.out.println(rs.getString("money"));
				System.out.println(rs.getString("universal_fee"));
				System.out.println(rs.getString("area"));
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			if (rs != null) {
			}
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
			if (stmt != null)
				try {
					stmt.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			if (conn != null)
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
		}
		return sdmwtf;
	}

}


12-14 435
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值