获取数据一直获取不上。之前用的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];
}
初学者,求大牛解答