Bookmark Topic Watch Topic
  • New Topic

ResultSet

 
bahri sirine
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm trying to know how many objectid in the resultset 1 have the same objectid in the Resultset 2.When I execute this I obtained just the objectid which are places in the same Rowin two tables .So any help please how can I correct this code:


try {
int count = 0;

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stage2", "root", "");
System.out.println("succés de connexion");
Statement stm = con.createStatement();
ResultSet Rs = stm.executeQuery("select idep from professeur");

Connection con1 = DriverManager.getConnection("jdbc:mysql://localhost:3306/stage3", "root", "");
System.out.println("succés de connexion1");
Statement stm1 = con1.createStatement();
ResultSet Rs1 = stm1.executeQuery("select idetudiant from etudiant");

int k = 0, j = 0;

while (Rs.next()) {
j = Rs.getInt("idep");

// System.out.println("j" + j);
while (Rs1.next()) {
k = Rs1.getInt("idetudiant");
if (k == j) {
System.out.println("k" + k + " j" + j);
count++;

}
break;
}

}

System.out.println(count);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate topic. Discussion continued here.

Topic locked.
    Bookmark Topic Watch Topic
  • New Topic