How the Server-side Connection Example Works

In this simple example, InternalConnect() is the only method used in the application.

The application requires only one of the libraries (JDBC) imported in the first line of the JDBCExamples.java class. The others are for external connections. The package named java.sql contains the JDBC classes.

The InternalConnect() method carries out the following tasks:

  1. Connects to the default running database using the current connection:

    • DriverManager.getConnection establishes a connection using a connection string of jdbc:default:connection.

  2. Prints Hello World to the current standard output, which is the server window. System.out.println carries out the printing.

  3. If there is an error in the attempt to connect, an error message appears in the server window, together with the place where the error occurred.

    The try and catch instructions provide the framework for the error handling.

  4. The class terminates.