After the driver has loaded and registered itself with the DriverManager, the ListEmployees class can attempt to connect to the database server, as shown in the following code fragment:All JDBC connections start with the DriverManager. The DriverManager class offers a static method called getConnection() that is responsible for creating a connection to the database. When you call the getConnection() method, the DriverManager must decide which JDBC driver to use to connect to the database; that decision is based on a URL (Uniform Resource Locator) that you pass to getConnection().The first component in a JDBC URL is always jdbc. When using the Advanced Server JDBC Connector, the second component (the driver) is edb.jdbc:edb:<database>jdbc:edb://<host>/<database>jdbc:edb://<host>:<port>/<database>Table 1.1 shows the various connection parameters:
The host name of the server. Defaults to localhost. In addition to the standard connection parameters, the Advanced Server JDBC driver supports connection properties that control behavior specific to EnterpriseDB. You can specify these properties in the connection URL or as a Properties object parameter passed to DriverManager.getConnection(). Listing 1.2 demonstrates how to use a Properties object to specify additional connection properties:To specify additional connection properties in the URL, add a question mark and an ampersand-separated list of keyword-value pairs:
The value of loglevel determines the amount of detail printed to the DriverManager’s current value for LogStream or LogWriter. It currently supports values of:Set the value of loglevel to INFO to include sparse log information or to DEBUG to produce significant detail. The value of charSet determines the character set used for data sent to or received from the database. The value of prepareThreshold determines the number of PreparedStatement executions required before switching to server side prepared statements. The default is five.