Sponsored Links


Results 1 to 2 of 2

Thread: Retrieving data in a JTable

  1. #1
    Senior Member saneha's Avatar
    Join Date
    Apr 2011
    Posts
    266

    Spotlight Retrieving data in a JTable

    Sponsored Links1



  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    Follow the given below steps to make the jatable in NetBeans , if you will face any problem at any stage let me know.

    To create entity classes to represent the database that is to be bound to the JTable:

    In the Projects window, right-click your project and choose New > Other, select the Persistence category, and select the Entity Classes from Database template.
    In the Database Tables page of the wizard, select the database connection.
    Once the Available Tables column is populated, select the tables that you want to use in your application and click Add to move them to the Selected Tables column. Click Next.
    In the Entity Classes page of the wizard, make sure the Generate Named Query Annotations for Persistent Fields dialog box is selected.
    Make any customizations that you want to make to the names of the generated classes and their location.
    Click Create Persistence Unit.
    In the Create Persistence Unit dialog box, make sure of the following things:
    That the selected Persistence Library is TopLink.
    That the selected Table Generation Strategy is "None".
    Click Finish.
    You should see nodes for the entity classes in the Projects window.

    To bind the data to a JTable component:

    Right-click the component in the GUI Builder and choose Bind > elements.
    Click Import Data to Form. From the Import Data to Form dialog box, select the database table to which you want to bind your components. Click OK.
    From the Binding Source combo box, select the item that represents the result list of the entity class. For example, if the entity class is called, Customer.java, the list object would be generated as customerList.
    Leave the Binding Expression value as null.
    If there are any database columns that you want to appear in the JTable, select those columns in the Selected list and move them to the Available list.
    Select the Advanced tab to further configure the binding. For example, you can specify a validator or converter, or you can specify behavior if the binding source is null or unreadable.
    Click OK.
    To bind the data to a JList component:

    Right-click the component in the GUI Builder and choose Bind > elements.
    Click Import Data to Form. From the Import Data to Form dialog box, select the database table to which you want to bind your components. Click OK.
    From the Binding Source combo box, select an item that represents the result list of the entity class. For example, if the entity class is called, Customer.java, the list object would be generated as customerList.
    Leave the Binding Expression value as null.
    In the Display Expression drop-down list, select the property that represents the database column that contains the values that you want to display in the list.
    Select the Advanced tab to further configure the binding.
    Click OK.
    You can use the New Java Desktop Application wizard to quickly create a whole working application that has CRUD (create, read, update, and delete) features. You can also drag a database table from the Services window on to a JTable to automatically bind data to the JTable. However, it is better to generate all the entity classes in advance to ensure that all relations among the entities are correctly covered by the generated classes.
    Connecting to a Database

    To connect to a database you first need to do the following:

    Confirm that a JDBC driver for your database is registered with the IDE.
    The registered JDBC drivers are visible under the Drivers node in the Services window.
    Create a database connection for the database.
    A database connection is represented by a database connection node under the Databases node in the Services window.
    When you create a database connection, you supply the details needed to connect to a specific database. The details needed to connect to a database include the location of the database, which driver to use and the username and password information.

    After you create the database connection you can do the following:

    Disconnect and reconnect to the database
    Browse the database structure
    View data contained in a table in the database

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 03-05-2012, 11:05 PM
  2. Replies: 0
    Last Post: 07-17-2011, 03:56 PM
  3. Replies: 1
    Last Post: 05-02-2011, 06:26 AM
  4. What data type will be used in C++ program?
    By sana.pari in forum C++ Programing
    Replies: 1
    Last Post: 04-24-2011, 06:07 PM
  5. Replies: 3
    Last Post: 05-10-2010, 11:55 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
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft | Jobs