Results 1 to 6 of 6
Like Tree2Likes
  • 1 Post By gimbal2
  • 1 Post By gimbal2

Thread: Need help! Making a Login system!

  1. #1
    spero33 is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Post Need help! Making a Login system!

    hello there! im realy new to java programming. Im working on a School project, i have a error whit { or } in my code, but i can't see it, can someone see here se the where the error is?



    package loginsystem;

    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;

    public class LoginSystem {

    Connection con;
    Statement st;
    ResultSet rs;

    JFrame f = new JFrame("INLOGIN");
    JLabel l = new JLabel("Username");
    JLabel l1 = new JLabel("Password");
    JTextField t = new JTextField(10);
    JTextField t1 = new JTextField(10);
    JButton b = new JButton("Login");

    public LoginSystem()
    {

    connect();
    frame();

    }

    public void connect(){

    try{



    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    Class.forName(driver);

    String db = "jdbc:odbc:innlogin";
    con = DriverManager.getConnection(db);
    st = con.createStatement();
    }
    catch(Exception ex)
    {

    }
    }

    public void frame()
    {

    f.setSize(600, 400);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);

    JPanel p = new JPanel();

    p.add(l);
    p.add(t);
    p.add(l1);
    p.add(t1);
    p.add(b);

    f.add(p);

    b.addActionListener(new ActionListener(){

    @Override
    public void actionPerformed(ActionEvent e)
    {
    try
    {


    String user = t.getText().trim();
    String pass = t1.getText().trim();

    String sql = "select user,pass from Table1 where user = '"+user+"'and pass = '"+pass+"'";
    rs = st.executeQuery(sql);

    int count = 0;
    while(rs.next())
    {
    count = count + 1;
    }

    if(count == 1)
    {
    JOptionPane.showMessageDialog(null, "Bruker funnet!");
    }
    else if(count > 1)
    {
    JOptionPane.showMessageDialog(null, "duplikerte brukere får ikke tilgang!");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "Bruker ikke funnet!");
    }
    }
    catch(Exception ex){

    }
    }

    }
    }

    public static void main(String[] args) {

    new LoginSystem();

    }

    }


    Thank you for helping me!

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,776
    Rep Power
    5

    Default Re: Need help! Making a Login system!

    Not like this. Use the advanced post editor and format the code using the code button to make it readable.

    If you have problems with mismatched {}, properly indenting your code should help you to find it.
    spero33 likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    spero33 is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: Need help! Making a Login system!


  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,776
    Rep Power
    5

    Default Re: Need help! Making a Login system!

    Don't post it on another site, post it here.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    spero33 is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: Need help! Making a Login system!

    its okay now i found the fould, the fail was i haven end } with }); :D so ty gimbal2 for helping :D

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,776
    Rep Power
    5

    Default Re: Need help! Making a Login system!

    Your main problem was thus lack of patience.

    As to your PM, please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and learn how to post code on this forum.
    spero33 likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Help making a Menu system for Student List System
    By jason3460 in forum New To Java
    Replies: 0
    Last Post: 12-09-2012, 01:39 PM
  2. Login System Netbeans!!!
    By hassaanid2012 in forum New To Java
    Replies: 8
    Last Post: 06-10-2012, 09:31 PM
  3. Login System
    By Chaosje in forum New To Java
    Replies: 3
    Last Post: 05-04-2011, 11:37 PM
  4. Database for Login system
    By Chris_X in forum JDBC
    Replies: 1
    Last Post: 11-27-2010, 01:14 AM
  5. Applet Login System Tutorial
    By Free-JavaTutorials in forum Java Applets
    Replies: 0
    Last Post: 03-15-2008, 02:51 AM

Tags for this Thread

Posting Permissions

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