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;
}
}
java j2se
最新推荐文章于 2024-11-08 23:31:31 发布