• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

finding a missing number

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic