⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbc.sgml

📁 关系型数据库 Postgresql 6.5.2
💻 SGML
📖 第 1 页 / 共 5 页
字号:
Oh, one last thing. If your object contains a line like:     public int oid;then, when the object is retrieved from the table, it is set to the oid within the table. Then, if the object is modified, and re-serialized, the existing entry is updated.If the oid variable is not present, then when the object is serialized, it is always inserted into the table, and any existing entry in the table is preserved.Setting oid to 0 before serialization, will also cause the object to be inserted. This enables an object to be duplicated in the database.Class postgresql.util.Serializejava.lang.Object   |   +----postgresql.util.Serialize   public class Serialize extends Object   This class uses PostgreSQL's object oriented features to store Java Objects. It does this by mapping a Java Class name to a table in the database. Each entry in this new table then represents a Serialized instance of this class. As each entry has an OID (Object IDentifier), this OID can be included in another table. This is too complex to show here, and will be documented in the main documents in more detail.Constructors public Serialize(Connection c,                  String type) throws SQLException          This creates an instance that can be used to serialize ordeserialize a Java object from a PostgreSQL table.Methods public Object fetch(int oid) throws SQLException          This fetches an object from a table, given it's OID        Parameters:                oid - The oid of the object        Returns:                Object relating to oid        Throws: SQLException                on error public int store(Object o) throws SQLException          This stores an object into a table, returning it's OID.          If the object has an int called OID, and it is > 0, then that value is used for the OID, and the table will be updated. If the value of OID is 0, then a new row will be created, and the value of OID will be set in the object. This enables an object's value in the database to be updateable. If the object has no int called OID, then the object is stored. However if the object is later retrieved, amended and stored again, it's new state will be appended to the table, and will not overwrite the old entries.        Parameters:                o - Object to store (must implement Serializable)        Returns:                oid of stored object        Throws: SQLException                on error  public static void create(Connection con,                           Object o) throws SQLException          This method is not used by the driver, but it creates a table, given a Serializable Java Object. It should be used before serializing any objects.        Parameters:                c - Connection to database                o - Object to base table on        Throws: SQLException                on error                   Returns:                Object relating to oid        Throws: SQLException                on error public int store(Object o) throws SQLException          This stores an object into a table, returning it's OID.          If the object has an int called OID, and it is > 0, then that value is used for the OID, and the table will be updated. If the value of OID is 0, then a new row will be created, and the value of OID will be set in the object. This enables an object's value in the database to be updateable. If the object has no int called OID, then the object is stored. However if the object is later retrieved, amended and stored again, it's new state will be appended to the table, and will not overwrite the old entries.        Parameters:                o - Object to store (must implement Serializable)        Returns:                oid of stored object        Throws: SQLException                on error  public static void create(Connection con,                           Object o) throws SQLException          This method is not used by the driver, but it creates a table, given a Serializable Java Object. It should be used before serializing any objects.        Parameters:                c - Connection to database                o - Object to base table on        Throws: SQLException                on error                 public static void create(Connection con,                           Class c) throws SQLException          This method is not used by the driver, but it creates a table, given a Serializable Java Object. It should be used before serializing any objects.        Parameters:                c - Connection to database                o - Class to base table on        Throws: SQLException                on error public static String toPostgreSQL(String name) throws SQLException                    This converts a Java Class name to a postgresql table, by          replacing . with _          Because of this, a Class name may not have _ in the name.          Another limitation, is that the entire class name (including          packages) cannot be longer than 31 characters (a limit forced by PostgreSQL).        Parameters:                name - Class name        Returns:                PostgreSQL table name        Throws: SQLException                on error           public static String toClassName(String name) throws SQLException          This converts a postgresql table to a Java Class name, by          replacing _ with .        Parameters:                name - PostgreSQL table name          Returns:                Class name        Throws: SQLException                on errorUtility ClassesThe postgresql.util package contains classes used by the internals of the main driver, and the other extensions.Class postgresql.util.PGmoney                                java.lang.Object   |   +----postgresql.util.PGobject           |           +----postgresql.util.PGmoney   public class PGmoney extends PGobject implements Serializable, Cloneable                  This implements a class that handles the PostgreSQL money typeVariables public double val                                          The value of the fieldConstructors            public PGmoney(double value)           Parameters:                value - of field                public PGmoney(String value) throws SQLException             This is called mainly from the other geometric types, when a point is imbeded within their definition.        Parameters:                value - Definition of this point in PostgreSQL's syntax public PGmoney()          Required by the driverMethods public void setValue(String s) throws SQLException        Parameters:                s - Definition of this point in PostgreSQL's syntax        Throws: SQLException                on conversion failure        Overrides:                setValue in class PGobject public boolean equals(Object obj)        Parameters:                obj - Object to compare with                                        Returns:                true if the two boxes are identical        Overrides:                equals in class PGobject public Object clone()                          This must be overidden to allow the object to be cloned        Overrides:                clone in class PGobject public String getValue()        Returns:                the PGpoint in the syntax expected by postgresql        Overrides:                getValue in class PGobjectClass postgresql.util.PGobjectjava.lang.Object   |   +----postgresql.util.PGobject   public class PGobject extends Object implements Serializable, Cloneable                  This class is used to describe data types that are unknown by <acronym>JDBC</acronym> Standard.    A call to postgresql.Connection permits a class that extends this class to be associated with a named type. This is how the postgresql.geometric package operates.    ResultSet.getObject() will return this class for any type that is not recognised on having it's own handler. Because of this, any postgresql data type is supported.Constructors public PGobject()          This is called by postgresql.Connection.getObject() to create the object.Methods public final void setType(String type)          This method sets the type of this object.          It should not be extended by subclasses, hence its final        Parameters:                type - a string describing the type of the object public void setValue(String value) throws SQLException          This method sets the value of this object. It must be overidden.        Parameters:                value - a string representation of the value of the                object        Throws: SQLException                thrown if value is invalid for this type     public final String getType()          As this cannot change during the life of the object, it's final.        Returns:                the type name of this object public String getValue()          This must be overidden, to return the value of the object, in the form required by postgresql.        Returns:                the value of this object public boolean equals(Object obj)          This must be overidden to allow comparisons of objects        Parameters:                obj - Object to compare with        Returns:                true if the two boxes are identical        Overrides:                equals in class Object public Object clone()          This must be overidden to allow the object to be cloned        Overrides:                clone in class Object public String toString()          This is defined here, so user code need not overide it.                  Returns:                the value of this object, in the syntax expected by postgresql        Overrides:                toString in class ObjectClass postgresql.util.PGtokenizerjava.lang.Object   |   +----postgresql.util.PGtokenizer   public class PGtokenizer extends Object   This class is used to tokenize the text output of postgres.   We could have used StringTokenizer to do this, however, we needed to handle nesting of '(' ')' '[' ']' '<' and '>' as these are used by the geometric data types.   It's mainly used by the geometric classes, but is useful in parsing any output from custom data types output from postgresql.                    See Also:          PGbox, PGcircle, PGlseg, PGpath, PGpoint, PGpolygon          Constructors public PGtokenizer(String string,                    char delim)          Create a tokeniser.        Parameters:                string - containing tokens                delim - single character to split the tokensMethods         public int tokenize(String string,                     char delim)          This resets this tokenizer with a new string and/or delimiter.        Parameters:                string - containing tokens                delim - single character to split the tokens public int getSize()        Returns:                the number of tokens available public String getToken(int n)        Parameters:                n - Token number ( 0 ... getSize()-1 )        Returns:                The token value public PGtokenizer tokenizeToken(int n,                                  char delim)          This returns a new tokenizer based on one of our tokens. The geometric datatypes use this to process nested tokens (usually PGpoint).        Parameters:                n - Token number ( 0 ... getSize()-1 )                delim - The delimiter to use        Returns:                A new instance of PGtokenizer based on the token public static String remove(String s,                             String l,                             String t)          This removes the lead/trailing strings from a string        Parameters:                s - Source string                l - Leading string to remove                t - Trailing string to remove                        Returns:                String without the lead/trailing strings public void remove(String l,                    String t)          This removes the lead/trailing strings from all tokens        Parameters:                l - Leading string to remove                t - Trailing string to remove public static String removePara(String s)          Removes ( and ) from the beginning and end of a string        Parameters:                s - String to remove from        Returns:                String without the ( or ) public void removePara()          Removes ( and ) from the beginning and end of all tokens        Returns:                String without the ( or ) public static String removeBox(String s)             Removes [ and ] from the beginning and end of a string        Parameters:                s - String to remove from           Returns:                String without the [ or ] public void removeBox()          Removes [ and ] from the beginning and end of all tokens        Returns:                String without the [ or ] public static String removeAngle(String s)          Removes < and > from the beginning and end of a string        Parameters:                s - String to remove from        Returns:                Strin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -