Results 1 to 3 of 3
  1. #1
    metagoth is offline Member
    Join Date
    Mar 2012
    new delhi
    Rep Power

    Default To fetch rows of ms acess database using combobox

    i m working on net beans ,i want to fetch the rows of ms acess database in incremental manner such that when i click 1 on combobox ,row 1st is displayed on corresponding textfield ,when i click 2 row 2 get fetched and so on ....
    my code is

    private void jComboBox1ActionPerformed(java.awt.event.ActionEve nt evt) {

    Connection conn = DriverManager.getConnection("jdbc:odbc:event");
    Statement st = conn.createStatement();
    ResultSet rs = st.executeQuery(" Select * from event ");


    catch(Exception e){}
    this is only giving me first row ,now how i will able to fetch other rows ...............

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Rep Power

    Default Re: To fetch rows of ms acess database using combobox

    I think you will get the other rows too, but you don`t do anything with them - you set the text of one JTextArea, but if you get the next row, you override it.
    What you are looking for is append instead of setText: JTextArea (Java Platform SE 6)

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: To fetch rows of ms acess database using combobox

    Just to make sure i've understood you.
    You have a combo box, each entry of which represents a row in your 'event' table.
    WHen you select an entry in the list, you want the relevant data in the row to be displayed in those text fields.

    Assuming that's correct you need to use:
    SELECT * FROM event WHERE somekey = ? (could be multiple fields if need be)

    Have that as your PreparedStatement, then use whatever value is available in the combo to set the bind variable.
    That will (assuming somekey is unique) return a single row, so just use:
    Java Code:
    if ( {
        ... populate the text fields here
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Combobox selections in to a database
    By MonkeyMan in forum New To Java
    Replies: 1
    Last Post: 03-05-2012, 04:25 PM
  2. No values from database in Combobox
    By aborgeld in forum New To Java
    Replies: 3
    Last Post: 01-01-2011, 08:38 PM
  3. how to fetch 20,000 records from excel sheet & insert into access database using Java
    By santosh_tamse in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-22-2009, 10:24 AM
  4. Deleting rows from a database using JSP
    By Manas Das in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 02-17-2009, 02:31 PM
  5. ComboBox with database options
    By Goldy in forum Advanced Java
    Replies: 0
    Last Post: 12-01-2007, 09:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts