connectivity with access

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)
        {
        }


    }
}









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
J2ME connectivity to ms access
J2ME connectivity to ms access  How to establish client server connectivity to access ms access database on the server side? I have made the odbc connection. Plz help me in the coding part.. Dont know how to start
Advertisements
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
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
audio files in jdbc connectivity with ms-access - JDBC
audio files in jdbc connectivity with ms-access  i need to know how to retrieve audio files through jdbc connectivity with ms-access and how to play... static void main(String[] args) { try{ String url="jdbc:odbc:access"; File
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
Access Specifiers and Access Modifiers
Access Specifiers and Access Modifiers  What are Access Specifiers and Access Modifiers
database connectivity
database connectivity  describe java program steps in order to get connectivity to database along with example
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
access specifiers and access modifiers
access specifiers and access modifiers  I want a powerpoint presentation for access specifiers and access modifiers. Please send me the same and soon
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, Java Database Connectivity
tutorials. Java Database Connectivity or JDBC for short is Java bases API... Server, MS Access etc. It gives necessary tools to make a connection... its implementations for each database. For example to access oracle database
DB connectivity - EJB
DB connectivity  DB connectivity
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
in connectivity - Hibernate
insertted  Hi friend, This is connectivity and hibernate configuration
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.
database connectivity - JDBC
database connectivity  can u ppl pls provide me with database connectivity programs with MSacces   Hi Friend, If you havn't create your... a user DSN 4. Select Microsoft Access Driver(*.mdb) 5. Select database name
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
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
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
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
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
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
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou
ms access
ms access  how to delete the autonumber from ms access using java delete code
Database connectivity Hibernate mysql connection.
Database connectivity Hibernate mysql connection.  How to do database connectivity in Hibernate using mysql
Eclipse Connectivity - JDBC
Eclipse Connectivity  Hello Friends.. I want to do connectivity... connectivity..and which plugins are required for it. i have try to do connectivity but i got given below error. "Error Occured Error
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 do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want to access it via Code. Can anyone help me ? Please give reply urgent...   give me reply
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
Database Connectivity Withe Oracle
Database Connectivity Withe Oracle  Develop a program to perform the database driven operation like insert, Delete, Update and select. To perform the above operations create one table named Employee. Field Name Field Type EmpId
jdbc oracle connectivity problem
jdbc oracle connectivity problem  Hi All, I am trying to connect my swing application to oracle DB . but class.forname is giving error. Please suggest me if there is some different way to connect swing application to oracle
how to access the MS ACCESS database with java
how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records of ms access with java   Java MS Access database connectivity Follow
ModuleNotFoundError: No module named 'spectral-connectivity'
ModuleNotFoundError: No module named 'spectral-connectivity'  Hi...: No module named 'spectral-connectivity' How to remove the ModuleNotFoundError: No module named 'spectral-connectivity' error? Thanks   Hi
Ms Access
Ms Access   How to get query for Primary key from MsAccess?   SELECT column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name = 'data';   SELECT column_name FROM INFORMATION_SCHEMA.KEY_COLUMN
Access specifiers
Access specifiers  Why we are giving "public static void main"? How many times declared the main()?   Hi Friend, We used this statement as it provides the "entry point" for the program. Whenever the program executes

Ads