This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes finding a missing number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "finding a missing number" Watch "finding a missing number" New topic
Author

finding a missing number

vinu pillai
Greenhorn

Joined: Oct 05, 2001
Posts: 7
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
vivek makode
Greenhorn

Joined: Oct 01, 2001
Posts: 27
take the result set data in an integer array and not a single number.
u have taken int num.
take int num[];
vinu pillai
Greenhorn

Joined: Oct 05, 2001
Posts: 7
Thanks buddy...

Originally posted by vivek makode:
take the result set data in an integer array and not a single number.
u have taken int num.
take int num[];

 
Don't get me started about those stupid light bulbs.
 
subject: finding a missing number
 
Similar Threads
No suitable driver found
Cannot resolve type in jsp
problem connecting to postgres 8.2.3
update to database problem
Java-Xml file not getting Connected to DataBase