課程
/后端開(kāi)發(fā)
/Java
/使用JSP+Servlet技術(shù)生成報(bào)表
不給過(guò)程 倒是貼出來(lái)啊 有其中一個(gè)也行啊。。。
2015-06-02
源自:使用JSP+Servlet技術(shù)生成報(bào)表 3-2
正在回答
package service;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import beans.Profit;
import jdbc.JdbcConn;
public class Service {
private Connection dbConnection;
private Statement st,st1,st2;
private ResultSet rs,rs1,rs2;
private String sql;
@SuppressWarnings("rawtypes")
private List list;
private Profit profit;
@SuppressWarnings({ "rawtypes", "unchecked" })
public List getProfit(){
list=new ArrayList();
dbConnection=JdbcConn.getConnection();
try {
st=dbConnection.createStatement();
st1=dbConnection.createStatement();
st2=dbConnection.createStatement();
sql="select g.goods_name goodsName,g.selling_price selling,g.cost_price costPrice, g.goods_id goodsId from goodslist g,trading_information t where t.trading_goods_id=g.goods_id group by g.goods_name,g.selling_price,g.cost_price, g.goods_id";
rs=st.executeQuery(sql);
int temp;
while(rs.next()){
profit=new Profit();
profit.setGoodsName(rs.getString("goodsName"));
profit.setSellingPrice(rs.getInt("selling"));
profit.setCostPrice(rs.getInt("costPrice"));
profit.setGoodsId(rs.getInt("goodsId"));
temp=0;
temp=profit.getSellingPrice()-profit.getCostPrice();
sql="select sum(t.trading_number)sumNum from trading_information t where t.trading_goods_id="+profit.getGoodsId();
rs1=st1.executeQuery(sql);
while(rs1.next()){
profit.setTradingNum(rs1.getInt("sumNum"));
}
profit.setProfit(temp*profit.getTradingNum());
sql="select count(t.trading_id)times from trading_information t where trading_goods_id="+profit.getGoodsId();
rs2=st2.executeQuery(sql);
while(rs2.next()){
profit.setTimes(rs2.getInt("times"));
list.add(profit);
System.out.println(list);
} catch (SQLException e) {
e.printStackTrace();
return list;
/**
* 測(cè)試
*/
// public static void main(String[] args) {
// Service service = new Service();
// service.getProfit();
// }
舉報(bào)
Java Web案例課程,教你如何使用JSP+Servlet技術(shù)生成報(bào)表
2 回答課程的源碼去哪了???
2 回答這些項(xiàng)目需要的圖片在哪啊?
2 回答源碼分享?。。?!
1 回答有源代碼嗎?
5 回答誰(shuí)有源碼啊
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢(xún)優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2015-12-20
package service;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import beans.Profit;
import jdbc.JdbcConn;
public class Service {
private Connection dbConnection;
private Statement st,st1,st2;
private ResultSet rs,rs1,rs2;
private String sql;
@SuppressWarnings("rawtypes")
private List list;
private Profit profit;
@SuppressWarnings({ "rawtypes", "unchecked" })
public List getProfit(){
list=new ArrayList();
dbConnection=JdbcConn.getConnection();
try {
st=dbConnection.createStatement();
st1=dbConnection.createStatement();
st2=dbConnection.createStatement();
sql="select g.goods_name goodsName,g.selling_price selling,g.cost_price costPrice, g.goods_id goodsId from goodslist g,trading_information t where t.trading_goods_id=g.goods_id group by g.goods_name,g.selling_price,g.cost_price, g.goods_id";
rs=st.executeQuery(sql);
int temp;
while(rs.next()){
profit=new Profit();
profit.setGoodsName(rs.getString("goodsName"));
profit.setSellingPrice(rs.getInt("selling"));
profit.setCostPrice(rs.getInt("costPrice"));
profit.setGoodsId(rs.getInt("goodsId"));
temp=0;
temp=profit.getSellingPrice()-profit.getCostPrice();
sql="select sum(t.trading_number)sumNum from trading_information t where t.trading_goods_id="+profit.getGoodsId();
rs1=st1.executeQuery(sql);
while(rs1.next()){
profit.setTradingNum(rs1.getInt("sumNum"));
}
profit.setProfit(temp*profit.getTradingNum());
sql="select count(t.trading_id)times from trading_information t where trading_goods_id="+profit.getGoodsId();
rs2=st2.executeQuery(sql);
while(rs2.next()){
profit.setTimes(rs2.getInt("times"));
}
list.add(profit);
System.out.println(list);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
/**
* 測(cè)試
*/
// public static void main(String[] args) {
// Service service = new Service();
// service.getProfit();
// }
}