31.8. PostgreSQLJDBC API的擴展

PostgreSQL 是一種可擴展的數據庫系統。 你可以向數據庫後端裡增加你自己的函數,這些函數可以供查詢調用, 甚至你可以增加你自己的數據類型。因為這些是 PostgreSQL 特有的功能,因此我們在 Java 裡面支持它們,同時還帶著一套擴展的 API。在標準驅動的核心裡實際上使用了這些擴展來實現大對象等等。

31.8.1. 訪問這些擴展

要獲得某些擴展,你需要使用 org.postgresql.PGConnection 類裡的一些額外的方法,這時,你需要轉換 Driver.getConnection() 的返回值。比如︰

Connection db = Driver.getConnection(url, username, password);
// ...
// 稍後
Fastpath fp = ((org.postgresql.PGConnection)db).getFastpathAPI();

31.8.1.1. 類 org.postgresql.PGConnection

public class PGConnection

這些是用于獲取 PostgreSQL 的擴展的額外的方法。

31.8.1.1.1. 方法

  • public Fastpath getFastpathAPI() throws SQLException

    這個方法為當前聯接返回 Fastpath API。 主要用于大對象API

    使用這個方法的最好方式是︰

    import org.postgresql.fastpath.*;
    ...
    Fastpath fp = ((org.postgresql.PGConnection)myconn).getFastpathAPI();

    這裡的myconn是一個已經打開的與 PostgreSQLConnection

    返回:. 一個可以用來訪問 PostgreSQL 後端裡面的函數的 Fastpath 對象。

    拋出:. 在第一次初始化的時候 Fastpath 拋出的SQLException

  • public LargeObjectManager getLargeObjectAPI() throws SQLException

    這個方法為當前聯接返回一個大對象 API

    使用這個方法的最佳手段如下︰

    import org.postgresql.largeobject.*;
    ...
    LargeObjectManager lo = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();

    這裡的myconn是一個已經打開的與 PostgreSQLConnection

    返回:. 實現大對象 APILargeObject對象。

    拋出:. 在第一次初始化的時候LargeObject拋出的 SQLException

  • public void addDataType(String type, String name)

    這個方法允許客戶端代碼為PostgreSQL中比較獨特的數據類型加一個句柄。 通常,驅動器不認識的數據類型是由 ResultSet.getObject() 以一個PGobject實例的形式返回的。 這個方法允許你寫一個擴展PGobject 的類,然後告訴驅動該類型名字,以及要使用的類名字。 這個方法的缺點是,每次你建立新聯接的時候,你都要調用這個方法。

    使用這個用法的最佳手段是:

     ...
    ((org.postgresql.PGConnection)myconn).addDataType("mytype","my.class.name");
     ...

    這裡的myconn是一個已經打開的與 PostgreSQLConnection。做控制的類必須擴展 org.postgresql.util.PGobject

31.8.1.2. 類 org.postgresql.Fastpath

public class Fastpath extends Object

java.lang.Object
   |
   +----org.postgresql.fastpath.Fastpath

Fastpath是一套存在于libpqC 接口裡的 API , 並且這個接口允許客戶機器執行後端數據庫的函數. 大多數客戶端代碼不需要使用這個方法,但是我們還是提供這個方法, 因為大對象 API 使用它。

要使用這個擴展,你需要輸入 postgresql.fastpath包,使用下面行:

import org.postgresql.fastpath.*;

然後,在你的代碼裡,你需要獲取一個FastPath對象:

Fastpath fp = ((org.postgresql.PGConnection)conn).getFastpathAPI();

這樣將返回一個實例,該實例與你發出命令的數據庫聯接相關聯。 必須把Connection轉換成 org.postgresql.PGConnection, 因為getFastpathAPI()是我們自己的方法之一,而不是 JDBC的。 一旦你擁有了 Fastpath 實例, 你就可以使用 fastpath() 方法執行一個後端函數。

又見:. FastpathFastpathArg, LargeObject

31.8.1.2.1. 方法

  • public Object fastpath(int fnid,
                           boolean resulttype,
                           FastpathArg args[]) throws SQLException

    PostgreSQL後端發送一個函數調用。

    參數:. fnid - 函數 id resulttype - 如果結果為整數則為真,如果為其它則為假 args - 傳遞給捷徑的 FastpathArguments

    返回:. 如果沒有數據返回空(null), 如果結果為整數返回一個Integer, 否則返回 byte[]

  • public Object fastpath(String name,
                           boolean resulttype,
                           FastpathArg args[]) throws SQLException

    通過名字向PostgreSQL後端發送一個函數調用。

    注意: 函數名到函數 id 的映射必須存在, 通常先調用 addfunction()。 這是調用函數的優選方法,因為函數 id 在不同版本的後端裡是會/可能改變的。 這個方法工作的例子,可以參閱 org.postgresql.LargeObject。

    參數:. name - 函數名稱 resulttype - 如果結果是整數返回真 (true), 其他結果返回假 (false) args - 傳遞給 fastpath 的參數FastpathArguments

    返回︰. 如果沒有數據返回空 (null), 如果結果為整數返回一個 Integer, 否則返回 byte[]

    又見:. LargeObject

  • public int getInteger(String name,
                          FastpathArg args[]) throws SQLException

    這個便利方法假設返回值是一個 Integer (整數)

    參數:. name - 函數名 args - 函數參數

    返回:. 整數結果

    拋出:. 如果發生了數據庫訪問錯誤或者沒有結果拋出 SQLException

  • public byte[] getData(String name,
                          FastpathArg args[]) throws SQLException

    這個便利方法假設返回值是二進制數據

    參數:. name - 函數名 args - 函數參數

    返回:. 包含結果的 byte[] 數組

    拋出:. 如果發生了數據庫訪問錯誤或者沒有結果拋出SQLException?

  • public void addFunction(String name,
                            int fnid)

    這個方法向我們的(函數)檢索表裡增加一個函數。 用戶代碼應該使用addFunctions方法, 因為這個方法基于一個查詢, 而不是 OID 硬代碼。我們不保證一個函數的 OID 是靜態的, 甚至運行在不同服務器的同版本的數據庫也不能保證是靜態的。

  • public void addFunctions(ResultSet rs) throws SQLException

    這個方法接收一個包含兩個字段的ResultSet。 字段 1 包含函數名,字段 2 是 OID。 它讀取整個ResultSet,把值裝載入函數表.

    Important: 調用完這個方法後記得用close()關閉 ResultSet!!

    關于函數名查找實現的信息: PostgreSQLpg_proc表裡存儲函數 id 和它們對應的名稱, 在查找時不是從該表裡查詢每個所需函數的名稱, 而是使用了一個Hashtable (散列表)。 同樣,只有需要的函數的名稱才放到這個表裡,以保證連接速度盡可能快。

    org.postgresql.LargeObject 類在啟動時執行一個查詢, 並且把返回的 ResultSet 傳遞給這裡提到的 addFunctions()方法。 一旦這些工作完成,LargeObjectAPI就用名稱引用函數。

    不要以為手工把它們轉換成 OID 就可以了。 的確,目前這樣做是可以用的,但隨著開發的進行這些可能被修改 (在 V7.0 版本的討論中有一些關于這些的話題), 所以這樣做是防止未來可能出現的任何不受保障的痛苦的手段。

    又見:. LargeObjectManager

  • public int getID(String name) throws SQLException

    這個方法返回與函數名關聯的函數 id, 如果還沒有對這個函數名調用 addFunction()addFunctions(), 那麼拋出一個SQLException

31.8.1.3. 類 org.postgresql.fastpath.FastpathArg

public class FastpathArg extends Object

java.lang.Object
   |
   +----org.postgresql.fastpath.FastpathArg

每個 fastpath 調用都需要一個參數列表,其數目和類型取決于被調用的函數。 這個類實現了提供這個功能所需要的方法。

關于如何使用這個方法的例子, 參閱 org.postgresql.LargeObject

又見:. Fastpath, LargeObjectManager, LargeObject

31.8.1.3.1. 構造器

  • public FastpathArg(int value)

    構造一個包含一個整數值的參數

    參數:. value - 待設置的整數值

  • public FastpathArg(byte bytes[])

    構造一個包含一個字節數組的參數

    參數:. bytes - 要保存的數組

  • public FastpathArg(byte buf[],
                       int off,
                       int len)

    構造一個包含一個數組的一部分的參數

    參數:.

    buf

    源數組

    off

    數組內的偏移量

    len

    要包括的數據的長度

  • public FastpathArg(String s)

    構造一個字符串組成的參數。

31.8.2. 幾何數據類型

PostgreSQL 有一個往表裡存儲幾何特性的數據類型集。 範圍包括點,線,和多邊形。 我們通過 org.postgresql.geometric 包在 Java 裡支持這些類型。 它包括擴展了 org.postgresql.util.PGobject 類的類。 參考該類獲取如何實現你自己的數據類型的控制器的細節。

Class org.postgresql.geometric.PGbox

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGbox

   public class PGbox extends PGobject implements Serializable,
Cloneable

   這個類在PostgreSQL裡表示盒子 (box) 數據類型。

變量

 public PGpoint point[]

          這些是盒子的兩個對角點。

構造器

 public PGbox(double x1,
              double y1,
              double x2,
              double y2)

        參數︰
                x1 - 第一個 x 坐標
                y1 - 第一個 y 坐標
                x2 - 第二個 x 坐標
                y2 - 第二個 y 坐標

 public PGbox(PGpoint p1,
              PGpoint p2)

        參數︰
                p1 - 第一個點
                p2 - 第二個點

 public PGbox(String s) throws SQLException

        參數︰
                s -PostgreSQL語法裡的盒子定義

        拋出︰ SQLException
                如果定義非法

 public PGbox()

          必須的構造(方法)

方法

 public void setValue(String value) throws SQLException

          這個方法設置這個對象的值。它應該被重載,但是仍然被子類調用。

        參數︰
                value - 一個代表對象值的字符串
        拋出︰ SQLException
                如果此數值對這個類型而言是非法的

        覆蓋︰
                 類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要比較的對象

        返回︰
                如果兩個盒子相等返回真 (true)

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

          必須覆蓋這個方法以允許對象被克隆 (cloned)

        覆蓋︰
                類 PGobject 裡的 equals

 public String getValue()

        返回︰
                PostgreSQL句法需要的 PGbox

        覆蓋︰
                getValue in class PGobject

Class org.postgresql.geometric.PGcircle

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGcircle

   public class PGcircle extends PGobject implements Serializable,
Cloneable

   這個類代表 PostgreSQL 的圓數據類型,由一個點和一個半徑組成

變量

 public PGpoint center

          這是圓心

 double radius

          這是半徑

構造器

 public PGcircle(double x,
                 double y,
                 double r)

        參數︰
               x - 圓心坐標
               y - 圓心坐標
               r - 圓半徑

 public PGcircle(PGpoint c,
                 double r)

        參數︰
                c - 描述圓心的 PGpoint
                r - 圓半徑

 public PGcircle(String s) throws SQLException

        參數︰
                s -PostgreSQL裡語法定義的圓。

        拋出︰ SQLException
                如果轉換失敗

 public PGcircle()

          這個構造(方法)被驅動器使用。

方法

 public void setValue(String s) throws SQLException

        參數︰
                s - 用PostgreSQL的語法定義的圓。

        拋出︰ SQLException
                如果轉換失敗

        覆蓋︰
                類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要對比的對象

        返回︰
                如果兩個圓相同返回真 (true)

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

        必須重載這個方法以便允許對象被克隆 (cloned)

        覆蓋︰
                類 PGobject 裡的 clone

 public String getValue()

        返回︰
                PostgreSQL 語法裡的 PGcircle 字串

        覆蓋︰
                PGobject 裡的 getValue

Class org.postgresql.geometric.PGline

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGline

   public class PGline extends PGobject implements Serializable,
Cloneable

這個類實現由兩個點組成的線。目前線還沒有在後端實現,
但這個類保證在後端實現後即可使用(線)。

變量

 public PGpoint point[]

          這是兩個點。

構造器

 public PGline(double x1,
               double y1,
               double x2,
               double y2)

        參數︰
                x1 - 第一個點的x坐標
                y1 - 第一個點的y坐標
                x2 - 第二個點的x坐標
                y2 - 第二個點的y坐標

 public PGline(PGpoint p1,
               PGpoint p2)

        參數︰
                p1 - 第一個點
                p2 - 第二個點

 public PGline(String s) throws SQLException

        參數︰
                s -PostgreSQL語法定義的點。

        拋出︰ SQLException
                當發生轉換錯誤時

 public PGline()

          驅動需要

方法

 public void setValue(String s) throws SQLException

        參數︰
                s -PostgreSQL裡語法的線段的定義

        拋出︰ SQLException
                當發生轉換錯誤時

        覆蓋︰
                類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要比較的對象

        返回︰
                如果兩條線段相同返回真 (true)

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

          這個方法必須被重載以便允許這個對象可以被克隆

        覆蓋︰
                類 PGobject 裡的 clone

 public String getValue()

        返回︰
                PostgreSQL 語法裡的 PGline

        覆蓋︰
                類 PGobject 裡的 getValue

Class org.postgresql.geometric.PGlseg

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGlseg

   public class PGlseg extends PGobject implements Serializable,
Cloneable

   這樣實現了一條包含兩個點的 lseg (線段)

變量

 public PGpoint point[]

          這裡是兩個點

構造器

 public PGlseg(double x1,
                double y1,
               double x2,
               double y2)

        參數︰

                x1 - 第一個點的x坐標
                y1 - 第一個點的y坐標
                x2 - 第二個點的x坐標
                y2 - 第二個點的y坐標

 public PGlseg(PGpoint p1,
               PGpoint p2)

        參數︰
                p1 - 第一個點
                p2 - 第二個點

 public PGlseg(String s) throws SQLException

        參數︰
                s -PostgreSQL裡語法對線段定義的字串。

        拋出︰ SQLException
                在發生轉換錯誤時

 public PGlseg()

          驅動要求

方法

 public void setValue(String s) throws SQLException

        參數︰
                s -PostgreSQL裡語法對線段定義的字串

        拋出︰ SQLException
                在發生轉換錯誤時

        覆蓋︰
                類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要比較的對象

        返回︰
                如果兩條線段相等

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

          必須覆蓋這個方法以便允許這個對象被克隆

        覆蓋︰
                類 PGobject 裡的 getValue

 public String getValue()

        返回︰
                PostgreSQL 語法裡的 PGlseg

        覆蓋︰
                類 PGobject 裡的 getValue

Class org.postgresql.geometric.PGpath

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGpath

   public class PGpath extends PGobject implements Serializable,
Cloneable

   這是路徑( 多線段圖形, 可以為封閉的 )的實現

變量

 public boolean open

          如果路徑開放時為真 (True),為封閉時為假

 public PGpoint points[]

          定義路徑的點

構造器

 public PGpath(PGpoint points[],
               boolean open)

        參數︰
                points - 定義路徑的 PGpoints
                open - 如果路徑是開放的為真 (True),封閉為假 (false)

 public PGpath()

          驅動需要

 public PGpath(String s) throws SQLException

        參數︰
                s -PostgreSQL的語法定義的路徑。

        拋出︰ SQLException
                在發生轉換錯誤時

方法

 public void setValue(String s) throws SQLException

        參數︰
                s -PostgreSQL的語法定義的路徑的字串

        拋出︰ SQLException
                在發生轉換失敗時

        覆蓋︰
                類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要比較的對象

        返回︰
                如果兩個路徑相同返回真 (true)

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

          必須覆蓋這個方法以便允許這個對象被克隆

        覆蓋︰
                clone in class PGobject

 public String getValue()

          這個方法返回PostgreSQL語法的多邊形


        覆蓋︰
                類 PGobject 裡的 getValue

 public boolean isOpen()

     如果路徑是開放的這個方法返回真 (true)

 public boolean isClosed()

     如果路徑是封閉的這個方法返回真 (true)

 public void closePath()

     標記路徑為封閉

 public void openPath()

     標記路徑為開放

Class org.postgresql.geometric.PGpoint

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGpoint

   public class PGpoint extends PGobject implements Serializable,
Cloneable

   這個類實現了 java.awt.Point 的一個版本,但用 double 表示參數。

   它對應于 PostgreSQL 裡的 point 數據類型。

變量

 public double x

          點的 X 坐標

 public double y

          點的 Y 坐標

構造器

 public PGpoint(double x,
                double y)

        參數︰
                x - 坐標
                y - 坐標

 public PGpoint(String value) throws SQLException

          這個方法主要從其他幾何類型調用 -- 當一個點嵌入它們的定義中時。

        參數︰
                value -PostgreSQL語法定義的點

 public PGpoint()

          驅動需要

方法

 public void setValue(String s) throws SQLException

        參數︰
                s -PostgreSQL語法定義的點

        拋出︰ SQLException
                在轉換失敗時

        覆蓋︰
                類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要比較的對象

        返回︰
                如果兩個對象相同返回真 (true)

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

          必須覆蓋這個方法以便允許這個對象被克隆

        覆蓋︰
                類 PGobject 裡的 clone

 public String getValue()

        返回︰
                  PostgreSQL裡語法 PGpoint 的表示。

        覆蓋︰
                類 PGobject 裡的 getValue

 public void translate(int x,
                       int y)

          對點做指定數量的轉換(位移)。

        參數︰
                x - 向 x 軸增加的整型數量
                y - 向 y 軸增加的整型數量

 public void translate(double x,
                       double y)

          對點做指定數量的轉換(位移)。

        參數︰
                x - 向 x 軸增加的雙精度型數量
                y - 向 y 軸增加的雙精度型數量

 public void move(int x,
                  int y)

          把點移到指定坐標。

        參數︰
                x - 整數坐標
                y - 整數坐標

public void move(double x,
                  double y)

          把點移到指定坐標。

        參數︰
                x - 雙精度坐標
                y - 雙精度坐標

 public void setLocation(int x,
                         int y)

          把點移到指定坐標. 參考
          java.awt.Point 獲取這個方法的描述信息

        參數︰
                x - 整數坐標
                y - 整數坐標

        又見︰
                Point

 public void setLocation(Point p)

          把點移到指定坐標. 參考
          java.awt.Point 獲取這個方法的描述信息

        參數︰
                p - 移動的目的點 (Point)

        又見︰
                Point

Class org.postgresql.geometric.PGpolygon

java.lang.Object
   |
   +----org.postgresql.util.PGobject
           |
           +----org.postgresql.geometric.PGpolygon

   public class PGpolygon extends PGobject implements Serializable,
Cloneable

   這個類在PostgreSQL裡實現了 polygon (多邊形)數據類型。

變量

 public PGpoint points[]

           定義 polygon (多邊形)的點

構造器

 public PGpolygon(PGpoint points[])

          使用一個 PGpoints 數組創建一個多邊形

        參數︰
                points - 定義多邊形 polygon 的點

 public PGpolygon(String s) throws SQLException

        參數︰
                s - 用PostgreSQL語法定義的多邊形.

        拋出︰ SQLException
                在轉換失敗時

 public PGpolygon()

        驅動需要

方法

 public void setValue(String s) throws SQLException

        參數︰
                s - 用PostgreSQL語法定義的多邊形.

        拋出︰ SQLException
                在轉換失敗時

        覆蓋︰
                類 PGobject 裡的 setValue

 public boolean equals(Object obj)

        參數︰
                obj - 要比較的對象

        返回︰
                如果兩個對象相同返回真 (true)

        覆蓋︰
                類 PGobject 裡的 equals

 public Object clone()

          必須覆蓋這個方法以便允許這個對象被克隆

        覆蓋︰
                 類 PGobject 裡的 clone

 public String getValue()

        返回︰
                 PostgreSQL裡語法表示的 PGpolygon。

        覆蓋︰
                類 PGobject 裡的 getValue

31.8.3. 大對象

標準的 JDBC 規範裡也支持大對象。 但是,那個接口有一些限制, 而PostgreSQL提供的 API 允許對對象內容的隨機訪問, 就象那是一個本地文件一樣。

org.postgresql.largeobject 包為 Java 提供了libpq C 接口的大對象 API。它包含兩個類, LargeObjectManager, 處理創建,打開和刪除大對象的任務;以及 LargeObject,處理獨立的對象。

31.8.3.1. 類org.postgresql.largeobject.LargeObject

public class LargeObject extends Object

java.lang.Object
   |
   +----org.postgresql.largeobject.LargeObject

這個類實現PostgreSQL的大對象接口。

它提供運行接口的基本的方法,另外還有一對方法為此對象提供 InputStreamOutputStream類。

通常,客戶端代碼將使用在 BLOB 裡的方法訪問大對象。

但是,有時候需要低層次的大對象訪問方法,那是 JDBC 規範還不支持的。

參考 org.postgresql.largeobject.LargeObjectManager 獲取如何訪問大對象和如何創建大對象的信息。

又見︰. LargeObjectManager

31.8.3.1.1. 變量

public static final int SEEK_SET

標識從一個文件的開頭進行一次搜索

public static final int SEEK_CUR

標識從當前位置進行一次搜索

public static final int SEEK_END

標識從一個文件的結尾進行一次搜索

31.8.3.1.2. 方法

  • public int getOID()

    返回這個 LargeObject 的 OID。

  • public void close() throws SQLException

    這個方法關閉對象,在調用這個方法後你不能調用這個對象裡的任何方法。

  • public byte[] read(int len) throws SQLException

    從對象讀取一些數據, 並且做為 byte[] 數組返回

  • public int read(byte buf[],
                     int off,
                     int len) throws SQLException

    從對象讀取一些數據到現有數組

    參數︰.

    buf

    目的數組

    off

    數組內偏移量

    len

    讀取的字節數

  • public void write(byte buf[]) throws SQLException

    向對象裡寫入一個數組

  • public void write(byte buf[],
                      int off,
                      int len) throws SQLException

    從數組裡寫一些數據到對象

    參數︰.

    buf

    目標數組

    off

    數組內偏移量

    len

    寫入字節數

31.8.3.2. 類org.postgresql.largeobject.LargeObjectManager

public class LargeObjectManager extends Object

java.lang.Object
   |
   +----org.postgresql.largeobject.LargeObjectManager

這個類型實現了PostgreSQL的大對象接口。 它提供了允許客戶代碼從數據庫裡創建,打開和刪除大對象的方法。 在打開一個對象時,返回一個 postgresql.largeobject.LargeObject的實例, 然後它的方法就可以訪問該對象。

這個類只能由 org.postgresql.PGConnection 創建 要訪問這個類,使用下面的代碼片段:

import org.postgresql.largeobject.*;
Connection  conn;
LargeObjectManager lobj;
// ... 打開一個連接的代碼 ...
lobj = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();

通常, 客戶代碼要使用 BLOB 方法訪問大對象。 但是,有時候需要低層次的大對象訪問方法,那是 JDBC 規範還不支持的。

請參考 org.postgresql.largeobject.LargeObject 獲取如何控制大對象內容的信息。

31.8.3.2.1. 變量

public static final int WRITE

這個模式表明我們要寫入大對象

public static final int READ

這個模式表明我們要讀取大對象

public static final int READWRITE

這個模式是缺省的,表明我們要對大對象進行讀和寫的操作

31.8.3.2.2. 方法

  • public LargeObject open(int oid) throws SQLException

    這個方法打開一個現有的大對象, 以其 OID 為基礎. 這個方法假設 我們需要READWRITE訪問模式 (缺省模式)。

  • public LargeObject open(int oid,
                            int mode) throws SQLException

    這個方法以其 OID 為基礎打開一個現有的大對象。 並且允許設置訪問模式。

  • public int create() throws SQLException

    這個方法創建一個大對象, 返回它的 OID。 它把新創建的大對象模式設為缺省的READWRITE

  • public int create(int mode) throws SQLException

    這個方法創建一個大對象,返回它的 OID。並設置訪問模式。

  • public void delete(int oid) throws SQLException

    這個方法刪除一個大對象。

  • public void unlink(int oid) throws SQLException

    這個方法刪除一個大對象。這個方法等同于 delete 方法, 並且作為類似使用"unlink"的 C API 出現。