Dec 29, 2010

How to bind data using Netbeans

What is Data Binding ?
Data binding is the process that establishes a connection between the application UI and business logic. If the binding has the correct settings and the data provides the proper notifications, then, when the data changes its value, the elements that are bound to the data reflect changes automatically. Data binding can also mean that if an outer representation of the data in an element changes, then the underlying data can be automatically updated to reflect the change.

Bind data using Netbeans without coding. How ?
Ok, there is a way to bind data quickly. I will make a small example to demo. 
Here I use MySQL and I'll bind data from a table in mysql to JTable using Netbeans IDE.

I created a database, name "mydb", some tables with data for demonstration
Make sure you MySQL client is running. 

Follow these steps below, 
  1. Open Netbeans and create a new project with the name you want.
  2. Register MySQL Server if you have not done yet (In the left pane >> click Services tab >> right click Database >> Register MySQL Server >> then fill with valid infomations)
  3. Create a new JFrame with a JTable
  4. Observe the left pane, you will see "Database connection" like this:
  5. Choose the right Database connection then click "connect"
  6. Then, you will see your database was created and their data tables
  7. Now, just drag and drop from left to right
  8. Run your project and see the result :)
Enjoy !


No comments: