conn.setAutoCommit(false);
// Get the Large Object Manager to perform operations with
-LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI();
+LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();
//create a new large object
int oid = lobj.create(LargeObjectManager.READ | LargeObjectManager.WRITE);
conn.setAutoCommit(false);
// Get the Large Object Manager to perform operations with
-LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI();
+LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();
PreparedStatement ps = con.prepareStatement("SELECT imgOID FROM imagesLO WHERE imgname=?");
ps.setString(1, "myimage.gif");
To access some of the extensions, you need to use some extra
- methods in the org.postgresql.Connection
+ methods in the org.postgresql.PGConnection
class. In this case, you would need to case the return value of
Driver.getConnection(). For example:
Connection db = Driver.getConnection(url, username, password);
// ...
// later on
-Fastpath fp = ((org.postgresql.Connection)db).getFastpathAPI();
+Fastpath fp = ((org.postgresql.PGConnection)db).getFastpathAPI();
-
Class org.postgresql.Connection
+
Class org.postgresql.PGConnection
-public class Connection extends Object implements Connection
-
-java.lang.Object
- |
- +----org.postgresql.Connection
+public class PGConnection
These are the extra methods used to gain access to
-
PostgreSQL's extensions. Methods
- defined by java.sql.Connection are not
- listed.
+
PostgreSQL's extensions.
import org.postgresql.fastpath.*;
...
-Fastpath fp = ((org.postgresql.Connection)myconn).getFastpathAPI();
+Fastpath fp = ((org.postgresql.PGConnection)myconn).getFastpathAPI();
where
myconn> is an open Connection> to PostgreSQL.
import org.postgresql.largeobject.*;
...
-LargeObjectManager lo = ((org.postgresql.Connection)myconn).getLargeObjectAPI();
+LargeObjectManager lo = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();
where myconn> is an open Connection> to
The best way to use this is as follows:
...
-((org.postgresql.Connection)myconn).addDataType("mytype","my.class.name");
+((org.postgresql.PGConnection)myconn).addDataType("mytype","my.class.name");
...
where myconn is an open Connection> to
Then, in your code, you need to get a
FastPath object:
-Fastpath fp = ((org.postgresql.Connection)conn).getFastpathAPI();
+Fastpath fp = ((org.postgresql.PGConnection)conn).getFastpathAPI();
This will return an instance associated with the database
connection that you can use to issue commands. The casing of
Connection to
- org.postgresql.Connection is required, as
+ org.postgresql.PGConnection is required, as
the getFastpathAPI() is an extension method,
not part of
JDBC. Once you have a
Fastpath instance, you can use the
- This class can only be created by org.postgresql.Connection. To
+ This class can only be created by org.postgresql.PGConnection. To
get access to this class, use the following segment of code:
import org.postgresql.largeobject.*;
Connection conn;
LargeObjectManager lobj;
// ... code that opens a connection ...
-lobj = ((org.postgresql.Connection)myconn).getLargeObjectAPI();
+lobj = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();