How can i find a missing number stored in database say an oracle database...Like for e.g there are 1 - 10 numbers in database...and the numbers 5 and 7 are missing in...so..! i want to print these two missing numbers in front end ....The code which i coded is ..
import java.sql.*;
class testNum {
public static void main(
String args[]) throws Exception {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc
dbc:Category_Trans";
String username = "vinu";
String password = "vinu";
Connection connection = null;
ResultSet rset = null;
int num = 0;
int i;
Class.forName(driver);
connection = DriverManager.getConnection(url, username, password);
Statement statement = connection.createStatement();
rset = statement.executeQuery("select * from number_test");
if(rset != null) {
while(rset.next()) {
num = rset.getInt(1);
//System.out.println(num);
}
}
for(i=1;i<=num;i++) {
System.out.println(i);
/*if(i!=num)
System.out.println("1.." +num);
else
System.out.println("2.." +i);*/
}
System.out.println();
}
}
but it's not printing what i wanted..
plz if there is any solution then help me out...
thanks
Vinu