Results 1 to 17 of 17
  1. #1
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Java Database : Column not Found Problem ...

    i got a message that say Column not Found

    Java Code:
    if(e.getSource() == btn){
        	rs = st.executeQuery("select CardNo,PIN from account WHERE CardNo = '" + txt.getText() + "'and PIN = '" +txt2.getText() +"'");
        	
        
        if(rs.next()){
        	JOptionPane.showMessageDialog(null,"Access Granted");
        		
        	
        		pan.setVisible(false);
        		pan2.setVisible(true);
        		pan7.setVisible(true);	
        			
        	txt3.setText(rs.getString("Account name"));
        	txt4.setText(rs.getString(Integer.parseInt("Balance")));
        }
        
        
        else if(cn2.equals("") || pin2.equals("")){
        	JOptionPane.showMessageDialog(null,"Enter Account Number/Pin Number");
        
        }
       
        
        else if(!cn2.equals("") || !pin2.equals("")){
        	JOptionPane.showMessageDialog(null,"Access Denied");
        }
        
        	    		
        	
        }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Java Database : Column not Found Problem ...

    On which line? For which column? Is that column in your table?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default Re: Java Database : Column not Found Problem ...

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: Java Database : Column not Found Problem ...

    Here
    Java Code:
      if(rs.next()){
            JOptionPane.showMessageDialog(null,"Access Granted");
                 
             
                pan.setVisible(false);
                pan2.setVisible(true);
                pan7.setVisible(true);  
                     
            txt3.setText(rs.getString("Account name"));
            txt4.setText(rs.getString(Integer.parseInt("Balance")));

  5. #5
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: Java Database : Column not Found Problem ...

    What do you mean ?? u mean change ?

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Java Database : Column not Found Problem ...

    Do you really have a column called "Account name"? Are you sure?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Java Database : Column not Found Problem ...

    Also, what do you think this is going to do:

    Integer.parseInt("Balance")
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: Java Database : Column not Found Problem ...

    Yes ! and Balance also

  9. #9
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: Java Database : Column not Found Problem ...

    i try to remove the Integer.parseInt but same result ,, Column Not Found ....

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Java Database : Column not Found Problem ...

    Which line is it? Balance or "Account name"? That space seems suspicious to me, but I'm not really a database guy...
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  11. #11
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: Java Database : Column not Found Problem ...

    From the Balance , theres a space between Account name ..

  12. #12
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Java Database : Column not Found Problem ...

    Take out the line that does not cause the error and repost the updated code, along with the full stack trace. Throw together an SSCCE that only does one thing, and we'll go from there.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  13. #13
    LogicBrix is offline Member
    Join Date
    Oct 2011
    Posts
    16
    Rep Power
    0

    Default Re: Java Database : Column not Found Problem ...

    1234
    Last edited by LogicBrix; 03-29-2012 at 04:08 PM.

  14. #14
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default Re: Java Database : Column not Found Problem ...

    I wasn't looking for your whole code, just an SSCCE- in your case, that should only be a few lines, just enough to read from a single column. In your first example, you're reading from a couple columns so we can't be sure which one is giving you trouble, plus you said you changed your code by taking out parseInt. So I suggest you create an SSCCE so that we're all talking about the same thing. Otherwise we're just guessing.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  15. #15
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default Re: Java Database : Column not Found Problem ...

    Quote Originally Posted by LogicBrix View Post
    1234
    Please don't edit your post after there has been a response, except possibly to correct a spelling mistake. Doing so is discourteous to the other members of the forum.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  16. #16
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default Re: Java Database : Column not Found Problem ...

    On your query you select CardNo and PIN columns ONLY. Then in you rs.getString(...) code you are looking for Account Name.

    Goodluck

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Java Database : Column not Found Problem ...

    That says to me someone needs to learn SQL.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 10-03-2011, 07:14 PM
  2. Replies: 1
    Last Post: 03-24-2011, 12:51 PM
  3. Replies: 5
    Last Post: 02-23-2011, 09:14 PM
  4. Database Column vs String Concatenation
    By varun_33 in forum JDBC
    Replies: 1
    Last Post: 12-11-2007, 04:14 PM
  5. Error: javax.servlet.ServletException: Column not found
    By barney in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •