Changes

Jump to: navigation, search

PostgreSQL Adapter Project - Resources

5 bytes removed, 16:25, 22 November 2010
JDBC
:Once you have registered the Driver class, you need to request a connection to a PostgreSQL database. To do this, you use a class called DriverManager. The DriverManager class is responsible for handling JDBC URLs, finding an appropriate driver, and then using that driver to provide a connection to the database.
:JDBC URLs are of the following format, in three colon-delimited parts: <code>jdbc:[drivertype]:[database]</code> :The first part, jdbc, is a constant. It represents that you are connecting to a JDBC data source. The second part, [drivertype], represents the kind of database you want to connect to. Use postgresql to connect to a PostgreSQL database. The third part is passed off to the driver, which finds the actual database. It takes on one of the following formats: <code> databasename --- //hostname/databasename ------ //hostname:portnumber/databasename</code>
:In the first case, the PostgreSQL database is running on the local machine, on the default port number. The databasename is the literal name of the database you wish to connect to. The second case is used for when you want to specify a hostname and a database. This also uses the default port number. The third case allows you to specify a port number as well. Even if you use the first type of URL, the JDBC connection will always be made via TCP/IP.
1
edit

Navigation menu