Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

next() method of ResultSet not showing data ..

866b4f0f-a02f-492c-a211-a1c3bc22c363Jun 6 2016 — edited Jun 6 2016

Class.forName("oracle.jdbc.driver.OracleDriver");

            

             Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","root");

             PreparedStatement stmt2;

            String sql="select * from RECORDDATA where ID= ? and COMPANY_NM=? ";

            stmt2=con.prepareStatement(sql);

            int i=5;

            str="Audi";

             try

             {   stmt2.setInt(1, i);

                 System.out.println("after setting id");

                 stmt2.setString(2,str);

                 System.out.println("after setting string");

             }

             catch(Exception iner)

             {

                 System.out.println("int coulnm"+iner);

             }

            try

            {

            ResultSet showdata=stmt2.executeQuery();

         

       

       

         while(showdata.next())

             {

                  // Doest not enter in this while loop.....dont know why??

                 System.out.println("in next");

                 System.out.println("\n"+showdata.getInt(1)+showdata.getString(2)+showdata.getString(3)+showdata.getString(4)+showdata.getString(5)+showdata.getString(6)+showdata.getString(7));

                 System.out.println("after next");

             }

        }catch(Exception e)

        {

            e.printStackTrace();

        }

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2016
Added on Jun 6 2016
2 comments
1,612 views