JDBC URLs

   

A Uniform Resource Locator (URL) provides a standard way of locating a resource on the Internet. It's very much like an address. The first part of an URL specifies the protocol used. The rest of the URL gives information for locating the resource using the protocol mentioned at the beginning of the URL.

A JDBC URL is a way to specify a database so that the application or applet will use it to make the connection. JDBC driver vendors have some flexibility when establishing what the URL format will be for their driver. Of course, there are standards that must be followed to some extent. The standard format of a JDBC URL looks like this:

 jdbc:<subprotocol>:<subname> 

Notice that a colon must separate each section. The protocol for a JDBC URL is always jdbc. The subprotocol is the name of the driver being used or the name of the database. A well known subprotocol is odbc. For example, to access a database through the JDBC-ODBC Bridge, you could use something like this:

 jdbc:odbc:my_access_database 

The subname section is a way to identify the database for the JDBC URL. The general format for this usually looks something like this:

 //hostname:port/subsubname 

Applications that need to access a database over the Internet or the physical network could specify the logical hostname of an IP address and a port to connect. It would probably also specify the name of the database instance that it wanted to connect to.

Keep in mind that each JDBC driver vendor will specify the exact format for the URL. Check the documentation for your driver to find the exact format.

For Oracle8i Lite, use the following URL format to connect to the database. Substitute the drive letter and/or database name for your specific needs.

 jdbc:polite:POLITE 

The <subname> part of this URL is the datasource name that was created in the ODBC configuration.

Troubleshooting Tip

If you are having trouble with the JDBC URL, see "Setting Up the Correct JDBC URL" in the "Troubleshooting" section at the end on this chapter.


   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net