Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Permissions in Java

  1. #1
    Junior Member
    Join Date
    May 2021
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Permissions in Java

    please help
    اI have a table named users
    It has a field named admin Takes a numeric value either 1 or 0
    If it is 1, it is open jframe1, and if it is 0 not opend any jframe
    the code is :

    String sql = "select * from users where user_name='" + txtusername.getText() + "' and USER_PASS='" + txtuserpass.getText() + "'";

    pst = conn.prepareStatement(sql);
    rs = pst.executeQuery();
    if (rs.next()) {

    if (rs.ADMIN ==1);
    new form_table2_station().setVisible(true);

    } else {
    JOptionPane.showMessageDialog(null, "Invalid username or Password");
    }
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null, e);
    }

    My question is here in this code
    if (rs.ADMIN ==1);
    new jframe1().setVisible(true);

    admin field is in the table
    I'm sure there is an error in the iF sentence
    How to write the correct code

    thank you

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Permissions in Java

    an error in the iF sentence
    Your compiler should be showing a warning on that if statement. Something like:
    warning: [empty] empty statement after if

    Add the -Xlint option to the compiler's options so that it will give the above warning.

    The empty statement is caused by the ;

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: October 18th, 2019, 04:54 AM
  2. JApplet (java runtime permissions)
    By KAJLogic in forum Java Theory & Questions
    Replies: 15
    Last Post: June 26th, 2014, 11:49 AM
  3. File Permissions?
    By bgroenks96 in forum Java Theory & Questions
    Replies: 8
    Last Post: July 9th, 2011, 01:02 PM
  4. Permissions?
    By Vindicator in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 16th, 2010, 05:14 PM