Java Programming - How to connect a ms access database to a swing application using netbeans.
Hi everyone,
Can anyone please tell me how can I connect my very simple swing loggin form that I created with netbeans 5.5 to a ms access database ?.
I've included the source code from the ide's source window and if anyone can please download my project from the url below @ esnips & correct it & mail it back to my e-mail address- <shehangrp@gmail.com> ,it would be a great help !.But if that's not possible the source code is given below.
URL: http://www.esnips.com/web/Java-Online
//
My Code From GUI's Code Window :
package nibmdcsd;
import java.awt.Dimension;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.Point;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.awt.*;
import java.util.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.event.*;
public class loggin extends javax.swing.JFrame {
//Here I need to include the code to connect to the dataBase !.
JFrame frame;
public loggin() {
initComponents();
// Center in the screen
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
setLocation(new Point((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.width) / 2));
}
# IDE Generated Code #
private void extActionPerformed(java.awt.event.ActionEvent evt) {
int s = JOptionPane.showConfirmDialog(frame,"Are You Sure You want to Exit ?","Confirm Exit",JOptionPane.YES_NO_OPTION);
if(s==0){System.exit(0);} else{}
}
private void rstActionPerformed(java.awt.event.ActionEvent evt) {
usr.setText("");
pwd.setText("");
}
private void logActionPerformed(java.awt.event.ActionEvent evt) {
String user = usr.getText();
String pass = pwd.getText();
// Here I need to include code to compare the data entered with the value in the database to
// loggin the user as in a normal user loggin process !.
}
public static void main(String args[]) {
}
// Variables declaration - do not modify
private javax.swing.JButton ext;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JButton log;
private javax.swing.JPasswordField pwd;
private javax.swing.JButton rst;
private javax.swing.JComboBox stat;
private javax.swing.JTextField usr;
// End of variables declaration
}
// As you can see I'm really really new to java & swing so it would be of great help if anyone of you can help me!. Thank you in advance & may god bles you !.

