File: load.md

package info (click to toggle)
libpgjava 42.2.5-2%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,136 kB
  • sloc: java: 57,821; xml: 1,135; sh: 307; perl: 99; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 908 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
layout: default_docs
title: Loading the Driver
header: Chapter 3. Initializing the Driver
resource: media
previoustitle: Chapter 3. Initializing the Driver
previous: use.html
nexttitle: Connecting to the Database
next: connect.html
---
		
Applications do not need to explicitly load the org.postgresql.Driver
class because the pgjdbc driver jar supports the Java Service Provider
mechanism. The driver will be loaded by the JVM when the application
connects to PostgreSQL™ (as long as the driver's jar file is on the
classpath).


### Note

Prior to Java 1.6, the driver had to be loaded by the application - either by calling

```java
Class.forName("org.postgresql.Driver");
```
or by passing the driver class name as a JVM parameter.

`java -Djdbc.drivers=org.postgresql.Driver example.ImageViewer`

These older methods of loading the driver are still supported but they are no longer necessary.