i have been having problems for a few weeks, got some compilation problems. hope tat someone can help me with my project.thanks! // Java core packages import java.awt.*; import java.awt.event.*; // Java extension packages import javax.swing.*; public class TestingLogin extends JFrame { private JTextField nameField; private JPasswordField passwordField; private JButton loginButton, exitButton; private JLabel label1; //****************************************************** String dialogmessage; String driver="sun.jdbc.odbc.JdbcOdbcDriver"; String url="jdbc dbc:try"; String dialogf = "LOGIN FAILED"; String output = " "; int dialogtype = JOptionPane.PLAIN_MESSAGE; //********************************************************** public TestingLogin() { super( "TestingLoginPage" ); Container container = getContentPane(); container.setLayout( new FlowLayout() ); Icon nyp = new ImageIcon( "nyp.gif" ); label1 = new JLabel("Student Feedback System", nyp,SwingConstants.LEFT ); // construct textfield with default sizing nameField = new JTextField( 10 ); container.add( nameField ); // construct textfield with default text passwordField = new JPasswordField( 10 ); container.add( passwordField ); // register event handlers TextFieldHandler handler = new TextFieldHandler(); nameField.addActionListener( handler ); passwordField.addActionListener( handler ); // create login button loginButton = new JButton( "Login" ); container.add( loginButton ); // create exit button exitButton = new JButton( "Exit" ); container.add( exitButton );
// create an instance of inner class ButtonHandler loginButton.addActionListener( handler ); exitButton.addActionListener( handler );
setSize( 350, 100 ); setVisible( true ); } // execute application public static void main( String args[] ) { TestingLogin application = new TestingLogin(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } // private inner class for event handling private class TextFieldHandler implements ActionListener { // process text field events public void actionPerformed( ActionEvent event ) { String string = ""; // user pressed Enter in JTextField nameField if ( event.getSource() == nameField ) string = "nameField: " + event.getActionCommand();
// user pressed Enter in JTextField passwordField else if ( event.getSource() == passwordField ) { JPasswordField pwd = ( JPasswordField ) event.getSource(); string = "passwordField: " + new String( passwordField.getPassword() ); } } } //********************************************************************** public void accessDB() { try { String var1 = nameField.getText(); var1 = var1.trim(); String var2 = passwordField.getText(); var2 = var2.trim(); sql = "SELECT STAFFID, PASSWORD FROM Staff WHERE STAFFID='"+var1+"' AND PASSWORD='"+var2+"'"; Class.forName(driver); Connection connection=DriverManager.getConnection(url); Statement statement = connection.createStatement(); boolean hasResults = statement.execute(sql); if(hasResults) { ResultSet result = statement.getResultSet(); // get result from query if(result!=null) { displayResults(result); } connection.close(); } } catch(Exception ex) { JOptionPane.showMessageDialog(null, "Failed to load JDBC/ODBC driver","Message",JOptionPane.INFORMATION_MESSAGE); } } public void displayResults(ResultSet r) throws SQLException { ResultSetMetaData rmeta = r.getMetaData(); int foundrec = 0; int numColumns=rmeta.getColumnCount(); while(r.next()) { String param4 = r.getString(4).trim(); if (param4.equals("Accounts")) { output += "\nTesting"; JOptionPane.showMessageDialog(null, output); } } if(foundrec==0)//field=0 { dialogmessage = "Please Re-Login"; dialogtype = JOptionPane.INFORMATION_MESSAGE; JOptionPane.showMessageDialog((Component) null, dialogmessage, dialogf, dialogtype); nameField.setText(" "); passwordField.setText(" "); } } //*********************************************************************** // inner class for button event handling private class ButtonHandler implements ActionListener { // handle button event public void actionPerformed( ActionEvent event ) { JOptionPane.showMessageDialog( null,"You pressed: " + event.getActionCommand() ); } } }
this is the compilation results C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:132: cannot resolve symbol symbol : class ResultSet location: class TestingLogin public void displayResults(ResultSet r) throws SQLException ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:132: cannot resolve symbol symbol : class SQLException location: class TestingLogin public void displayResults(ResultSet r) throws SQLException ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:108: cannot resolve symbol symbol : variable sql location: class TestingLogin sql = "SELECT STAFFID, PASSWORD FROM Staff WHERE STAFFID='"+var1+"' AND PASSWORD='"+var2+"'"; ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:110: cannot resolve symbol symbol : class Connection location: class TestingLogin Connection connection=DriverManager.getConnection(url); ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:110: cannot resolve symbol symbol : variable DriverManager location: class TestingLogin Connection connection=DriverManager.getConnection(url); ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:111: cannot resolve symbol symbol : class Statement location: class TestingLogin Statement statement = connection.createStatement(); ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:112: cannot resolve symbol symbol : variable sql location: class TestingLogin boolean hasResults = statement.execute(sql); ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:115: cannot resolve symbol symbol : class ResultSet location: class TestingLogin ResultSet result = statement.getResultSet(); // get result from query ^ C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java:134: cannot resolve symbol symbol : class ResultSetMetaData location: class TestingLogin ResultSetMetaData rmeta = r.getMetaData(); ^ Note: C:\Documents and Settings\013119R\StudentFeedbackSystem\studentfdbk\TestingLogin.java uses or overrides a deprecated API. Note: Recompile with -deprecation for details. 9 errors Tool completed with exit code 1
General questions belong in the other forums, but since I see you've posted a duplicate here in the Applet forum, I'm going to get this thread closed. Please don't post the same question in multiple forums, it creates duplicate conversations and wastes people's time. Thanks, Dave