connectivity with access

Ads
 

connectivity with access

how to connect with data base with access sheet. in my application form there is two JTextArea and Two JComboBox.

View Answers

June 28, 2011 at 12:57 PM

Is this Access database or excel sheet. Do you want to display the values in Textarea and Combobox?

Please specify some more details.


June 28, 2011 at 11:13 PM

I AM WRITING THE CODE HERE PLS GIVE ME A DEMO CONNECT WITH ACCESS DATABASE.....

import java.util.*;
import java.io.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;



public class Air
{
    public static void main(String []args)
    {
        JFrame frame=new AirFrame();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
    }

}
class AirFrame extends JFrame implements ActionListener
{   

    JPanel panel;
    JPanel panel1;
    JPanel panel2;

    JLabel title;
    JLabel aircode,source,destination;
    JComboBox cb,cb1,cb2;
    JButton save,reset,exit;

    public AirFrame()
    {
        setSize(1024,720);
                setLocation(120,40);
                setResizable(false);
        setTitle("Air-Line");

        Container contentPane=getContentPane();

        title=new JLabel("Radhe Krishna Air-Line Ticket Reservation");
        title.setSize(1024,40);
        title.setLocation(250,20);
        title.setFont(new Font("Lucida Handwriting", Font.PLAIN, 24));
        title.setForeground(Color.red); 


        aircode=new JLabel("AIRCODE");
        aircode.setSize(200,20);
        aircode.setLocation(120,120);
        aircode.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        aircode.setForeground(Color.green);

        String[]  Aircode={ "Select AirCode", "Jet Airways", "Kingfisher Airways" };
        cb = new JComboBox(Aircode);
        cb.setSelectedIndex(0);
        cb.setSize(150, 20);
        cb.setLocation(230,120);

        source=new JLabel("SOURCE");
        source.setSize(200,20);
        source.setLocation(120,170);
        source.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        source.setForeground(Color.green);


        String[]  Source={ "Select Source","Agartala","Agatti Island","Agra","Ahmedabad","Aizawl","Allahabad","Amritsar","Aurangabad","Bagdogra","Bangalore","Belgaum","Bellary","Bengaluru","Bhavnagar","Bhopal","Bhubaneshwar","Bhuj","Bikaner","Bombay","Calcutta","Calicut","Chandigarh","Chennai","Cochin","Coimbatore","Dehradun","Delhi","Dharamshala","Dibrugarh","Dimapur","Diu","Gaya","Goa","Gorakhpur","Guwahati","Gwalior","Hubli","Hyderabad","Imphal","Indore","Jabalpur","Jagdalpur ","Jaipur","Jammu","Jamnagar","Jamshedpur","Jindal","Vidyanagar","Jodhpur","Jorhat","Kandla ","Kanpur ","Khajuraho","Kochi","Kolhapur","Kolkata","Kulu","Latur","Leh","Lilabari","Lucknow","Ludhiana","Madras","Madurai","Mangalore","Mumbai","Mysore ","Nagpur ","Nanded","Nasik ","New Delhi","Pantnagar","Pathankot","Patna","Porbandar","Port Blair ","Pune","Raipur","Rajahmundry","Rajkot","Ranchi","Salem","Shillong ","Shimla ","Sholapur","Silchar","Srinagar","Surat","Tezpur","Thiruvananthapuram","Tiruchirapally","Tirupati","Trichy","Trivandrum","Tuticorin","Udaipur","Vadodara","Varanasi","Vijayawada","Vishakhapatnam" };

        cb1 = new JComboBox(Source);
        cb1.setSelectedIndex(0);
        cb1.setSize(150, 20);
        cb1.setLocation(230,170);

        destination=new JLabel("DESTINATION");
        destination.setSize(200,20);
        destination.setLocation(550,170);
        destination.setFont(new Font("Times New Roman", Font.PLAIN, 20));
        destination.setForeground(Color.green);


        String[]  Destination={ "Select Destination","Agartala","Agatti Island","Agra","Ahmedabad","Aizawl","Allahabad","Amritsar","Aurangabad","Bagdogra","Bangalore","Belgaum","Bellary","Bengaluru","Bhavnagar","Bhopal","Bhubaneshwar","Bhuj","Bikaner","Bombay","Calcutta","Calicut","Chandigarh","Chennai","Cochin","Coimbatore","Dehradun","Delhi","Dharamshala","Dibrugarh","Dimapur","Diu","Gaya","Goa","Gorakhpur","Guwahati","Gwalior","Hubli","Hyderabad","Imphal","Indore","Jabalpur","Jagdalpur ","Jaipur","Jammu","Jamnagar","Jamshedpur","Jindal","Vidyanagar","Jodhpur","Jorhat","Kandla ","Kanpur ","Khajuraho","Kochi","Kolhapur","Kolkata","Kulu","Latur","Leh","Lilabari","Lucknow","Ludhiana","Madras","Madurai","Mangalore","Mumbai","Mysore ","Nagpur ","Nanded","Nasik ","New Delhi","Pantnagar","Pathankot","Patna","Porbandar","Port Blair ","Pune","Raipur","Rajahmundry","Rajkot","Ranchi","Salem","Shillong ","Shimla ","Sholapur","Silchar","Srinagar","Surat","Tezpur","Thiruvananthapuram","Tiruchirapally","Tirupati","Trichy","Trivandrum","Tuticorin","Udaipur","Vadodara","Varanasi","Vijayawada","Vishakhapatnam" };
        cb2 = new JComboBox(Destination);
        cb2.setSelectedIndex(0);
        cb2.setSize(150, 20);
        cb2.setLocation(710,170);


        save=new JButton("SAVE");
        save.setSize(150,20);
        save.setLocation(350,600);
        save.setFont(new Font("Times New Roman", Font.PLAIN, 20));      
        save.setForeground(Color.green);
        save.addActionListener(this);

        reset=new JButton("RESET");
        reset.setSize(150,20);
        reset.setLocation(550,600);
        reset.setFont(new Font("Times New Roman", Font.PLAIN, 20));     
        reset.setForeground(Color.green);
        reset.addActionListener(this);

        exit=new JButton("EXIT");
        exit.setSize(150,20);
        exit.setLocation(750,600);
        exit.setFont(new Font("Times New Roman", Font.PLAIN, 20));      
        exit.setForeground(Color.green);
        exit.addActionListener(this);

        panel=new JPanel();
        panel.setLayout(null);
        panel.setSize(1024, 100);
        panel.setLocation(0, 0);
        panel.setBackground(Color.blue);


        panel1=new JPanel();
        panel1.setLayout(null);
        panel1.setSize(1024, 100);
        panel1.setLocation(0, 0);
        panel1.setBackground(Color.PINK);


        panel2=new JPanel();
        panel2.setLayout(null);
        panel2.setSize(1024, 100);
        panel2.setLocation(0, 0);
        panel2.setBackground(Color.BLUE);


        contentPane.add(panel); 
        contentPane.add(panel1);
        contentPane.add(panel2);

        panel.add(title);
        panel2.add(aircode);
        panel2.add(cb);
        panel2.add(source);
        panel2.add(cb1);
        panel2.add(destination);
        panel2.add(cb2);
        panel2.add(save);
        panel2.add(reset);
        panel2.add(exit);
    }
    public void actionPerformed(ActionEvent e)
    {
// i try the give below code but not store the value//
        Object obj = e.getSource();
        if (obj==save)
        {
            try
            {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:db1");
                PreparedStatement stat= con.prepareStatement("insert into table1 values(?,?,?)");
                stat.setString(1,cb.getName());
                stat.setString(2,cb1.getName());
                stat.setString(3,cb2.getName());


                stat.executeUpdate();
                JOptionPane.showMessageDialog(null,"Record updated");


                con.close();
            }
            catch(Exception err)
            {
                JOptionPane.showMessageDialog(null," "+err);

            }

        }
        if(obj==exit)
        {
            System.exit(0);
        }

        if (obj==reset)
        {
        }


    }
}

Ads









Related Tutorials/Questions & Answers:
connectivity with access
connectivity with access  how to connect with data base with access...; Is this Access database or excel sheet. Do you want to display the values...;Is this Access database or excel sheet. Do you want to display the values in Textarea
Access 2007 database connectivity
source and destination. pls tell me the code of connectivity with access 2007...Access 2007 database connectivity  i design an application form that have two JComboBox as the label(source,destination) and two JButton save
Advertisements
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
connectivity
connectivity  sir i have created a web page for login form and i have also created the related data base in both ms access and oracle 10g now how to store those values in form to databases can u plz hlp me
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**  <p>...; data sources. 2)Click Add button and select the driver Microsoft Access Driver
access
access   This is Nitha Sriram i am having a problem that, i am having a combo box in the JSP page when i select an item from that i am calling the onchange function. In javascript i am getting the value now i want to pass
database connectivity
database connectivity  how to create database connectivity between HTML and sql server2005
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
connectivity with php
connectivity with php  i have make one html form and doing connectivity with php database but when i click on submit button on html form display all coding in php form about connectivity instead of adding data, i used in html
java connectivity
java connectivity  hi........ Can u help me to do connectivity between java and weka??????? weka is a data mining tool which allows to do prediction, classification etc.... i want to do connectivity between weka and java can u
connectivity problem
connectivity problem  i am facing error in Class.for name statement... connectivity still i am facing this error* ================================oracle connectivity program============================ import java.sql.*; import
JDBC CONNECTIVITY
file in environment variable.   Java Mysql connectivity Other JDBC
connectivity with mysql
connectivity with mysql  if this code of roseindia doesnt work,then what to do..cant connect with my sql http://www.roseindia.net/tutorial/php/phpdatabase/Check-PHP-MySQL-Connectivity.html   Please visit the following
connectivity
connectivity
JDBC CONNECTIVITY
connectivity Other JDBC Tutorials
connectivity step
connectivity step  sir.pls give me step one by one for connect the java program to oracle.   Follow these steps: 1) Import the following packages in your java file:*** import java.sql.*; import oracle.jdbc.driver.
ModuleNotFoundError: No module named 'connectivity'
ModuleNotFoundError: No module named 'connectivity'  Hi, My Python... 'connectivity' How to remove the ModuleNotFoundError: No module named 'connectivity' error? Thanks   Hi, In your python
Validate telnet connectivity
Validate telnet connectivity  How to validate telnet connectivity in my java code
sql connectivity through java
sql connectivity through java  i want an example for java db through sql connection. Thanks in advance
Access Specifier
Access Specifier  What's the usage of getter and setter in access specifier? Thank You
Access level
Access level  Which access level allows exclusive access to the attributes and methods that belong to a class or classes derived from that class? default protected public private
jdbc connectivity to mysql tutorial
jdbc connectivity to mysql tutorial  here is complete jdbc connectivity to mysql tutorial for newbies. Person who don't even know how to install mysql and don't know about which driver to use can do with ease
How to Access MS Access in jar.
How to Access MS Access in jar.  how do i access my Ms-Access file... to access it via Code or is their any alter-native?? Do i need any Driver to do this ... i m able to access a Ms-access via JDBC but cant find the file wen
Database connectivity Hibernate mysql connection.
Database connectivity Hibernate mysql connection.  How to do database connectivity in Hibernate using mysql
VoIP Access
VoIP Access Mediatrix VoIP Access Device The Mediatrix 2102... modem - without the need for an external router. The Mediatrix 2102 VoIP access... residential IP telephony. There are few Features: * IP connectivity for analog
oracle connectivity problem with netbeans
oracle connectivity problem with netbeans  sir I am using oracle.... for this after adding new driver(ojdbc6.jar) in services tab I got connectivity with oracle... of simple connectivity with oracle in this I am giving driver details
j2me mysql connectivity
j2me mysql connectivity  I do a project on reservation using j2me. I need a connectivity to a MYSQL database. How do I do this Thanks and regards Karthiga
database connectivity problem
database connectivity problem  what if client dont have database with them then what is other way to run successfully our programm   Please visit the following link: http://www.roseindia.net/jdbc
ms access
ms access  how to delete the autonumber from ms access using java delete code
JDBC with access as backend
JDBC with access as backend  Jdbc connectivity in java to MS Access for retrieving data between two dates   Here is an example that fetches data between two dates from MS access database. import java.sql.*; class

Ads