java - While(rs.next()) not executing -
sorry code large. problem rs.next not seem execute @ because system.out.println("//////////////////////////////////");
not print anything.
string temp2; temp2 = ""; //initialise variable system.out.println("*************************************************"); try { string filename = "database.mdb"; string database = "jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq="; database += filename.trim() + ";driverid=22;readonly=false"; conn = drivermanager.getconnection(database, "", ""); for(int id = 1; id < 16; id++)//will repeat 15 times (for each player) { for(int x = 1; x < 18; x++)//will repeat 18 times (once each team fixture) { statement sta2 = conn.createstatement(); resultset rs2 = sta2.executequery("select * tblplayers playerid = "+ playerid +" , fixturenumber = "+ x); while (rs2.next()) { temp2 = rs2.getstring("playername"); system.out.println("//////////////////////////////////"); system.out.println(temp2 + ":temp2"); total = total + rs2.getint("goals");//calculating total system.out.println(total + ":total"); } } if (total.equals(totalsrev[0])){ playername[0] = temp2; }else if (total.equals(totalsrev[1])){ playername[1] = temp2; }else if (total.equals(totalsrev[2])){ playername[2] = temp2; }else if (total.equals(totalsrev[3])){ playername[3] = temp2; }else if (total.equals(totalsrev[4])){ playername[4] = temp2; } } playerid = 0;//reset variable for(int x = 0; x < 5; x++){ system.out.println(playername[x]); } system.out.println("*********************************************"); system.out.println(totalsrev[0]); system.out.println(totalsrev[1]); system.out.println(totalsrev[2]); system.out.println(totalsrev[3]); system.out.println(totalsrev[4]); jlabel10.settext(playername[0] + ""); jlabel11.settext(playername[1] + ""); jlabel12.settext(playername[2] + ""); jlabel13.settext(playername[3] + ""); jlabel14.settext(playername[4] + ""); } catch (exception e) { system.out.println("exception displaytotalattributes:" + e); } //close down connection prevent "too many tables open" error { if (conn != null) { try { conn.close(); } catch (sqlexception e) {} } }
the output in console is:
"*********************************************"
//system.out.println("//////////////////////////////////");
should have executed here omicron //team name
null //these should team names too
null
null
null
"*****************************************"
15
14
13
12
11"
Comments
Post a Comment