password verification in the database
I am using JDeveloper 3.1 to develop a fixed asset application. I have designed a logon frame with userid Textfield,password Textfield, OK button and Cancel button so that all users should enter a USERID and PASSWORD at the logon frame. When the OK button is clicked the application should authenticate the user whose userid and password are stored in a table calles USERAUTHENTICATION in Oracle database. After which the main application frame should display. The first problem i'm having is that the driver is not loading and Hence it does not do what i want. Can any one help me?. my email:winnersln@onebox.com
Below is my code:
package asspackage;
import javax.swing.*;
import java.awt.*;
import oracle.jdeveloper.layout.*;
import java.awt.event.*;
import java.sql.*;
import borland.jbcl.dataset.*;
import borland.sql.dataset.*;
/**
* A Swing-based top level window class.
* @author Luper J Noah
*/
public class FrameLogon extends JFrame implements ActionListener
{
JPanel jPanel1 = new JPanel();
TextField userIdtextField = new TextField();
XYLayout xYLayout1 = new XYLayout();
TextField passwordtextField = new TextField();
Button buttonCancel = new Button();
Label labelUserId = new Label();
Label labelpassword = new Label();
Button buttonOk = new Button();
/**
* Constructs a new instance.
*/
public FrameLogon() {
super();
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
// DrawFrame();
}
public static void main(String[] args)
{
FrameLogon frm = new FrameLogon();
frm.DrawFrame();
}
// public static void main(String[] args)
public void DrawFrame()
{
// JFrame FrameLogon = new FrameLogon();
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
if ( frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
// addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
setVisible(true);
}
/**
* Initializes the state of this instance.
*/
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
this.setTitle("Logon");
this.setSize(new Dimension(400, 300));
userIdtextField.setText("userIdtextField");
//userIdtextField.addActionListener( this );
passwordtextField.setText("passwordtextField");
//passwordtextField.addActionListener( this );
buttonCancel.setLabel("Cancel");
buttonCancel.setActionCommand("Cancel");
buttonCancel.addActionListener( this );
labelUserId.setText("User Id");
labelpassword.setText("Password");
buttonOk.setLabel("Ok");
buttonOk.setActionCommand("OK");
buttonOk.addActionListener( this );
this.getContentPane().add(jPanel1, new XYConstraints(0, 0, -1, -1));
this.getContentPane().add(passwordtextField, new XYConstraints(141, 100, 118, -1));
this.getContentPane().add(userIdtextField, new XYConstraints(141, 53, 118, -1));
this.getContentPane().add(buttonCancel, new XYConstraints(221, 156, 62, 32));
this.getContentPane().add(labelUserId, new XYConstraints(58, 51, -1, -1));
this.getContentPane().add(labelpassword, new XYConstraints(59, 94, 59, -1));
this.getContentPane().add(buttonOk,new XYConstraints(133, 155, 63, 33));
}
public void UserAuthentication() {
String username, password;
username = new String();
password = new String ();
Connection connection1;
try
{
//Find the driver class
connection1 = setConnection (new
ConnectionDescriptor("jdbc:oracle:thin:@:1521:ORA8",
"easset", "easset",true,
"oracle.jdbc.driver.OracleDriver"));
// connection1 = DriverManager.getConnection("jdbc.Oracle.thin:@Luper.World","easset","easset");
//create a statement
Statement sqlstmt = connection1.createStatement();
ResultSet mySet;
try
{
//execute the query
//ResultSet mySet = sqlstmt.executeQuery("select * from authentication");
sqlstmt.executeQuery("select * from authentication");
//get the resultset
//ResultSet mySet = sqlstmt.getResultSet();
mySet = sqlstmt.getResultSet();
//advance to the next row
while (mySet.next())
{
username = mySet.getString("username");
password = mySet.getString("password");
// userIdtextField.setText(password);
// passwordtextField.setText(username);
}
}
catch (Exception ex){
ex.printStackTrace();
}
}
//catch(Exception e)
//{
// userIdtextField.setText( e.toString() );
// passwordtextField.setText(username);
//}
catch(NullPointerException ex)
{
userIdtextField.setText( ex.toString() );
passwordtextField.setText(" " + connection1);
}
catch(SQLException ex)
{
userIdtextField.setText( ex.toString() );
passwordtextField.setText(username);
}
catch(ClassNotFoundException ex)
{
userIdtextField.setText( ex.toString() );
passwordtextField.setText(username);
}
}
void this_windowClosing(WindowEvent e) {
this.dispose();
}
// public void windowClosing(WindowEvent e) {
// this_windowClosing(e);
// }
public void actionPerformed(ActionEvent e)
{
// buttonOk_actionPerformed(e);
if ( e.getActionCommand().equals("OK") )
{
UserAuthentication();
// AppMainFrame.show();
// dispose();
// if authentication failure
// return;
// if authentication success
try
{
// new AppMainFrame();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
}