java获得使用查询类中,相关数据进入结果集,但是从中获取的值为空值null
try{subjectsj=newsubject();sj.setStuid(Integer.parseInt(jt.getText()));System.out.pri...
try {
subject sj = new subject();
sj.setStuid(Integer.parseInt(jt.getText()));
System.out.println("内容是1:"+jt.getText());
Connection conn = JDBC_Util.getConnection();
String sql = "select *from subject where stuid=?";
PreparedStatement ps = conn.prepareStatement(sql);
System.out.println("sj.getstuid:"+sj.getStuid());
ps.setInt(1,sj.getStuid() );
ResultSet rs = ps.executeQuery();
int p =0;
String[][] s = new String[10000][3];
while (rs.next()) {
s[p][1] =String.valueOf(rs.getString("subno"));
p++;
System.out.println("内容3:"+s[p][1]);
}
selesub ss = new selesub();
for (int i = 0; i < p; i++) {
int subno=ss.setSubno(Integer.parseInt(s[p][1]));
System.out.println("内容2是:"+s[p][1]);
}
JDBC_Util.closeConnection(rs, ps, conn);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
} 展开
subject sj = new subject();
sj.setStuid(Integer.parseInt(jt.getText()));
System.out.println("内容是1:"+jt.getText());
Connection conn = JDBC_Util.getConnection();
String sql = "select *from subject where stuid=?";
PreparedStatement ps = conn.prepareStatement(sql);
System.out.println("sj.getstuid:"+sj.getStuid());
ps.setInt(1,sj.getStuid() );
ResultSet rs = ps.executeQuery();
int p =0;
String[][] s = new String[10000][3];
while (rs.next()) {
s[p][1] =String.valueOf(rs.getString("subno"));
p++;
System.out.println("内容3:"+s[p][1]);
}
selesub ss = new selesub();
for (int i = 0; i < p; i++) {
int subno=ss.setSubno(Integer.parseInt(s[p][1]));
System.out.println("内容2是:"+s[p][1]);
}
JDBC_Util.closeConnection(rs, ps, conn);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
} 展开
展开全部
p++;
System.out.println("内容3:"+s[p][1]);
调换一下位置试试,改成
System.out.println("内容3:"+s[p][1]);
p++;
下面这两句
int subno=ss.setSubno(Integer.parseInt(s[p][1]));
System.out.println("内容2是:"+s[p][1]);
改成
int subno=ss.setSubno(Integer.parseInt(s[i][1]));
System.out.println("内容2是:"+s[i][1]);
System.out.println("内容3:"+s[p][1]);
调换一下位置试试,改成
System.out.println("内容3:"+s[p][1]);
p++;
下面这两句
int subno=ss.setSubno(Integer.parseInt(s[p][1]));
System.out.println("内容2是:"+s[p][1]);
改成
int subno=ss.setSubno(Integer.parseInt(s[i][1]));
System.out.println("内容2是:"+s[i][1]);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询