jdbc odbc

jdbc odbc

Sir, i want to get the selected value from JCombobox to ms access database...means the value which i selected it may me text or number simply i just want to print in ms access or stored on ms acess databse in selected comlumn???

View Answers

December 28, 2012 at 4:19 PM

Hi Devendra, Here I am giving a sample code against your problem. you can read this complete tutorial from the link given below

http://www.roseindia.net/java/example/java/swing/store-jcombobox-selecteditem-value-msaccess.shtml

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class GetValueOfJcomboBox implements ActionListener{

    String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
    String petName ="";

private void createUI()
    {
        JFrame frame = new JFrame("JDBC All in One");
        JComboBox petList = new JComboBox(petStrings);
        petList.setPreferredSize(new Dimension(10,20));
        petList.setSelectedIndex(0);
        petList.addActionListener(this);
        Container cn = frame.getContentPane();
        JPanel p= new JPanel();             
        p.add(petList);
        cn.add(p);
        Insets insets = cn.getInsets();
        Dimension size = p.getPreferredSize();
        p.setBounds(80 + insets.left, 135 + insets.top,
                size.width, size.height);
        cn.setLayout(new BoxLayout(cn,BoxLayout.Y_AXIS));
        frame.add(petList);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

@Override
public void actionPerformed(ActionEvent e)
{
    JComboBox cb = (JComboBox)e.getSource();
    petName = (String)cb.getSelectedItem();
    for(String s : petStrings)
    {
        if(petName.equals(s))
        {
            addOperation();
            System.out.println("Value added successfully");
        }       
      }
    }

 private void addOperation()
 {
    try
    {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:swing");
        String sql = "INSERT INTO PetTable(petName) Values('"+petName+"')";
        Statement st = con.createStatement();
        st.execute(sql);
        JOptionPane.showMessageDialog(null, "Record Added Succesfully.","Record Added",
                JOptionPane.INFORMATION_MESSAGE);
    }
    catch(Exception e)
    {
        JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
                JOptionPane.ERROR_MESSAGE);
    }
  }
 public static void main(String args[])
 {
     GetValueOfJcomboBox gvb = new GetValueOfJcomboBox();
     gvb.createUI();
 }
}// class closed









Related Tutorials/Questions & Answers:
jdbc odbc
jdbc odbc   i have two tables in database 1table's attribute is foreign key of another in this case how to retrive value from both table and show in a gridview combine using java code   Sql query to retrieve values
jdbc odbc
= DriverManager.getConnection("jdbc:odbc:swing"); String sql = "INSERT...jdbc odbc  Sir, i want to get the selected value from JCombobox to ms...("JDBC All in One"); JComboBox petList = new JComboBox(petStrings
Advertisements
JDBC-ODBC
JDBC-ODBC  HI what should i give names for DNS and TNS in Administrative Tools so that there will be connection between Database (oracle) and java.Actually how to operate Administrative Tools
JDBC-ODBC
JDBC-ODBC  HI what should i give names for DNS and TNS in Administrative Tools so that there will be connection between Database (oracle) and java.Actually how to operate Administrative Tools
jdbc odbc
jdbc odbc  i want to fetch the data from the ms access and print on ms word for printing purpose?? the whole program is in swing to ms acess connectivity.. the whole set up is perform only printing part is remaining? so help me
jdbc odbc
jdbc odbc  i want to fetch the data from the ms access and print on ms word for printing purpose?? the whole program is in swing to ms acess connectivity.. the whole set up is perform only printing part is remaining? so help me
The JDBC-ODBC Bridge.
The JDBC-ODBC Bridge.  Are there any ODBC drivers that do not work with the JDBC-ODBC Bridge
Java Jdbc-odbc
Java Jdbc-odbc  What is the difference between JDBC and ODBC
Java JDBC ODBC
Java JDBC ODBC  What is the difference between JDBC and ODBC
jdbc odbc connection
jdbc odbc connection  i need a program in java which uses a jdbc odbc... computer and then access in your Java program.ADS_TO_REPLACE_1 Read the JDBC ODBC..._TO_REPLACE_2 Example of JDBC ODBC bridge. Thanks
What is ODBC - JDBC
What is ODBC  What is Java ODBC and JDBC?   Method of type.... | JDBC Driver | ODBC Driver
JDBC-ODBC Bridge multi-threaded.
JDBC-ODBC Bridge multi-threaded.  Is the JDBC-ODBC Bridge multi-threaded
JDBC ODBC related problem
JDBC ODBC related problem  i WANT HELP RELATED TO JDBC CONNECTIVITY WITH MS ACCESS.. HERE IS MY FULL CODE... import java.awt.Container; import... con; con = DriverManager.getConnection("jdbc:odbc:Digambar
JDBC-Odbc Connection
JDBC-ODBC Connection       JDBC-ODBC Connection is a JDBC driver that translates the operation in  JDBC into ODBC. For ODBC,it is a normal java application program. This bridge
jdbc odbc sql server exception
jdbc odbc sql server exception  Hi, I am trying to use sql server with java jdbc odbc but I am getting this exception java.sql.SQLException: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '@P1
JDBC ODBC Connection In Java
JDBC ODBC Connection In Java In this section we will read about the various aspects of JDBC ODBC such as, JDBC-ODBC bridge, JDBC ODBC connection, how to create DSN etc. JDBC-ODBC Bridge As its name JDBC-ODBC bridge, it acts like
JDBC-Odbc Connectivity
JDBC-ODBC Connectivity       The code illustrates an example from JDBC-ODBC...;static private final String connection = "jdbc:odbc
jdbc,odbc,MySQL,swing - Java Beginners
jdbc,odbc,MySQL,swing  write a code that displays a menu list of all available database drivers in a window,and allows the user to select any driver... to the selected database driver.It is very well known as jdbc front end of a database
how to set fetch size for jdbc odbc driver
how to set fetch size for jdbc odbc driver  What is the default fetch size for the JDBC ODBC driver and how can i fetch a set of results for JDBC ODBC driver?   Fetching results JDBC ODBC Driver A. The default fetch
Connect to MS Acces wothout using ODBC but JDBC - JDBC
Connect to MS Acces wothout using ODBC but JDBC  Hi, I want to connect my MS Access using JDBC but not ODBC. Please help me out. Thanks
Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.
Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.  Is there a way to find the primary key(s) for an Access Database table? Sun's JDBC-ODBC driver does not implement
Connection using Jdbc-odbc bridge Driver
Connection using JDBC-ODBC bridge driver JDBCExample.java..."); con=DriverManager.getConnection("jdbc:odbc:datastud");  ... program, Jdbc-Odbc bridge driver create connection between java application
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver  Can any please help it is very urgent. I tried to read excel sheet using ODBC..."); Connection conn = DriverManager.getConnection("jdbc:odbc:excel
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.  please provide online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.   Create table test
ODBC connection
ODBC connection   import java.sql.*; import java.util.*; public...)c.newInstance(); String s="jdbc:oracle:thin:@localhost:1521:ORCL... ODBC program,bt here I am getting error i.e Exception in Thread "main
ODBC connection
ODBC connection   import java.sql.*; import java.util.*; public...)c.newInstance(); String s="jdbc:oracle:thin:@localhost:1521:ORCL... ODBC program,bt here I am getting error i.e Exception in Thread "main
ODBC connection
ODBC connection   import java.sql.*; import java.util.*; public...)c.newInstance(); String s="jdbc:oracle:thin:@localhost:1521:ORCL... ODBC program,bt here I am getting error i.e Exception in Thread "main
odbc - Java Beginners
What is odbc connection  What is odbc connection
Product Components of JDBC
. The JDBC Driver Manager. 3. The JDBC Test Suite. 4. The JDBC-ODBC Bridge.ADS... of  Java Platform Enterprise Edition (J2EE).  4. The JDBC-ODBC Bridge. The JDBC-ODBC bridge, also known as JDBC type 1 driver is a 
Java JDBC
Java JDBC   Is the JDBC-ODBC Bridge multi-threaded
odbc MS EXCEL
odbc MS EXCEL  hey my whole database is stored in MS Excel. so please tell me that can we connect to that database. if yes, how to do that. please help me out i am doing it in netbeans can please tell me the steps
XLS JDBC Example
comes with ODBC driver therefore you should use JDBC - ODBC bridge driver... = DriverManager.getConnection("jdbc:odbc:datasource", "", ""); stmt... .style1 { background-color: #FFFFCC; } XLS JDBC XlS JDBC driver
jdbc - JDBC
drivers for concurrent access?   Question: Is the JDBC-ODBC Bridge multi-threaded? Answer: No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods
jdbc
= DriverManager.getConnection("jdbc:odbc:student"); Class.forName... using jdbc connection   import java.sql.*; public class CreateTable
jdbc
=DriverManager.getConnection("jdbc:odbc:access","",""); Statement st=null; st...jdbc  how to update int values of ms-access in jdbc program?   In MS Access database, use Number data type for int values. import
how to connect java with ms access using odbc in eclipse
"); //Connection con = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft... = DriverManager.getConnection("jdbc:odbc:student.accdb"); Statement st...how to connect java with ms access using odbc in eclipse  import
JDBC - JDBC
of JDBC drivers available. They are:Type 1 : JDBC-ODBC Bridge Driver A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers. Note that some... technology application is not important. For information on the JDBC-ODBC bridge
PHP SQL ODBC
PHP SQL ODBC       This example illustrates how to create an ODBC Connection for php application. Follow the given steps to create an ODBC connection to a MS Access Database: 
ModuleNotFoundError: No module named 'odoo8-addon-import-odbc'
ModuleNotFoundError: No module named 'odoo8-addon-import-odbc'  Hi...: No module named 'odoo8-addon-import-odbc' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-import-odbc' error? Thanks   
Query On JDBC - JDBC
Query On JDBC  Hello , I am trying to migrate from xls TO mysql in Linux platform.. I'm using JDBC ODBC Bridge Driver..String url = "jdbc:excel:./personal1.xls";System.out.println
Jdbc Driver - JDBC
JDBC Driver Types  Type of JDBC Driver  four..Type 1(JDBC-ODBC Driver)Type 2(java native driver)Type 3Type 4  Type of JDBC... as: * JDBC-ODBC bridge plus ODBC driver, also called Type 1. * Native-API
Php Sql ODBC
Php Sql ODBC  This example illustrates how to create a ODBC Connection for php application. With an ODBC connection, you can connect to any database, on any computer in your network, as long as an ODBC connection is available
JDBC - JDBC
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D... on JDBC visit to : http://www.roseindia.net/jdbc/ Thanks
jdbc
); } try{ Connection con; con=DriverManager.getConnection("jdbc:odbc:student
jdbc
("jdbc:odbc:student"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
Java jdbc connection
Java jdbc connection  Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection
JDBC
JDBC  why we use batch in jdbc
jdbc
jdbc  display the records using index in jdbc
jdbc
jdbc  Hai , Give a steps for jdbc connectivity
JDBC
JDBC  How to add set of queries in a single query in JDBC

Ads