You must include the repraconn.jar file in your CLASSPATH environment variable setting.
For bsh enter:
CLASSPATH =$REPRA_HOME/lib/repraconn.jar:$CLASSPATH export CLASSPATH
For csh enter:
setenv CLASSPATH $REPRA_HOME/lib/repraconn.jar:$CLASSPATH
Using the RaXML utility in your code
Import the essential modules:
import org.dom4j.Element; import com.sybase.connector.repra.util.*;
Create an instance of RaXMLBuilder:
RaXMLBuilder raXML = new RaXMLBuilder();
Get the event body, which requires three parameters:
The URI of the xsd. file
The name of the database
The event ID of the current event, which can be any string value
If you want the transaction (<tran>) type to contain multiple database operations, enter:
foo.createTranDocument("file://dbeventstream.xsd", "pubs2"","00001001");
If you want the event (<dbevent>) type to contain a single database operation, enter:
foo.createEventDocument("file://dbeventstream.xsd", "pubs2"","00001001");
Add an operation, which requires two parameters:
The command
The name of the schema
For example:
Element oper1=foo.addOperation("update","authors"):
Add data to the operation, which requires these parameters:
the operation element
fieldName
fieldType
fieldValue, the string value of the field
For example:
foo.addValue(operl,"au_id"," CHAR","0001"); foo.addValue(oper1,"au_num","INT","1");
The field types, as SQL datatypes, are:
TEXT, DATETIME, SMALLDATETIME, MONEY, SMALLMONEY,
NUMERIC, DECIMAL, VARCHAR, CHAR, DATE, TIME
BINARY, IMAGE, VARBINARY
TINYINT, SMALLINT, INT
REAL
FLOAT
BIT
UNICHAR, UNIVARCHAR
UNITEXT
BIGINT, USMALLINT, UINT, UBIGINT
Add a where clause to the operation, which requires these parameters:
The operation element
fieldName
fieldType
fieldValue
SQL condition: either AND or OR
SQL operator: =, <,>, NOT, and so forth
For example:
foo.addWhere(oper1,"au_id","CHAR","0002","AND","=");
Create an XML file:
foo.write(fileName);
Get the String value of the event from the current XML document:
String dataStr=foo.xmlDocString();
Your application must send the dataStr object to the RepConnector connection.