3 Replies - 691 Views - Last Post: 29 March 2011 - 09:21 PM Rate Topic: -----

#1 Xantara  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-February 11

My login page doesnt work yet it brings no error when i build

Posted 29 March 2011 - 07:55 PM


				if(command=="login"){
				try{
					d=new Databys();
					rs= st.executeQuery("Select *  from user_login");
					rs.beforeFirst();
					while(rs.next()){
					String uname=rs.getString("name_txt");
					String pass=rs.getString("pass_txt");

                                                              					if(name_txt.getText().equals(uname)&&pass_txt.getText().equals(pass)){
							entry=true;
                                                     new poffice();
							this.dispose();
			
								}


							}
						}
						catch (Exception err) {
						err.printStackTrace();
						System.out.println( "Error: " + err );
					
	JOptionPane.showMessageDialog(rootPane, "Enter  Correct Username or Password","Login",JOptionPane.ERROR_MESSAGE);
						}
				}}
			

	public static void main(String[]args){
		setDefaultLookAndFeelDecorated(true);
	plogin app=new plogin();
	}

}



Hi? could someone please help me, my code has no error when i build it but after i run it and try to log in using the username and password saved in the database it tells me its an incorrect input. i have called username and password as "uname" and "pass" in the database and the table is user_login.

*Edited :code:

This post has been edited by pbl: 29 March 2011 - 08:05 PM


Is This A Good Question/Topic? 0
  • +

Replies To: My login page doesnt work yet it brings no error when i build

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: My login page doesnt work yet it brings no error when i build

Posted 29 March 2011 - 08:11 PM

Don't compare String like that

if(command=="login"){

us the equals() method


What is poffice ?
new poffice();

I presume this means we are in a JFrame
this.dispose();

"i have called username and password as "uname" and "pass" in the database "
you mean as column name ? In that case should be
String uname=rs.getString("uname");
Was This Post Helpful? 0
  • +
  • -

#3 Xantara  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-February 11

Re: My login page doesnt work yet it brings no error when i build

Posted 29 March 2011 - 09:18 PM

new poffice(); is the class containing the next window that is supposed to be opened after the username and password are validated
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10669
  • View blog
  • Posts: 39,633
  • Joined: 27-December 08

Re: My login page doesnt work yet it brings no error when i build

Posted 29 March 2011 - 09:21 PM

Also, always separate your program's state/data from the user interface. You should have a StateManager to manage things like currentUser, etc., and there should be a DataManager to manage database connections and other program data.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1