PostgreSQL ÊÇÒ»ÖÖ¿ÉÀ©Õ¹µÄÊý¾Ý¿âϵͳ£® Äã¿ÉÒÔÏòÊý¾Ý¿âºó¶ËÀïÔö¼ÓÄã×Ô¼ºµÄº¯Êý£¬ÕâЩº¯Êý¿ÉÒÔ¹©²éѯµ÷Ó㬠ÉõÖÁÄã¿ÉÒÔÔö¼ÓÄã×Ô¼ºµÄÊý¾ÝÀàÐÍ£®ÒòΪÕâЩÊÇ PostgreSQL ÌØÓеŦÄÜ£¬Òò´ËÎÒÃÇÔÚ Java ÀïÃæÖ§³ÖËüÃÇ£¬Í¬Ê±»¹´ø×ÅÒ»Ì×À©Õ¹µÄ API£®ÔÚ±ê×¼Çý¶¯µÄºËÐÄÀïʵ¼ÊÉÏʹÓÃÁËÕâЩÀ©Õ¹ À´ÊµÏÖ´ó¶ÔÏóµÈµÈ£®
Òª»ñµÃijЩÀ©Õ¹£¬ÄãÐèҪʹÓà org.postgresql.PGConnection ÀàÀïµÄһЩ¶îÍâµÄ·½·¨£¬Õâʱ£¬ÄãÐèҪת»» Driver.getConnection() µÄ·µ»ØÖµ£®±ÈÈç¡Ã
Connection db = Driver.getConnection(url, username, password); // ... // ÉÔºó Fastpath fp = ((org.postgresql.PGConnection)db).getFastpathAPI();
public class PGConnection
ÕâЩÊÇÓÃÓÚ»ñÈ¡ PostgreSQL µÄÀ©Õ¹ µÄ¶îÍâµÄ·½·¨£®
public Fastpath getFastpathAPI() throws SQLException
Õâ¸ö·½·¨Îªµ±Ç°Áª½Ó·µ»Ø Fastpath API£® Ö÷ÒªÓÃÓÚ´ó¶ÔÏóAPI£®
ʹÓÃÕâ¸ö·½·¨µÄ×îºÃ·½Ê½ÊÇ¡Ã
import org.postgresql.fastpath.*; ... Fastpath fp = ((org.postgresql.PGConnection)myconn).getFastpathAPI();
ÕâÀïµÄmyconnÊÇÒ»¸öÒѾ´ò¿ªµÄÓë PostgreSQL µÄConnection£®
·µ»Ø¡Ã. Ò»¸ö¿ÉÒÔÓÃÀ´·ÃÎÊ PostgreSQL ºó¶ËÀïÃæµÄº¯ÊýµÄ Fastpath ¶ÔÏó£®
Å׳ö¡Ã. ÔÚµÚÒ»´Î³õʼ»¯µÄʱºò Fastpath Å׳öµÄSQLException¡£
public LargeObjectManager getLargeObjectAPI() throws SQLException
Õâ¸ö·½·¨Îªµ±Ç°Áª½Ó·µ»ØÒ»¸ö´ó¶ÔÏó API£®
ʹÓÃÕâ¸ö·½·¨µÄ×î¼ÑÊÖ¶ÎÈçÏ¡Ã
import org.postgresql.largeobject.*; ... LargeObjectManager lo = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();
ÕâÀïµÄmyconnÊÇÒ»¸öÒѾ´ò¿ªµÄÓë PostgreSQL µÄConnection£®
·µ»Ø¡Ã. ʵÏÖ´ó¶ÔÏó API µÄLargeObject¶ÔÏó£®
Å׳ö¡Ã. ÔÚµÚÒ»´Î³õʼ»¯µÄʱºòLargeObjectÅ׳öµÄ SQLException£®
public void addDataType(String type, String name)
Õâ¸ö·½·¨ÔÊÐí¿Í»§¶Ë´úÂëΪPostgreSQLÖбȽ϶ÀÌصÄÊý¾ÝÀàÐÍ ¼ÓÒ»¸ö¾ä±ú£®Í¨³££¬Çý¶¯Æ÷²»ÈÏʶµÄÊý¾ÝÀàÐÍÊÇÓÉ ResultSet.getObject() ÒÔÒ»¸öPGobjectʵÀýµÄÐÎʽ·µ»ØµÄ£® Õâ¸ö·½·¨ÔÊÐíÄãдһ¸öÀ©Õ¹PGobject µÄÀ࣬Ȼºó¸æËßÇý¶¯¸ÃÀàÐÍÃû×Ó£¬ÒÔ¼°ÒªÊ¹ÓõÄÀàÃû×Ó£® Õâ¸ö·½·¨µÄȱµãÊÇ£¬Ã¿´ÎÄ㽨Á¢ÐÂÁª½ÓµÄʱºò£¬Ä㶼Ҫµ÷ÓÃÕâ¸ö·½·¨£®
ʹÓÃÕâ¸öÓ÷¨µÄ×î¼ÑÊÖ¶ÎÊÇ£º
... ((org.postgresql.PGConnection)myconn).addDataType("mytype","my.class.name"); ...
ÕâÀïµÄmyconnÊÇÒ»¸öÒѾ´ò¿ªµÄÓë PostgreSQL µÄConnection£®×ö¿ØÖƵÄÀà±ØÐëÀ©Õ¹ org.postgresql.util.PGobject£®
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
public Object fastpath(int fnid, boolean resulttype, FastpathArg args[]) throws SQLException
ÏòPostgreSQLºó¶Ë·¢ËÍÒ»¸öº¯Êýµ÷Óã®
²ÎÊý¡Ã. fnid - º¯Êý id resulttype - Èç¹û½á¹ûΪÕûÊýÔòΪÕ棬Èç¹ûΪÆäËüÔòΪ¼Ù args - ´«µÝ¸ø fastpath µÄ 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 Ó²´úÂ룮ÎÒÃDz»±£Ö¤Ò»¸öº¯ÊýµÄ OID ÊǾ²Ì¬µÄ£¬ ÉõÖÁÔËÐÐÔÚ²»Í¬·þÎñÆ÷µÄͬ°æ±¾µÄÊý¾Ý¿âÒ²²»Äܱ£Ö¤ÊǾ²Ì¬µÄ£®
public void addFunctions(ResultSet rs) throws SQLException
Õâ¸ö·½·¨½ÓÊÕÒ»¸ö°üº¬Á½¸ö×ֶεÄResultSet£® ×ֶΠ1 °üº¬º¯ÊýÃû£¬ ×ֶΠ2 ÊÇ OID£® Ëü¶ÁÈ¡Õû¸öResultSet£¬°ÑÖµ×°ÔØÈ뺯Êý±í.
Important: µ÷ÓÃÍêÕâ¸ö·½·¨ºó¼ÇµÃÓÃclose()¹Ø±Õ ResultSet!!
¹ØÓÚº¯ÊýÃû²éÕÒʵÏÖµÄÐÅÏ¢: PostgreSQL ÔÚpg_proc±íÀï´æ´¢º¯Êý id ºÍËüÃǶÔÓ¦µÄÃû³Æ£¬ ÔÚ²éÕÒʱ²»ÊǴӸñíÀï²éѯÿ¸öËùÐ躯ÊýµÄÃû³Æ£¬ ¶øÊÇʹÓÃÁËÒ»¸öHashtable (É¢Áбí)£® ͬÑù£¬Ö»ÓÐÐèÒªµÄº¯ÊýµÄÃû³Æ²Å·Åµ½Õâ¸ö±íÀÒÔ±£Ö¤Á¬½ÓËٶȾ¡¿ÉÄܿ죮
org.postgresql.LargeObject ÀàÔÚÆô¶¯Ê±Ö´ÐÐÒ»¸ö²éѯ, ²¢ÇÒ°Ñ·µ»ØµÄ ResultSet ´«µÝ¸øÕâÀïÌáµ½µÄ addFunctions()·½·¨£® Ò»µ©ÕâЩ¹¤×÷Íê³É£¬LargeObjectAPI¾ÍÓÃÃû³ÆÒýÓú¯Êý£®
²»ÒªÒÔΪÊÖ¹¤°ÑËüÃÇת»»³É OID ¾Í¿ÉÒÔÁË£® µÄÈ·£¬Ä¿Ç°ÕâÑù×öÊÇ¿ÉÒÔÓõģ¬µ«Ëæ×Å¿ª·¢µÄ½øÐÐÕâЩ¿ÉÄܱ»ÐÞ¸Ä £¨ÔÚ V7.0 °æ±¾µÄÌÖÂÛÖÐÓÐһЩ¹ØÓÚÕâЩµÄ»°Ì⣩£¬ ËùÒÔÕâÑù×öÊÇ·ÀֹδÀ´¿ÉÄܳöÏÖµÄÈκβ»Êܱ£ÕϵÄÍ´¿àµÄÊֶΣ®
ÓÖ¼û¡Ã. LargeObjectManager
public int getID(String name) throws SQLException
Õâ¸ö·½·¨·µ»ØÓ뺯ÊýÃû¹ØÁªµÄº¯Êý id£¬ Èç¹û»¹Ã»ÓжÔÕâ¸öº¯ÊýÃûµ÷Óà addFunction()»ò addFunctions()£¬ ÄÇôÅ׳öÒ»¸öSQLException£®
public class FastpathArg extends Object java.lang.Object | +----org.postgresql.fastpath.FastpathArg
ÿ¸ö fastpath µ÷Óö¼ÐèÒªÒ»¸ö²ÎÊýÁÐ±í£¬ÆäÊýÄ¿ºÍÀàÐÍÈ¡¾öÓÚ±»µ÷Óõĺ¯Êý£® Õâ¸öÀàʵÏÖÁËÌṩÕâ¸ö¹¦ÄÜËùÐèÒªµÄ·½·¨£®
¹ØÓÚÈçºÎʹÓÃÕâ¸ö·½·¨µÄÀý×Ó, ²ÎÔÄ org.postgresql.LargeObject °ü
ÓÖ¼û¡Ã. Fastpath, LargeObjectManager, LargeObject
public FastpathArg(int value)
¹¹ÔìÒ»¸ö°üº¬Ò»¸öÕûÊýÖµµÄ²ÎÊý
²ÎÊý¡Ã. value - ´ýÉèÖÃµÄ int (ÕûÊý)Öµ
public FastpathArg(byte bytes[])
¹¹ÔìÒ»¸ö°üº¬Ò»¸ö×Ö½ÚÊý×éµÄ²ÎÊý
²ÎÊý¡Ã. bytes - Òª±£´æµÄÊý×é
public FastpathArg(byte buf[], int off, int len)
¹¹ÔìÒ»¸ö°üº¬Ò»¸öÊý×éµÄÒ»²¿·ÖµÄ²ÎÊý
²ÎÊý¡Ã.
Ô´Êý×é
Êý×éÄÚµÄÆ«ÒÆÁ¿
Òª°üÀ¨µÄÊý¾ÝµÄ³¤¶È
public FastpathArg(String s)
¹¹ÔìÒ»¸ö×Ö·û´®×é³ÉµÄ²ÎÊý£®
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
±ê×¼µÄ JDBC ¹æ·¶ÀïÒ²Ö§³Ö´ó¶ÔÏó£® µ«ÊÇ£¬ÄǸö½Ó¿ÚÓÐһЩÏÞÖÆ£¬ ¶øPostgreSQLÌṩµÄ API ÔÊÐí¶Ô¶ÔÏóÄÚÈݵÄËæ»ú·ÃÎÊ£¬ ¾ÍÏóÄÇÊÇÒ»¸ö±¾µØÎļþÒ»Ñù£®
org.postgresql.largeobject °üΪ Java ÌṩÁËlibpqC ½Ó¿ÚµÄ´ó¶ÔÏó API£®Ëü°üº¬Á½¸öÀ࣬ LargeObjectManager£¬ ´¦Àí´´½¨£¬´ò¿ªºÍɾ³ý´ó¶ÔÏóµÄÈÎÎñ£»ÒÔ¼° LargeObject£¬´¦Àí¶ÀÁ¢µÄ¶ÔÏó£®
public class LargeObject extends Object java.lang.Object | +----org.postgresql.largeobject.LargeObject
Õâ¸öÀàʵÏÖPostgreSQLµÄ´ó¶ÔÏó½Ó¿Ú£®
ËüÌṩÔËÐнӿڵĻù±¾µÄ·½·¨£¬ÁíÍ⻹ÓÐÒ»¶Ô·½·¨Îª´Ë¶ÔÏóÌṩ InputStream ºÍ OutputStreamÀ࣮
ͨ³££¬¿Í»§¶Ë´úÂ뽫ʹÓÃÔÚ BLOB ÀïµÄ·½·¨ ·ÃÎÊ´ó¶ÔÏó£®
µ«ÊÇ£¬ÓÐʱºòÐèÒªµÍ²ã´ÎµÄ´ó¶ÔÏó·ÃÎÊ·½·¨£¬ÄÇÊÇ JDBC ¹æ·¶»¹²»Ö§³ÖµÄ£®
²Î¿¼ org.postgresql.largeobject.LargeObjectManager »ñÈ¡ÈçºÎ·ÃÎÊ´ó¶ÔÏóºÍÈçºÎ´´½¨´ó¶ÔÏóµÄÐÅÏ¢£®
ÓÖ¼û¡Ã. LargeObjectManager
±êʶ´ÓÒ»¸öÎļþµÄ¿ªÍ·½øÐÐÒ»´ÎËÑË÷
±êʶ´Óµ±Ç°Î»ÖýøÐÐÒ»´ÎËÑË÷
±êʶ´ÓÒ»¸öÎļþµÄ½áβ½øÐÐÒ»´ÎËÑË÷
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
´Ó¶ÔÏó¶ÁȡһЩÊý¾Ýµ½ÏÖÓÐÊý×é
²ÎÊý¡Ã.
Ä¿µÄÊý×é
Êý×éÄÚÆ«ÒÆÁ¿
¶ÁÈ¡µÄ×Ö½ÚÊý
public void write(byte buf[]) throws SQLException
Ïò¶ÔÏóÀïдÈëÒ»¸öÊý×é
public void write(byte buf[], int off, int len) throws SQLException
´ÓÊý×éÀïдһЩÊý¾Ýµ½¶ÔÏó
²ÎÊý¡Ã.
Ä¿±êÊý×é
Êý×éÄÚÆ«ÒÆÁ¿
дÈë×Ö½ÚÊý
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 »ñÈ¡ÈçºÎ¿ØÖÆ´ó¶ÔÏóÄÚÈݵÄÐÅÏ¢£®
Õâ¸öģʽ±íÃ÷ÎÒÃÇҪдÈë´ó¶ÔÏó
Õâ¸öģʽ±íÃ÷ÎÒÃÇÒª¶ÁÈ¡´ó¶ÔÏó
Õâ¸öģʽÊÇȱʡµÄ£¬±íÃ÷ÎÒÃÇÒª¶Ô´ó¶ÔÏó½øÐжÁºÍдµÄ²Ù×÷
public LargeObject open(int oid) throws SQLException
Õâ¸ö·½·¨´ò¿ªÒ»¸öÏÖÓеĴó¶ÔÏó, ÒÔÆä OID Ϊ»ù´¡. Õâ¸ö·½·¨¼ÙÉè ÎÒÃÇÐèÒªREADºÍWRITE·ÃÎÊģʽ (ȱʡģʽ)£®
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 ³öÏÖ£®