3 Replies - 4650 Views - Last Post: 13 October 2010 - 11:16 AM Rate Topic: -----

#1 y0yie_333  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-October 10

help ! how to do a simple log in program in netbeans using java da

Posted 13 October 2010 - 08:46 AM

help ! how to do a simple log in program in netbeans using java database ?
tnx in advance ! :D
Is This A Good Question/Topic? 0
  • +

Replies To: help ! how to do a simple log in program in netbeans using java da

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10665
  • View blog
  • Posts: 39,608
  • Joined: 27-December 08

Re: help ! how to do a simple log in program in netbeans using java da

Posted 13 October 2010 - 08:50 AM

Moved to Java.

You should take a look at the JDBC API, as well as Swing if you want a GUI. We are happy to help you with code you wrote. Post it using code tags, along with your problems or errors. :)
Was This Post Helpful? 0
  • +
  • -

#3 y0yie_333  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-October 10

Re: help ! how to do a simple log in program in netbeans using java da

Posted 13 October 2010 - 08:58 AM

View Postmacosxnerd101, on 13 October 2010 - 07:50 AM, said:

Moved to Java.

You should take a look at the JDBC API, as well as Swing if you want a GUI. We are happy to help you with code you wrote. Post it using code tags, along with your problems or errors. :)


im a newbie in programming..i just got this code somewhere on the internet ! my problems is..only one account in my database can succesfully login even though the others are correct and truly exist !
why ?

 try{
            stmt =con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
            String SQL = "SELECT * FROM DATOS";
            rs =stmt.executeQuery( SQL );
            rs.first();
            while(rs.next()){
                if(rs.getString("USER_ID").equals(txt1.getText())&& rs.getString("PASSCODE").equals(txt2.getText())){
                    JOptionPane.showMessageDialog(null, "Login Successful");
                  //  PatientReg patient = new PatientReg();
                  //  patient.init();
                  //  patient.buildGUI();
                  //                  loginFrame.hide();
                    con.close();
                    rs.close();
                    stmt.close();
                }
                else{
                    JOptionPane.showMessageDialog(null, "Attempt failed");
                    System.exit(1);
                }
            }
        }catch(SQLException e){
            System.err.println(e.getMessage());
        }
    }

Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10665
  • View blog
  • Posts: 39,608
  • Joined: 27-December 08

Re: help ! how to do a simple log in program in netbeans using java da

Posted 13 October 2010 - 11:16 AM

Only one account should be able to login at a time on your computer. Can you login for the others when you don't have any running sessions? For security reasons, you really don't want to have three separate sessions open at once.

Also, I advise against copying code from other sources, especially when you don't feel comfortable writing the code yourself. It makes for a debugging nightmare when you come across troubles integrating it or setting it up with your other code or tools. Take some time to look at online tutorials, like the Sun tutorial, and write the code yourself. You will learn a lot more that way. If you've never written a line of code before, perhaps JDBC is a ways off. Start with the basic and introductory material, and get up to speed on that before pursuing more advanced topics.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1