Using the Database Binding Component

Connecting to a MySQL Database

This topic demonstrates setting up a connection to a MySQL database from GlassFish ESB — NetBeans IDE 6.1.

Connections to databases are managed using database drivers, which enable applications written in different programming languages to interact with the database management system. GlassFish ESB — NetBeans IDE 6.1 comes bundled with the MySQL Native (mysql-connector-java-5.1.5-bin.jar), which is a Java implementation of the JDBC API, and communicates directly with the MySQL Driver.

ProcedureTo Connect to a MySQL Database

  1. Click Services tab.

  2. Expand the Drivers node from the Database Explorer. Right-click the MySQL (Connector/J driver) and choose Connect Using....

    The New Database Connection dialog box is displayed.

    My SQL Connection
  3. In the Basic Setting tab, enter the Database's URL <HOST>:<PORT>/<DB> in the corresponding text field.

    The URL identifies the type and location of a database server.

    In this example, specify the host name (that is, the location of the server), the port number on which the database communicates, and the name of the database instance.

    In this case you can enter: jdbc:mysql://localhost:xxxx/MyNewDatabase.

  4. Enter User Name and Password.


    Note –

    Select the Remember password option. This is optional.


    Database Connection
  5. Click OK to accept the credentials.

    This displays a new Connection node in the Database Explorer under the Databases node.

    Password Handling
  6. Click OK to accept the default schema.

  7. Right-click the MySQL Database URL in the Services window (Ctrl-5). Click Connect.

    This opens the New Database Connection dialog box.

    MySQL Database

    The illustration shows that the Database Connection is enabled.

    Database Driver Enabled

    You are now connected to the MySQL RDBMS in the IDE.