Problem with the database - regarding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeep84
    New Member
    • Sep 2007
    • 37

    Problem with the database - regarding

    hi..to all........
    i used the following code... in order to check the input with the database...
    but i had a error java.sql.SQLExc eption: No data found
    i checked the database name... and database connection... i dont know wats wrong ..... plz help me to resolve the problem......
    Code:
    try 
    {
         
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con=DriverManager.getConnection("jdbc:odbc:prism");
          stmt=con.createStatement();
          rs=stmt.executeQuery("select * from Customerdetails");
          
          
            s1=(ccod.getText());
          
          while(rs.next())
         {
             if(rs.getString("CustomerID").equals(s1))
             {
                 flag=1;
    
               s1=(rs.getString(1));
               s2=(rs.getString(2));
               s3=(rs.getString(3));
               s4=(rs.getString(4));
               s5=(rs.getString(5));
               s6=(rs.getString(6));
               s7=(rs.getString(7));
               
               JOptionPane.showMessageDialog(this,new String("data found"+rs.getString(1)));
                 
               ccod.setText(s1);
               cname.setText(s2);
               add.setText(s3);
               phno.setText(s4);
               conp.setText(s5);
               email.setText(s6);
               fax.setText(s7);
    }
             
    }
    }
    
      catch(ClassNotFoundException e)
    {
      System.out.println(e);
    }    
    catch(SQLException e)
    {
      System.out.println(e);
    }
     }
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Look!

    For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once.

    So change this line.
    [code=java]
    JOptionPane.sho wMessageDialog( this,new String("data found"+rs.getSt ring(1)));
    //This is wrong
    JOptionPane.sho wMessageDialog( this,new String("data found"+s1));
    //This is right
    [/code]

    So you got my point :-)
    Good Luck !

    Kind regards,
    Dmjpro.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by pradeep84
      hi..to all........
      i used the following code... in order to check the input with the database...
      but i had a error java.sql.SQLExc eption: No data found
      i checked the database name... and database connection... i dont know wats wrong ..... plz help me to resolve the problem......
      Code:
      try 
      {
           
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con=DriverManager.getConnection("jdbc:odbc:prism");
            stmt=con.createStatement();
            rs=stmt.executeQuery("select * from Customerdetails");
            
            
              s1=(ccod.getText());
            
            while(rs.next())
           {
               if(rs.getString("CustomerID").equals(s1))
               {
                   flag=1;
      
                 s1=(rs.getString(1));
                 s2=(rs.getString(2));
                 s3=(rs.getString(3));
                 s4=(rs.getString(4));
                 s5=(rs.getString(5));
                 s6=(rs.getString(6));
                 s7=(rs.getString(7));
                 
                 JOptionPane.showMessageDialog(this,new String("data found"+rs.getString(1)));
                   
                 ccod.setText(s1);
                 cname.setText(s2);
                 add.setText(s3);
                 phno.setText(s4);
                 conp.setText(s5);
                 email.setText(s6);
                 fax.setText(s7);
      }
               
      }
      }
      
        catch(ClassNotFoundException e)
      {
        System.out.println(e);
      }    
      catch(SQLException e)
      {
        System.out.println(e);
      }
       }
      The specs say that you should only read a values from left to right and and read them only once. You are reading from column one to seven then reading column one again. See if that doesn't affect it.

      Comment

      • pradeep84
        New Member
        • Sep 2007
        • 37

        #4
        Originally posted by r035198x
        The specs say that you should only read a values from left to right and and read them only once. You are reading from column one to seven then reading column one again. See if that doesn't affect it.
        Thanks... for your valuable suggestions...

        i got the output.....


        Regards
        Pradeep

        Comment

        • i carry 2 r3al
          New Member
          • Sep 2007
          • 1

          #5
          I CANT GET MY FRIENDS LIST 2,3 AND SO ON,,PLEASE HELP



          Результаты 1-3 по запросу javascript:__do PostBack('ctl00 $cpMain$pagerTo p','2') (0,04 секунд)

          Возможно, вы имели в виду: javascript:__do PostBack('ctl00 $pcmain$pagetop ','2')



          Пользовательски й поиск
          Q&A - [Myspace navigation]The link for page 2 is: javascript:__do PostBack('ctl00 $cpMain$pagerTo p','2') Since BrownRecluse has some javascript and forms ability I'm hoping that there ...
          softbytelabs.co m/us/support.pl?prod uct=br&msg=177

          jasmusic.com : Journal Listing... 2 of most listings because instead of <A href=""> I have to contend with dumb stupid shit like javascript:__do PostBack('ctl00 $cpMain$pagerTo p','2'). ...
          www.jasmusic.co m/journal.php?ski p=10&show=10

          Parse a friends page on MySpace - ASP ForumThe question is, how do I get page 2 and page 3 and so on? There's a simple Javascript post on the ... javascript:__do PostBack('ctl00 $cpMain$pagerTo p','4 ') ...
          www.thescripts. com/forum/thread595690.ht ml

          Возможно, вы искали: javascript:__do PostBack('ctl00 $pcmain$pagetop ','2')

          Comment

          • Nepomuk
            Recognized Expert Specialist
            • Aug 2007
            • 3111

            #6
            Originally posted by i carry 2 r3al
            I CANT GET MY FRIENDS LIST 2,3 AND SO ON,,PLEASE HELP



            Результаты 1-3 по запросу javascript:__do PostBack('ctl00 $cpMain$pagerTo p','2') (0,04 секунд)

            Возможно, вы имели в виду: javascript:__do PostBack('ctl00 $pcmain$pagetop ','2')



            Пользовательски й поиск
            Q&A - [Myspace navigation]The link for page 2 is: javascript:__do PostBack('ctl00 $cpMain$pagerTo p','2') Since BrownRecluse has some javascript and forms ability I'm hoping that there ...
            softbytelabs.co m/us/support.pl?prod uct=br&msg=177

            jasmusic.com : Journal Listing... 2 of most listings because instead of <A href=""> I have to contend with dumb stupid shit like javascript:__do PostBack('ctl00 $cpMain$pagerTo p','2'). ...
            www.jasmusic.co m/journal.php?ski p=10&show=10

            Parse a friends page on MySpace - ASP ForumThe question is, how do I get page 2 and page 3 and so on? There's a simple Javascript post on the ... javascript:__do PostBack('ctl00 $cpMain$pagerTo p','4 ') ...
            www.thescripts. com/forum/thread595690.ht ml

            Возможно, вы искали: javascript:__do PostBack('ctl00 $pcmain$pagetop ','2')
            This doesn't seem to have anything to do with the original Question and also this seems to be JavaScript instead of Java. Please open a new Thread about this in the JavaScript Forum.

            Greetings,
            Nepomuk

            Comment

            Working...