Explore your Imagination

Blog of Joeby Zaldivar Keep in touch…


How to bind jtable from your database table using netbeans

1. Create a JFrame that holds your Jtable...

2. From Pallete click and drag Jtable to the JFrame.

. Click Jtable to be selected and right click then choose bind -> elements then click.

4. Window for binding jtable will popup.  click import data from button. Select new connection for connection string is not set in the selection and click.  Select the driver name according to your chosen database.

5. Fill-up neccessary data according to machine configuration. Then click ok.  window popup that display your connection and selection of table to be bind in jtable. Then click ok and wait for data to import.

6.From Left portion of the window are those fields that are available and from the right are fields that are selected to view in the jtable. Then click ok and compile and run your program...


Happy coding....  


Connect Java to MYSQL using JDBC

Most of the System requires a back end in order to save the transactions. Here is the sample how to connect your java apps into mysql database.

import java.sql.*
public class MysqlConnect{
Connection con = null;
String dbUser = "root";
String dbPwd = "password";
String selectedDb = "test";

 try {
      con = DriverManager.getConnection("jdbc:mysql://localhost/selectedDb",
        dbUSer, dbPwd);

        System.out.println("Successfully connected to " +
          "MySQL server using TCP/IP...");

    } catch(Exception e) {
      System.err.println("Exception: " + e.getMessage());