com.cometway.jdbc
Class JDBCExportAgent

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.jdbc.JDBCAgent
              extended by com.cometway.jdbc.PooledJDBCAgent
                  extended by com.cometway.jdbc.JDBCExportAgent
All Implemented Interfaces:
AgentInterface, HasStateMachineModel

public class JDBCExportAgent
extends PooledJDBCAgent

This agent exports the specified fields from a PropsList to the specified field and field types in a SQL table through a JDBC connection to the database. Note: This has only been tested with MS-SQL using the JTDS driver so far.


Field Summary
protected static java.lang.String DATETIME
           
protected static java.lang.String DOUBLE
           
protected  java.util.Vector from_fields
           
protected static java.lang.String INT
           
protected  JDBCConnection jdbcConnection
           
protected static java.text.SimpleDateFormat SQL_SDF
           
protected  java.sql.PreparedStatement statement
           
protected  java.util.Vector to_types
           
protected static java.lang.String VARCHAR
           
 
Fields inherited from class com.cometway.jdbc.PooledJDBCAgent
jdbcConnectionDriver
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Constructor Summary
JDBCExportAgent()
           
 
Method Summary
protected  void createStatement()
          Creates a PreparedStatement for inserting values into the table based on the to_table and to_fields properties.
 void initProps()
          Initializes the Props for this agent: "jdbc_driver" is the classname of the JDBC driver to use (default: sun.jdbc.odbc.JdbcOdbcDriver), "jdbc_url" is the JDBC URL of the database (ie: jdbc:odbc:mydb), "jdbc_username" is the database login username (default: none), "jdbc_password" is the database login password (default: none), "service_name" is the service_name used to register this agent if it is to be used as a service (default: none).
protected  void saveToDatabase()
          Inserts the records from the PropsList specified by database_name into the table specified by to_table.
 void start()
          Starts this agent by
 
Methods inherited from class com.cometway.jdbc.PooledJDBCAgent
closeConnectionDriver, getConnection, openConnectionDriver, stop
 
Methods inherited from class com.cometway.jdbc.JDBCAgent
closeConnection, createTable, dropTable, error, executeInsert, executeQuery, executeQuery, executeUpdate, executeUpdate, getInsertPropsSQL
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VARCHAR

protected static final java.lang.String VARCHAR
See Also:
Constant Field Values

INT

protected static final java.lang.String INT
See Also:
Constant Field Values

DOUBLE

protected static final java.lang.String DOUBLE
See Also:
Constant Field Values

DATETIME

protected static final java.lang.String DATETIME
See Also:
Constant Field Values

SQL_SDF

protected static final java.text.SimpleDateFormat SQL_SDF

jdbcConnection

protected JDBCConnection jdbcConnection

statement

protected java.sql.PreparedStatement statement

from_fields

protected java.util.Vector from_fields

to_types

protected java.util.Vector to_types
Constructor Detail

JDBCExportAgent

public JDBCExportAgent()
Method Detail

initProps

public void initProps()
Description copied from class: JDBCAgent
Initializes the Props for this agent: "jdbc_driver" is the classname of the JDBC driver to use (default: sun.jdbc.odbc.JdbcOdbcDriver), "jdbc_url" is the JDBC URL of the database (ie: jdbc:odbc:mydb), "jdbc_username" is the database login username (default: none), "jdbc_password" is the database login password (default: none), "service_name" is the service_name used to register this agent if it is to be used as a service (default: none).

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class PooledJDBCAgent

start

public void start()
Description copied from class: JDBCAgent
Starts this agent by

Specified by:
start in interface AgentInterface
Overrides:
start in class PooledJDBCAgent

createStatement

protected void createStatement()
                        throws java.lang.Exception
Creates a PreparedStatement for inserting values into the table based on the to_table and to_fields properties.

Throws:
java.lang.Exception

saveToDatabase

protected void saveToDatabase()
                       throws java.lang.Exception
Inserts the records from the PropsList specified by database_name into the table specified by to_table.

Throws:
java.lang.Exception