apache > db
Apache DB Project
 
Font size:      

Database connection URLs

Database connection URLs

A JDBC URL provides a way of identifying a database so that the appropriate driver recognizes it and connects to it. In the Derby documents, a JDBC URL is referred to as a database connection URL.

After the driver is loaded, an application must specify the correct database connection URL to connect to a specific database. The Derby database connection URL allows you to accomplish tasks other than simply connecting. For more information about the Derby database connection URLs, see the Derby Developer's Guide.

A JDBC URL always starts with jdbc:. After that, the format for the database connection URL depends on the JDBC driver.

For the Derby-provided embedded driver listed above, here is the format for the database connection URL for connecting to an existing database:

  • jdbc:derby:databaseName;URLAttributes

For the JCC driver listed above, here is the format for the database connection URL for connecting to an existing database:

  • jdbc:db2://host:port/databaseName

URL attributes can be passed to the JCC driver by using double quotes (") around the database name portion of the URL, as follows:

  • jdbc:db2://host:port/"databaseName;URLAttributes";

The italicized items stand for something the user fills in:

  • databaseName

    The name of the database you want to connect to

  • URLAttributes

    One or more of the supported attributes of the database connection URL, such as ;territory=ll_CC or ;create=true. For more information, see the Derby Developer's Guide.

  • host

    The name of the machine where the server is running. It can be the name of the machine or the address.

  • port

    The port number of the server framework

About Protocols

Officially, the portion of the database connection URL called the protocol is jdbc:, just as http:// is a protocol in Web URLs. However, the second portion of the database connection URL (everything between jdbc: and databaseName), which is called the subprotocol, is informally considered part of the protocol. Later in this book you might see references to protocol. Consider protocol to be everything that comes before databaseName.

For complete information about the database connection URL, see the Derby Developer's Guide.


Previous Page
Next Page
Table of Contents
Index