RainMoun 2017-04-18 07:59 采纳率: 0%
浏览 920

一个Eclipse获取Mysql数据的小问题

获取数据一直获取不上。之前用的C语言写的算法,想要写进Eclipse中,大家看看有什么问题,数据库连接一切正常
try {
Connection connect = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/financehelper","root","123456");

  System.out.println("Success connect Mysql server!");
  Statement stmt = connect.createStatement();

  ResultSet rs = stmt.executeQuery("select * from user_finaproduct");
  C_node[][]  C = new C_node[100][100]; 
  L_node[][]  L = new L_node[100][100];
  D_node[] D = new D_node[100]; 
  int i = 1;

while (rs.next()) {
D[i].item[1] = rs.getInt("sex");
D[i].item[2] = rs.getInt("stage");
D[i].item[3] = rs.getInt("moneytype");
D[i].item[4] = rs.getInt("income");
D[i].item[5] = rs.getInt("outcome");
D[i].item[6] = rs.getInt("save");
D[i].item[7] = rs.getInt("worktype");
D[i].item[8] = rs.getInt("product1");
String temp = rs.getInt("product2")+"";
if(!temp.equals(""))
D[i].item[9] = rs.getInt("product2");
temp = rs.getInt("product3")+"";
if(!temp.equals(""))
D[i].item[10] = rs.getInt("product3");
i++;
System.out.println(D[i].item[1]);
}
}
catch (Exception e) {
System.out.print("get data error!");
e.printStackTrace();
}
}

D_NODE的类:class D_node {
int[] item=new int[100]; 

}
初学者,求大牛解答

  • 写回答

5条回答 默认 最新

  • RainMoun 2017-04-18 07:56
    关注

    问题出在while循环的第一行

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站