Subject | Re: [Firebird-Java] Java support in Firebird |
---|---|
Author | Jim Starkey |
Post date | 2005-04-28T15:19:14Z |
Roman Rokytskyy wrote:
maintain if you actually passed the parameters necessary for triggers,
udfs, and procedures rather than requiring them to call static procedure
to pick these things out of the ether. A trigger, for examples, needs a
connection, a pre-update records (possibly null), a post-update record,
and a trigger operation type. These should be passed directly to the
trigger.
In Netfrastruture, which has had an embedded Java implementation for
five years, the signature for a trigger method is:
public static void methodName (Connection connection, Record
oldVersion, Record newVersion, int type)
where Record:
public interface Record
{
public static final int PreInsert = 1;
public static final int PostInsert = 2;
public static final int PreUpdate = 4;
public static final int PostUpdate = 8;
public static final int PreDelete = 16;
public static final int PostDelete = 32;
public static final int PreCommit = 64;
public static final int PostCommit = 128;
public String getSchemaName() throws SQLException;
public String getTableName() throws SQLException;
public int getColumnId (String columnName) throws
SQLException;
public int nextColumnId (int columnId) throws SQLException;
public int nextPrimaryKeyColumn (int columnId) throws
SQLException;
public boolean isChanged (int columnId, Record record) throws
SQLException;
public boolean wasNull () throws SQLException;
public String getColumnName (int columnId) throws SQLException;
public int getColumnType (int columnId) throws SQLException;
public int getPrecision (int columnId) throws SQLException;
public int getScale (int columnId) throws SQLException;
public String getString(String columnName) throws SQLException;
public boolean getBoolean(String columnName) throws SQLException;
public byte getByte(String columnName) throws SQLException;
public short getShort(String columnName) throws SQLException;
public int getInt(String columnName) throws SQLException;
public long getLong(String columnName) throws SQLException;
public float getFloat(String columnName) throws SQLException;
public double getDouble(String columnName) throws SQLException;
public byte[] getBytes(String columnName) throws SQLException;
public java.sql.Timestamp getTimestamp(String columnName) throws
SQLException;
public java.sql.Date getDate(String columnName) throws SQLException;
public java.sql.Time getTime(String columnName) throws SQLException;
public netfrastructure.sql.NfsBlob getBlob (String columnName)
throws SQLException;
public netfrastructure.sql.NfsBlob getClob (String columnName)
throws SQLException;
public void setNull(String columnName, int sqlType)
throws SQLException;
public void setString(String columnName, String value)
throws SQLException;
public void setBoolean(String columnName, boolean value)
throws SQLException;
public void setByte(String columnName, byte value) throws
SQLException;
public void setShort(String columnName, short value)
throws SQLException;
public void setInt(String columnName, int value) throws
SQLException;
public void setLong(String columnName, long value) throws
SQLException;
public void setFloat(String columnName, float value)
throws SQLException;
public void setDouble(String columnName, double value)
throws SQLException;
public void setBytes(String columnName, byte[] value)
throws SQLException;
public void setTimestamp(String columnName,
java.sql.Timestamp value) throws SQLException;
public void setDate(String columnName, java.sql.Date
value) throws SQLException;
public void setTime(String columnName, java.sql.Time
value) throws SQLException;
public void setBlob(String columnName, java.sql.Blob
value) throws SQLException;
public void setClob(String columnName, java.sql.Clob
value) throws SQLException;
public String getString(int columnId) throws SQLException;
public boolean getBoolean(int columnId) throws SQLException;
public byte getByte(int columnId) throws SQLException;
public short getShort(int columnId) throws SQLException;
public int getInt(int columnId) throws SQLException;
public long getLong(int columnId) throws SQLException;
public float getFloat(int columnId) throws SQLException;
public double getDouble(int columnId) throws SQLException;
public byte[] getBytes(int columnIndex) throws SQLException;
public java.sql.Timestamp getTimestamp(int columnId) throws
SQLException;
public java.sql.Date getDate(int columnId) throws SQLException;
public java.sql.Time getTime(int columnId) throws SQLException;
public netfrastructure.sql.NfsBlob getBlob(int columnId) throws
SQLException;
public netfrastructure.sql.NfsClob getClob(int columnId) throws
SQLException;
public void setNull(int columnId, int sqlType) throws
SQLException;
public void setString(int columnId, String value) throws
SQLException;
public void setBoolean(int columnId, boolean value)
throws SQLException;
public void setByte(int columnId, byte value) throws
SQLException;
public void setShort(int columnId, short value) throws
SQLException;
public void setInt(int columnId, int value) throws
SQLException;
public void setLong(int columnId, long value) throws
SQLException;
public void setFloat(int columnId, float value) throws
SQLException;
public void setDouble(int columnId, double value) throws
SQLException;
public void setBytes(int columnId, byte[] value) throws
SQLException;
public void setTimestamp(int columnId, java.sql.Timestamp
value) throws SQLException;
public void setDate(int columnId, java.sql.Date value)
throws SQLException;
public void setTime(int columnId, java.sql.Time value)
throws SQLException;
public void setBlob(int columnId, java.sql.Blob value)
throws SQLException;
public void setClob(int columnId, java.sql.Clob value)
throws SQLException;
}
A key issue for triggers is metadata access. Existing Firebird triggers
are necessarily single table, so built in knowledge of metadata isn't a
problem. Java triggers, on the other hand, are naturally table
independent, so building in a mechanism for rapid, context sensitve
access to metadata is critical.
The methods "nextColumnId" and "nextPrimaryKeyColumn" allow rapid
iteration through all fields or primary keys, for example:
for (int n = -1; (n = record.nextPrimaryKeyColumn (n)) >= 0;)
key += record.getString (n) + "^";
The rest of the methods are necessary for metadata and data access and
data update.
--
Jim Starkey
Netfrastructure, Inc.
978 526-1376
>It's been a while since we have published a document describing possibleIt would be both easier to use, easier to implement, and easier to
>architecture to support external procedures written in different languages.
>Today we have released first preview version of Java support in Firebird.
>
>
>
maintain if you actually passed the parameters necessary for triggers,
udfs, and procedures rather than requiring them to call static procedure
to pick these things out of the ether. A trigger, for examples, needs a
connection, a pre-update records (possibly null), a post-update record,
and a trigger operation type. These should be passed directly to the
trigger.
In Netfrastruture, which has had an embedded Java implementation for
five years, the signature for a trigger method is:
public static void methodName (Connection connection, Record
oldVersion, Record newVersion, int type)
where Record:
public interface Record
{
public static final int PreInsert = 1;
public static final int PostInsert = 2;
public static final int PreUpdate = 4;
public static final int PostUpdate = 8;
public static final int PreDelete = 16;
public static final int PostDelete = 32;
public static final int PreCommit = 64;
public static final int PostCommit = 128;
public String getSchemaName() throws SQLException;
public String getTableName() throws SQLException;
public int getColumnId (String columnName) throws
SQLException;
public int nextColumnId (int columnId) throws SQLException;
public int nextPrimaryKeyColumn (int columnId) throws
SQLException;
public boolean isChanged (int columnId, Record record) throws
SQLException;
public boolean wasNull () throws SQLException;
public String getColumnName (int columnId) throws SQLException;
public int getColumnType (int columnId) throws SQLException;
public int getPrecision (int columnId) throws SQLException;
public int getScale (int columnId) throws SQLException;
public String getString(String columnName) throws SQLException;
public boolean getBoolean(String columnName) throws SQLException;
public byte getByte(String columnName) throws SQLException;
public short getShort(String columnName) throws SQLException;
public int getInt(String columnName) throws SQLException;
public long getLong(String columnName) throws SQLException;
public float getFloat(String columnName) throws SQLException;
public double getDouble(String columnName) throws SQLException;
public byte[] getBytes(String columnName) throws SQLException;
public java.sql.Timestamp getTimestamp(String columnName) throws
SQLException;
public java.sql.Date getDate(String columnName) throws SQLException;
public java.sql.Time getTime(String columnName) throws SQLException;
public netfrastructure.sql.NfsBlob getBlob (String columnName)
throws SQLException;
public netfrastructure.sql.NfsBlob getClob (String columnName)
throws SQLException;
public void setNull(String columnName, int sqlType)
throws SQLException;
public void setString(String columnName, String value)
throws SQLException;
public void setBoolean(String columnName, boolean value)
throws SQLException;
public void setByte(String columnName, byte value) throws
SQLException;
public void setShort(String columnName, short value)
throws SQLException;
public void setInt(String columnName, int value) throws
SQLException;
public void setLong(String columnName, long value) throws
SQLException;
public void setFloat(String columnName, float value)
throws SQLException;
public void setDouble(String columnName, double value)
throws SQLException;
public void setBytes(String columnName, byte[] value)
throws SQLException;
public void setTimestamp(String columnName,
java.sql.Timestamp value) throws SQLException;
public void setDate(String columnName, java.sql.Date
value) throws SQLException;
public void setTime(String columnName, java.sql.Time
value) throws SQLException;
public void setBlob(String columnName, java.sql.Blob
value) throws SQLException;
public void setClob(String columnName, java.sql.Clob
value) throws SQLException;
public String getString(int columnId) throws SQLException;
public boolean getBoolean(int columnId) throws SQLException;
public byte getByte(int columnId) throws SQLException;
public short getShort(int columnId) throws SQLException;
public int getInt(int columnId) throws SQLException;
public long getLong(int columnId) throws SQLException;
public float getFloat(int columnId) throws SQLException;
public double getDouble(int columnId) throws SQLException;
public byte[] getBytes(int columnIndex) throws SQLException;
public java.sql.Timestamp getTimestamp(int columnId) throws
SQLException;
public java.sql.Date getDate(int columnId) throws SQLException;
public java.sql.Time getTime(int columnId) throws SQLException;
public netfrastructure.sql.NfsBlob getBlob(int columnId) throws
SQLException;
public netfrastructure.sql.NfsClob getClob(int columnId) throws
SQLException;
public void setNull(int columnId, int sqlType) throws
SQLException;
public void setString(int columnId, String value) throws
SQLException;
public void setBoolean(int columnId, boolean value)
throws SQLException;
public void setByte(int columnId, byte value) throws
SQLException;
public void setShort(int columnId, short value) throws
SQLException;
public void setInt(int columnId, int value) throws
SQLException;
public void setLong(int columnId, long value) throws
SQLException;
public void setFloat(int columnId, float value) throws
SQLException;
public void setDouble(int columnId, double value) throws
SQLException;
public void setBytes(int columnId, byte[] value) throws
SQLException;
public void setTimestamp(int columnId, java.sql.Timestamp
value) throws SQLException;
public void setDate(int columnId, java.sql.Date value)
throws SQLException;
public void setTime(int columnId, java.sql.Time value)
throws SQLException;
public void setBlob(int columnId, java.sql.Blob value)
throws SQLException;
public void setClob(int columnId, java.sql.Clob value)
throws SQLException;
}
A key issue for triggers is metadata access. Existing Firebird triggers
are necessarily single table, so built in knowledge of metadata isn't a
problem. Java triggers, on the other hand, are naturally table
independent, so building in a mechanism for rapid, context sensitve
access to metadata is critical.
The methods "nextColumnId" and "nextPrimaryKeyColumn" allow rapid
iteration through all fields or primary keys, for example:
for (int n = -1; (n = record.nextPrimaryKeyColumn (n)) >= 0;)
key += record.getString (n) + "^";
The rest of the methods are necessary for metadata and data access and
data update.
--
Jim Starkey
Netfrastructure, Inc.
978 526-1376