Home Answers Viewqa Java-Beginners connectivity with access

 
 


Bhagirath Singh
connectivity with access
2 Answer(s)      a year and 11 months ago
Posted in : Java Beginners

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 Pages:
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
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
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
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
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
JDBC Connectivity - JDBC
with MS-Access database?  Hello Use this code import java.sql...."); // set this to a MS Access DB you have on your machine...:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="; database
connectivity - JSP-Servlet
connectivity  hi, im doing a project in bioinformatics.I wish to create a webserver,for that I have to access the datas from a databse file named ProteinDataBank which is already available.I want to know the coding for how
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
**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
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... implementations for each database. For example to access oracle database we need the JDBC
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
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
MS Access - JSP-Servlet
in Connectivity in MS Access : import java.sql.*; public class... stepts 1.to configure the ms access database to your system control panel
MS Access - JDBC
= stmt.executeQuery(query); Code to help in Connectivity in MS Access : import... information about MS access database...but still i am having doubt in that topic. My problem is : Is there any jar to connect MS Access and java ... because
JDBC access database
JDBC access database       JDBC is a Java Database Connectivity. The JDBC Connectivity provides API classes... that helps in understanding JDBC access database. The code illustrates the list
JDBC - Java Database Connectivity Tutorial
JDBC - Java Database Connectivity Tutorials       Java Database Connectivity... interface that allows the Java programmers to access database management system
stock checking in java with backend as access
stock checking in java with backend as access  Hi, I am doing a project in java,Can i able to know how to check the stock availability of a product in java...my back end connectivity is ms-access from the database ,i hv
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  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
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
How to Create and display Reports in Java with Database connectivity - Java Beginners
How to Create and display Reports in Java with Database connectivity  Hello Sir , I have Created Student Admission Form with Swing and MS Access 2007 Database Connection,when i will click on Print button it shows the report
in connectivity - Hibernate
insertted  Hi friend, This is connectivity and hibernate configuration
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.
JDBC CONNECTIVITY
connectivity Other JDBC Tutorials
DB connectivity - EJB
DB connectivity  DB connectivity
Access Specifiers and Access Modifiers
Access Specifiers and Access Modifiers  What are Access Specifiers and Access Modifiers
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 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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.