Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners connectivity with access
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Bhagirath Singh
connectivity with access
2 Answer(s)      3 years and 6 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.


Advertisement
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
database connectivity
database connectivity  how to create database connectivity between HTML and sql server2005
database connectivity
database connectivity  describe java program steps in order to get connectivity to database along with example
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
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
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
JDBC CONNECTIVITY
file in environment variable.   Java Mysql connectivity Other JDBC
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
in connectivity - Hibernate
insertted  Hi friend, This is connectivity and hibernate configuration
DB connectivity - EJB
DB connectivity  DB connectivity
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
Access Specifiers and Access Modifiers
Access Specifiers and Access Modifiers  What are Access Specifiers and Access Modifiers
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
sql connectivity through java
sql connectivity through java  i want an example for java db through sql connection. Thanks in advance
Validate telnet connectivity
Validate telnet connectivity  How to validate telnet connectivity in my java code
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
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
 

 

 

DMCA.com