请问有谁做过用java做数据统计 不是股票,只是一个mis系统的统计,其他部分都是用pb,但是这一部分享用java做,这样就可以随时在网上查询了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jsp+servlet or applet ??? 都可以呀,不过我觉得用applet+servelet可能更好些 我以前做过一个统计方面的servlet+jsp,源码是无法给你的,因为不归我所有,虽然水平不高可公司认为这也是归他的不是我个人的:)。如果有兴趣,愿意与你讨论这方面的问题。 [email protected] 我是刚接触java,所以也不知道改用什么好,大家提提意见吧,该用什么呢?用javabeans可以吗?感谢sharetop,以后要多多像你请教了,先谢过了! 再问一下,用oracle的webserver+applet可以做出来吗?网上关于webserver的资料好少呀! 用APPLET,很好做,下面的是俺做项目时做过的,欢迎批评指正!!!!!import java.awt.*;import java.awt.event.*;import java.applet.*;//import java.awt.color.*;public class tour extends Applet{ boolean isStandalone = false; /************** 矩形外框的长宽值 ****************/ public static final int Rect_Width = 440; //框宽 public static final int Rect_Height = 305; //框高 public static final int Mon_Num = 12; //显示的月份数 public static final int Zhu_Width = 15; //柱宽 int x[] = new int[Mon_Num], // x[] 和 y[][] 是每个柱的左上角坐标(因为包含“海外”情况,所以x只有一个值,y有两个值) y[][] = new int[Mon_Num][2], zhuHeight[][] = new int[Mon_Num][2], //每个柱的柱高 par[][] = new int[Mon_Num][2], //参数数组变量 max = 0, //参数中的最大值 row = 0, //行数 rowHeight = 0, //行高像素值 rowHeightVal = 0, //行高指标值 xPoint[] = new int[Mon_Num], // xPoint[] 和 yPoint[] 是画折线需用到的点坐标值 yPoint[] = new int[Mon_Num], changNum = -1; boolean changFlag = false; String appletTitle = null, //applet标题 label1 = null, label2 = null, label3 = null, label4 = null; Color zhuColor[] = new Color[Mon_Num], zhuColorDark[] = new Color[Mon_Num], stringColor = Color.darkGray, pointColor = Color.red; /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } public void paint(Graphics g) { g.drawString(appletTitle, 170, 15); g.setColor(Color.darkGray); g.drawRect(40, 25, Rect_Width-1, Rect_Height-1); //绘制矩形外框 g.setColor(Color.lightGray); g.drawRect(39, 24, Rect_Width+1, Rect_Height+1); //绘制矩形外框的边框 g.setColor(Color.darkGray); rowHeight = Rect_Height/row; //计算行高像素值 for (int i=0; i<row; i++) //绘制行刻度 { g.drawLine(40, 24+Rect_Height-rowHeight*i, 39+Rect_Width, 24+Rect_Height-rowHeight*i); g.setColor(Color.lightGray); g.drawLine(41, 25+Rect_Height-rowHeight*i, 38+Rect_Width, 25+Rect_Height-rowHeight*i); g.setColor(Color.darkGray); if (rowHeightVal >= 10000) g.drawString(rowHeightVal/10000*i+"万", 5, 27+Rect_Height-rowHeight*i); else g.drawString(""+rowHeightVal*i, 5, 27+Rect_Height-rowHeight*i); } for (int i=0; i<Mon_Num; i++) //计算每个柱的柱高(像素值),并画柱 { zhuHeight[i][0] = rowHeight*par[i][0] / rowHeightVal; zhuHeight[i][1] = rowHeight*par[i][1] / rowHeightVal; y[i][0] = 25 + Rect_Height - zhuHeight[i][0]; y[i][1] = 25 + Rect_Height - zhuHeight[i][1]; x[i] = 60 + i*35; xPoint[i] = x[i]+7; yPoint[i] = y[i][0]-1; g.setColor(Color.lightGray); g.draw3DRect(x[i], y[i][0], Zhu_Width, zhuHeight[i][0]-1, true); g.setColor(zhuColor[i]); g.fillRect(x[i]+1, y[i][0]+1, Zhu_Width-2, zhuHeight[i][0]-2); g.setColor(zhuColorDark[i]); g.fillRect(x[i]+1, y[i][1]+1, Zhu_Width-2, zhuHeight[i][1]-2); g.setColor(stringColor); g.drawString(i+1+"月", 60+i*35, 40+Rect_Height); g.setColor(pointColor); g.fillOval(xPoint[i]-2, yPoint[i]-3, 5, 5); //画折线点 } g.drawPolyline(xPoint, yPoint, Mon_Num); //画折线 g.setColor(Color.black); g.drawString("月"+label1+":", 35, 65+Rect_Height); g.drawString("月"+label2+":", 35, 85+Rect_Height); int all0 = 0,all1 = 0; for (int i=0; i<Mon_Num; i++) { all0 += par[i][0]; all1 += par[i][1]; } g.drawString(label3+": "+all0, 290, 65+Rect_Height); g.drawString(label4+": "+all1, 290, 85+Rect_Height);} public void update(Graphics g) { if (changFlag) { g.setColor(zhuColor[changNum]); g.fillRect(x[changNum]+1, y[changNum][0]+1, Zhu_Width-2, zhuHeight[changNum][0]-2); g.setColor(zhuColorDark[changNum]); g.fillRect(x[changNum]+1, y[changNum][1]+1, Zhu_Width-2, zhuHeight[changNum][1]-2); g.setColor(stringColor); g.drawString(changNum+1+"月", 60+changNum*35, 40+Rect_Height); g.setColor(pointColor); g.fillOval(xPoint[changNum]-2, yPoint[changNum]-3, 5, 5); //画折线点 g.setColor(Color.red); g.drawPolyline(xPoint, yPoint, Mon_Num); //画折线 g.setColor(Color.black); if (zhuColor[changNum] != Color.orange) { g.drawString(changNum+1+"", 22, 65+Rect_Height); g.drawString(changNum+1+"", 22, 85+Rect_Height); g.drawString(""+par[changNum][0], 200, 65+Rect_Height); g.drawString(""+par[changNum][1], 225, 85+Rect_Height); } else { g.clearRect(22, 50+Rect_Height, 12, 100); g.clearRect(200, 50+Rect_Height, 40, 20); g.clearRect(225, 70+Rect_Height, 40, 20); } changFlag = false; } else paint(g); } /**Construct the applet*/ public tour() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { for (int i=1; i<=Mon_Num; i++) { par[i-1][0] = Integer.parseInt(getParameter("mon"+i, "0")); par[i-1][1] = Integer.parseInt(getParameter("mon"+i+"out", "0")); if (par[i-1][0] > max) {max = par[i-1][0];} //取得参数中总人数的最大值 zhuColor[i-1] = Color.orange; zhuColorDark[i-1] = Color.blue; } appletTitle = getParameter("appletTitle", ""); label1 = getParameter("label1", ""); label2 = getParameter("label2", ""); label3 = getParameter("label3", ""); label4 = getParameter("label4", ""); /************ 计算行数 *********************/ int i,temp; for (i=0, temp=max; temp>=10; i++) {temp = (int)temp/10;} if (temp <= 2) { rowHeightVal = (int)Math.pow(10, i-1); row = max/(int)Math.pow(10, i-1) + 2; } else { rowHeightVal = (int)Math.pow(10, i); row = temp + 2; } this.setBackground(Color.white); this.setSize(600, 400); this.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent e) { int mouseX = e.getX(), mouseY = e.getY(); for (int i = 0; i<Mon_Num; i++) { if ((mouseX>x[i] && mouseX<x[i]+15) && (mouseY>y[i][0] && mouseY<y[i][0]+zhuHeight[i][0])) { if (zhuColor[i] == Color.orange && zhuColorDark[i] == Color.blue) { changFlag = true; changNum = i; zhuColor[i] = new Color(0x33b3ff); zhuColorDark[i] = new Color(0x666699); pointColor = Color.lightGray; stringColor = Color.red; repaint(); break; } } else if (zhuColor[i] != Color.orange && zhuColorDark[i] != Color.blue) { changFlag = true; changNum = i; zhuColor[i] = Color.orange; zhuColorDark[i] = Color.blue; pointColor = Color.red; stringColor = Color.darkGray; repaint(); break; } } } }); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; }} 多谢hccpro!不过我看不懂你的数据是怎样取得的(不可能是写在tour.htm中吧),小弟太愚钝了! 对啊,就是写在html文件里,比如:<HTML><HEAD><TITLE>HTML Test Page</TITLE></HEAD><BODY><APPLET CODEBASE = "." CODE = "tour.class" NAME = "tour" WIDTH = 500 HEIGHT = 400 HSPACE = 0 VSPACE = 0 ALIGN = top><param name=appletTitle value=标题><param name=label1 value=label1><param name=label2 value=label2><param name=label3 value=label3><param name=label4 value=label4><param name=mon1 value=79976><param name=mon1out value=24248><param name=mon2 value=109810><param name=mon2out value=283><param name=mon3 value=69732><param name=mon3out value=16167><param name=mon4 value=57316><param name=mon4out value=436><param name=mon5 value=44734><param name=mon5out value=19280><param name=mon6 value=43056><param name=mon6out value=642><param name=mon7 value=21678><param name=mon7out value=5900><param name=mon8 value=41250><param name=mon8out value=418><param name=mon9 value=39972><param name=mon9out value=147><param name=mon10 value=32197><param name=mon10out value=2392><param name=mon11 value=24679><param name=mon11out value=3019><param name=mon12 value=23829><param name=mon12out value=2650></APPLET></BODY></HTML> 可是我希望的是能够动态从数据库中取出数据呀。请hccpro留下email,我结了分,我们email讨论,好吗?多谢! 用JSP操作数据库,返回值写进JSP文件的<APPLET>参数里就可以了!这种方法适用于数据量不是很大,刷新不频繁的情况,使用起来很简单。在论坛里讨论不是挺好的么?非要用email吗? 用javabean生成图形文件,再用浏览器显示出来,速度快,适合internet使用,但缺点是和用户的交互性差。 不能用jsp,因为服务器只有oracle,希望采用的是oracle webserver! 正则表达式新手继续发帖..大家有空的帮个忙 java邮件开发出现java.lang.ClassCastException: javax.mail.Session cannot be cast to j错误 java_jbuilder修饰包nimrodlf-0.99b如何使用? 帮我看看这个错误,郁闷,新手上路 请教 请问字符为空的条件怎么写? 如何做到让applet只初始化一次! 如何将数字转换成字符串? JAVA包的存放路径问题 高分求助 :怎么保存图像? 在线等候!!!!!!! 谁用java做过gis?急死我了呀 Java设置的初级问题,请大虾指点!
jsp+servlet or applet ???
我以前做过一个统计方面的servlet+jsp,源码是无法给你的,因为不归我所有,虽然水平不高可公司认为这也是归他的不是我个人的:)。如果有兴趣,愿意与你讨论这方面的问题。 [email protected]
用APPLET,很好做,下面的是俺做项目时做过的,欢迎批评指正!!!!!
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
//import java.awt.color.*;public class tour extends Applet
{
boolean isStandalone = false; /************** 矩形外框的长宽值 ****************/
public static final int Rect_Width = 440; //框宽
public static final int Rect_Height = 305; //框高
public static final int Mon_Num = 12; //显示的月份数
public static final int Zhu_Width = 15; //柱宽 int x[] = new int[Mon_Num], // x[] 和 y[][] 是每个柱的左上角坐标(因为包含“海外”情况,所以x只有一个值,y有两个值)
y[][] = new int[Mon_Num][2],
zhuHeight[][] = new int[Mon_Num][2], //每个柱的柱高
par[][] = new int[Mon_Num][2], //参数数组变量
max = 0, //参数中的最大值
row = 0, //行数
rowHeight = 0, //行高像素值
rowHeightVal = 0, //行高指标值
xPoint[] = new int[Mon_Num], // xPoint[] 和 yPoint[] 是画折线需用到的点坐标值
yPoint[] = new int[Mon_Num],
changNum = -1; boolean changFlag = false; String appletTitle = null, //applet标题
label1 = null,
label2 = null,
label3 = null,
label4 = null; Color zhuColor[] = new Color[Mon_Num],
zhuColorDark[] = new Color[Mon_Num],
stringColor = Color.darkGray,
pointColor = Color.red; /**Get a parameter value*/
public String getParameter(String key, String def)
{
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} public void paint(Graphics g)
{
g.drawString(appletTitle, 170, 15); g.setColor(Color.darkGray);
g.drawRect(40, 25, Rect_Width-1, Rect_Height-1); //绘制矩形外框
g.setColor(Color.lightGray);
g.drawRect(39, 24, Rect_Width+1, Rect_Height+1); //绘制矩形外框的边框 g.setColor(Color.darkGray);
rowHeight = Rect_Height/row; //计算行高像素值
for (int i=0; i<row; i++) //绘制行刻度
{
g.drawLine(40, 24+Rect_Height-rowHeight*i, 39+Rect_Width, 24+Rect_Height-rowHeight*i);
g.setColor(Color.lightGray);
g.drawLine(41, 25+Rect_Height-rowHeight*i, 38+Rect_Width, 25+Rect_Height-rowHeight*i);
g.setColor(Color.darkGray);
if (rowHeightVal >= 10000) g.drawString(rowHeightVal/10000*i+"万", 5, 27+Rect_Height-rowHeight*i);
else g.drawString(""+rowHeightVal*i, 5, 27+Rect_Height-rowHeight*i);
} for (int i=0; i<Mon_Num; i++) //计算每个柱的柱高(像素值),并画柱
{
zhuHeight[i][0] = rowHeight*par[i][0] / rowHeightVal;
zhuHeight[i][1] = rowHeight*par[i][1] / rowHeightVal;
y[i][0] = 25 + Rect_Height - zhuHeight[i][0];
y[i][1] = 25 + Rect_Height - zhuHeight[i][1];
x[i] = 60 + i*35;
xPoint[i] = x[i]+7;
yPoint[i] = y[i][0]-1;
g.setColor(Color.lightGray);
g.draw3DRect(x[i], y[i][0], Zhu_Width, zhuHeight[i][0]-1, true);
g.setColor(zhuColor[i]);
g.fillRect(x[i]+1, y[i][0]+1, Zhu_Width-2, zhuHeight[i][0]-2);
g.setColor(zhuColorDark[i]);
g.fillRect(x[i]+1, y[i][1]+1, Zhu_Width-2, zhuHeight[i][1]-2);
g.setColor(stringColor);
g.drawString(i+1+"月", 60+i*35, 40+Rect_Height);
g.setColor(pointColor);
g.fillOval(xPoint[i]-2, yPoint[i]-3, 5, 5); //画折线点
}
g.drawPolyline(xPoint, yPoint, Mon_Num); //画折线
g.setColor(Color.black);
g.drawString("月"+label1+":", 35, 65+Rect_Height);
g.drawString("月"+label2+":", 35, 85+Rect_Height);
int all0 = 0,all1 = 0;
for (int i=0; i<Mon_Num; i++)
{
all0 += par[i][0];
all1 += par[i][1];
}
g.drawString(label3+": "+all0, 290, 65+Rect_Height);
g.drawString(label4+": "+all1, 290, 85+Rect_Height);} public void update(Graphics g)
{
if (changFlag)
{
g.setColor(zhuColor[changNum]);
g.fillRect(x[changNum]+1, y[changNum][0]+1, Zhu_Width-2, zhuHeight[changNum][0]-2);
g.setColor(zhuColorDark[changNum]);
g.fillRect(x[changNum]+1, y[changNum][1]+1, Zhu_Width-2, zhuHeight[changNum][1]-2);
g.setColor(stringColor);
g.drawString(changNum+1+"月", 60+changNum*35, 40+Rect_Height);
g.setColor(pointColor);
g.fillOval(xPoint[changNum]-2, yPoint[changNum]-3, 5, 5); //画折线点
g.setColor(Color.red);
g.drawPolyline(xPoint, yPoint, Mon_Num); //画折线
g.setColor(Color.black);
if (zhuColor[changNum] != Color.orange)
{
g.drawString(changNum+1+"", 22, 65+Rect_Height);
g.drawString(changNum+1+"", 22, 85+Rect_Height);
g.drawString(""+par[changNum][0], 200, 65+Rect_Height);
g.drawString(""+par[changNum][1], 225, 85+Rect_Height);
}
else {
g.clearRect(22, 50+Rect_Height, 12, 100);
g.clearRect(200, 50+Rect_Height, 40, 20);
g.clearRect(225, 70+Rect_Height, 40, 20);
}
changFlag = false;
}
else paint(g);
} /**Construct the applet*/
public tour()
{
}
/**Initialize the applet*/
public void init()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception
{
for (int i=1; i<=Mon_Num; i++)
{
par[i-1][0] = Integer.parseInt(getParameter("mon"+i, "0"));
par[i-1][1] = Integer.parseInt(getParameter("mon"+i+"out", "0"));
if (par[i-1][0] > max) {max = par[i-1][0];} //取得参数中总人数的最大值
zhuColor[i-1] = Color.orange;
zhuColorDark[i-1] = Color.blue;
}
appletTitle = getParameter("appletTitle", "");
label1 = getParameter("label1", "");
label2 = getParameter("label2", "");
label3 = getParameter("label3", "");
label4 = getParameter("label4", ""); /************ 计算行数 *********************/
int i,temp;
for (i=0, temp=max; temp>=10; i++)
{temp = (int)temp/10;}
if (temp <= 2)
{
rowHeightVal = (int)Math.pow(10, i-1);
row = max/(int)Math.pow(10, i-1) + 2;
}
else {
rowHeightVal = (int)Math.pow(10, i);
row = temp + 2;
}
this.setBackground(Color.white);
this.setSize(600, 400);
this.addMouseMotionListener(new MouseMotionAdapter()
{ public void mouseMoved(MouseEvent e)
{
int mouseX = e.getX(),
mouseY = e.getY();
for (int i = 0; i<Mon_Num; i++)
{
if ((mouseX>x[i] && mouseX<x[i]+15) && (mouseY>y[i][0] && mouseY<y[i][0]+zhuHeight[i][0]))
{
if (zhuColor[i] == Color.orange && zhuColorDark[i] == Color.blue)
{
changFlag = true;
changNum = i;
zhuColor[i] = new Color(0x33b3ff);
zhuColorDark[i] = new Color(0x666699);
pointColor = Color.lightGray;
stringColor = Color.red;
repaint();
break;
}
}
else if (zhuColor[i] != Color.orange && zhuColorDark[i] != Color.blue)
{
changFlag = true;
changNum = i;
zhuColor[i] = Color.orange;
zhuColorDark[i] = Color.blue;
pointColor = Color.red;
stringColor = Color.darkGray;
repaint();
break;
}
}
}
});
}
/**Get Applet information*/
public String getAppletInfo()
{
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo()
{
return null;
}}
对啊,就是写在html文件里,比如:<HTML>
<HEAD>
<TITLE>
HTML Test Page
</TITLE>
</HEAD>
<BODY>
<APPLET
CODEBASE = "."
CODE = "tour.class"
NAME = "tour"
WIDTH = 500
HEIGHT = 400
HSPACE = 0
VSPACE = 0
ALIGN = top
>
<param name=appletTitle value=标题>
<param name=label1 value=label1>
<param name=label2 value=label2>
<param name=label3 value=label3>
<param name=label4 value=label4><param name=mon1 value=79976>
<param name=mon1out value=24248>
<param name=mon2 value=109810>
<param name=mon2out value=283>
<param name=mon3 value=69732>
<param name=mon3out value=16167>
<param name=mon4 value=57316>
<param name=mon4out value=436>
<param name=mon5 value=44734>
<param name=mon5out value=19280>
<param name=mon6 value=43056>
<param name=mon6out value=642>
<param name=mon7 value=21678>
<param name=mon7out value=5900>
<param name=mon8 value=41250>
<param name=mon8out value=418>
<param name=mon9 value=39972>
<param name=mon9out value=147>
<param name=mon10 value=32197>
<param name=mon10out value=2392>
<param name=mon11 value=24679>
<param name=mon11out value=3019>
<param name=mon12 value=23829>
<param name=mon12out value=2650></APPLET>
</BODY>
</HTML>
用JSP操作数据库,返回值写进JSP文件的<APPLET>参数里就可以了!这种方法适用于数据量不是很大,刷新不频繁的情况,使用起来很简单。在论坛里讨论不是挺好的么?非要用email吗?