Applets and Access Database

robinad
robinad used Ask the Experts™
on
Could someone help me with this problem which I'm having during compile time?

Here's my program:

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

public class SignIn extends JApplet
   implements ActionListener {

   private String userid, passwd;
   private String msg = " ";
   private JTextField id;
   private JPasswordField pass;
   private JButton login;
   private Connection conn;
   private PreparedStatement pstmt;
   private ResultSet rst;

   public void init() {
      JLabel idp = new JLabel("User ID:", JLabel.RIGHT);
      JLabel passp = new JLabel("PIN:", JLabel.RIGHT);
      id = new JTextField(9);
      pass = new JPasswordField(9);
      pass.setEchoChar('*');
      login = new JButton("Login");

      // Add user ID and password to the applet.
      add(idp);
      add(id);
      add(passp);
      add(pass);
      add(login);


     // Register to receive action events.
     id.addActionListener(this);
     pass.addActionListener(this);
     login.addActionListener(this);
   }

   // This will select ID_Number and PIN from Customer table.
   private boolean connectToDb() {
      boolean success = false;

      try
      {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        conn = DriverManager.getConnection("jdbc:odbc:angie", " ", " ");                                           success = true;
      }
      catch (ClassNotFoundException e)
      {
        e.printStackTrace();
      }
      catch (SQLException e)
      {
        e.printStackTrace();
      }
      return success;
     }  // End of connectToDb().

        public boolean validateUser()
        {
          userid = id.getText();
          passwd = pass.getText();
          boolean success = false;

          try
          {
            pstmt = conn.prepareStatement("select ID_Number, PIN from Customer where (ID_Number = 'userid' and PIN = 'passwd')");
            rst = pstmt.executeQuery();

            while (rst.next())
            {
              String dbId = rst.getString(1);
              String dbPswd = rst.getString(2);

              if(userid.equals(dbId) && passwd.equals(dbPswd))
                success = true;
            }
       }
       catch (SQLException e)
       {
         e.printStackTrace();
       }
       return success;
       }

   // User pressed Login.
   public void actionPerformed(ActionEvent ae) {
      String str = ae.getActionCommand();
         if(str.equals("Login")) {
             if (connectToDb() == true && validateUser() == true) {
               msg = "You have successfully logged in.";
             }
             else {
               msg = "You have entered an invalid User ID/PIN.";
             }
             repaint();
         }
      }

    // Prints the string to the screen.
    public void paint (Graphics g) {
       g.drawString(msg, 6, 100);
    }
}


The error which I see is:

Note: SignIn.java uses or overrides a deprecated API.
Note: Recompile with -deprecated for details.

Not sure what -deprecated means....Need help understanding and a solution to the problem. Thanking you in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
deprecated means outdated.  What this error means is that you have intentionally used an old function.  If you wish to continue using the older function, you should compile your application with the -deprecated option so that the compiler knows you intended to do that.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Recommendation: Accept Comment from Twalgrove
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

DominicCronin
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial