有如下代码:// 随机生成并初始化数据
public void init()
{
preClose = 1000+Math.random() * 1500; // 初始化昨日收盘指数
max = preClose;
min = preClose;
for (int i = 0; i < counter; i++)
{
if (i == 0)
{
if (Math.random() > 0.5)
yPoint[i] = preClose + Math.random() * 10;
else
yPoint[i] = preClose - Math.random() * 10; volume[i] = (int)(10000 * (1+Math.random() * 5));
}
else
{
if (Math.random() > 0.5)
{
if ((yPoint[i - 1] + Math.random() * 3) >= preClose * 1.018)
yPoint[i] = yPoint[i - 1] - Math.random() * 3;
else
yPoint[i] = yPoint[i - 1] + Math.random() * 3;
}
else
{
if ((yPoint[i - 1] - Math.random() * 3) <= preClose * 0.982)
yPoint[i] = yPoint[i - 1] + Math.random() * 3;
else
yPoint[i] = yPoint[i - 1] - Math.random() * 3;
} if (Math.random() > 0.5)
volume[i] = volume[i - 1] + (int)(Math.random() * 10000);
else
volume[i] = volume[i - 1] - (int)(Math.random() * 10000); if (volume[i] >= 100000)
volume[i] -= 10000+(int)(Math.random() * 5000); if (volume[i] <= 10000)
volume[i] += 10000+(int)(Math.random() * 5000);
}
if (i == 0)
{
open = yPoint[i];
}
else if (i == counter - 1)
{
close = yPoint[i];
}如何使得// 随机生成并初始化数据 这一块变成从mysql 数据库中读取数据并且使用数据库中数据绘制呢?请高手们指教啊,谢谢了,分不多了,就10分了啊~!
public void init()
{
preClose = 1000+Math.random() * 1500; // 初始化昨日收盘指数
max = preClose;
min = preClose;
for (int i = 0; i < counter; i++)
{
if (i == 0)
{
if (Math.random() > 0.5)
yPoint[i] = preClose + Math.random() * 10;
else
yPoint[i] = preClose - Math.random() * 10; volume[i] = (int)(10000 * (1+Math.random() * 5));
}
else
{
if (Math.random() > 0.5)
{
if ((yPoint[i - 1] + Math.random() * 3) >= preClose * 1.018)
yPoint[i] = yPoint[i - 1] - Math.random() * 3;
else
yPoint[i] = yPoint[i - 1] + Math.random() * 3;
}
else
{
if ((yPoint[i - 1] - Math.random() * 3) <= preClose * 0.982)
yPoint[i] = yPoint[i - 1] + Math.random() * 3;
else
yPoint[i] = yPoint[i - 1] - Math.random() * 3;
} if (Math.random() > 0.5)
volume[i] = volume[i - 1] + (int)(Math.random() * 10000);
else
volume[i] = volume[i - 1] - (int)(Math.random() * 10000); if (volume[i] >= 100000)
volume[i] -= 10000+(int)(Math.random() * 5000); if (volume[i] <= 10000)
volume[i] += 10000+(int)(Math.random() * 5000);
}
if (i == 0)
{
open = yPoint[i];
}
else if (i == counter - 1)
{
close = yPoint[i];
}如何使得// 随机生成并初始化数据 这一块变成从mysql 数据库中读取数据并且使用数据库中数据绘制呢?请高手们指教啊,谢谢了,分不多了,就10分了啊~!
解决方案 »
- 异常java.lang.reflect.InvocationTargetException - Class: com.opensymphony.xwork2.i
- 用Myfaces的Trinidad的XMLMenuMoel时,只显示最level0的标签!?
- mysql日期格式转换的问题
- 一个比较大流量的网站,用什么应用服务器比较好?
- 小妹遇到个JSP的问题:我想在生成word文档后,点打开,重新开个IE,在那个新IE里打开,请问如何实现?急。。。
- jps的中文字符显示问题?这java怎么就这么不注意中文问题呢?
- 动态单选框问题 求助
- Tomcat 怎麽不能顯示tiff圖片,怎麽解決啊
- 基于B/S架构的ERP软件
- 在学JSP,有何比较经典的好书?
- 类型转换问题,
- ■■■■■■JSP如何用COOKIE数组??????
在上面语句该如何写呢?
请指教啊 谢谢!
然后用 Float var=new Float(rs.getString("filename "));
float fl=var.floatvalue();
然后在你的程序里面使用那个时间变量就可以liao!
public void init()
{
preClose = 1000+Math.random() * 1500; // 初始化昨日收盘指数
max = preClose;
min = preClose;
这里应该怎么写呢?直接写成?
public void init()
{
select filename from tab where ```````````
Float var=new Float(rs.getString("filename "));
float fl=var.floatvalue();
preClose = 1000+Math.random() * 1500; // 初始化昨日收盘指数
max = preClose;
min = preClose;
Float var=new Float(rs.getString("filename "));
float fl=var.floatvalue();还请 Sunny319 再详细指点下呀,谢谢了
PreparedStatement st = null;
ResultSet rset = null;
float fl=0;
cn=/*你取得数据库连接的函数代码*/;
st = cn.prepareStatement("select data from ecgfile where systime=?");
st.setString(1,systime);/*设置这个参数的值*/
rset=st.executeQuery();
if(rset.next())
{
Float var=new Float(rs.getString(1));/*取得你从数据库查询的字段的值*/
fl=var.floatvalue();
}
然后在后面代码就可以使用fl代码了.
public void init()
{
Connection cn = null;
PreparedStatement st = null;
ResultSet rset = null;
float fl=0;
cn=DataBaseConnection.getConnection();
st = cn.prepareStatement("select data from ecgfile where systime=?");
st.setString(systime);
rset=st.executeQuery();
if(rset.next())
{
float var=new float(rs.getString(systime));// 这一行的 new 后的float后面提示有错误 :invalid classtype
fl=var.floatvalue();
}
preClose = 1000+var.floatvalue() * 1500;
max = preClose;
min = preClose;
有一个错误 在float
是哪错了啊?
还有就是 st.setString(1,systime);/*设置这个参数的值*/ 为什么 要写个1呢?
st = cn.prepareStatement("select data from ecgfile where systime=?");
对上面的那个"?"参数设置值.st.setString(1,systime);1就是对第一个问号参数设置值.
正是有众多像你这样热心帮助别人的人,这个论坛才能这样火!
再一次谢谢!