• 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

data is not comming in order as it stored in database

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am having a student table in oracle database...

but when i am retrieving the data from this table by using resultset and jdbc connection. the rows retrieved by resultset are not comming in order, means according to logic first, first row should come, after that second and so on...

but here this order is not predictable, sometime while displaying the output its not following the order...

code is like this....

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","hr");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select sno from student");
StudentBean studentBean = new StudentBean();
while(resultSet.next())
{
studentBean.setStudentId(resultSet.getString(1));
System.out.println(studentBean.getStudentId());

}


and the output is coming like this....
11
16
21
6

and the database student data is like this...
SNO SNAME SAGE SQUALIFICATION SCOURSE
6 f df df f
11 sd f f sdf
21 bhcv cvb cvb b
16 dfg g d fg g

according to this table if we fetch the data it should come in 6,11,21,16 order but its not coming in this order....

i am unable to understand why its happening please help me...

i will be waiting for your reply...
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless you explicitely order by a column, the results are not guaranteed to be in any particular order.
 
santosh kimothi
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnaks for your reply
i understand now what was wrong with the sql query

thanks once again
 
reply
    Bookmark Topic Watch Topic
  • New Topic