|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.props.Props
com.cometway.ak.Agent
com.cometway.jdbc.JDBCAgent
public class JDBCAgent
The JDBCAgent manages a JDBC connection and performs simple database tasks such as creating and dropping tables, and executing queries, inserts and updates.
| Field Summary |
|---|
| 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 | |
|---|---|
JDBCAgent()
|
|
| Method Summary | |
|---|---|
void |
closeConnection(java.sql.Connection connection)
Properly closes the specified Connection. |
boolean |
createTable(java.lang.String tableName,
java.util.List fieldList,
java.util.List typeList)
Creates the specified table using the specified parameters. |
boolean |
dropTable(java.lang.String tableName)
Drops the specified table from the databsae. |
void |
error(java.lang.String message,
java.lang.Exception e)
Overrided to fully report SQLExceptions. |
boolean |
executeInsert(java.lang.String tableName,
Props p)
Inserts the specified Props values into a table. |
java.util.Vector |
executeQuery(java.lang.String sql)
Executes the specified SQL query, returning the result as a Vector of Props. |
java.util.Vector |
executeQuery(java.lang.String tableName,
java.lang.String uniqueKey,
java.lang.String uniqueValue)
Executes a search query based on a unique key and value, returning the result as a Vector of Props. |
boolean |
executeUpdate(java.lang.String sql)
Executes the specified update SQL, returning true if the update succeeded; false otherwise. |
boolean |
executeUpdate(java.lang.String tableName,
Props p,
java.lang.String uniqueKey,
java.lang.String uniqueValue)
Updates the specified Props into the record specified by uniqueKey and uniqueValue. |
java.sql.Connection |
getConnection()
Creates a new connection to the database using the current JDBC related settings. |
java.lang.String |
getInsertPropsSQL(java.lang.String tableName,
Props p)
Generates appropriate SQL for inserting the specified Props into a table. |
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). |
void |
start()
Starts this agent by |
void |
stop()
Override this method to handle stop requests from the agent kernel. |
| 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JDBCAgent()
| Method Detail |
|---|
public void initProps()
initProps in interface AgentInterfaceinitProps in class Agentpublic void start()
start in interface AgentInterfacestart in class Agentpublic void stop()
Agent
stop in interface AgentInterfacestop in class Agentpublic void closeConnection(java.sql.Connection connection)
public boolean createTable(java.lang.String tableName,
java.util.List fieldList,
java.util.List typeList)
public boolean dropTable(java.lang.String tableName)
public void error(java.lang.String message,
java.lang.Exception e)
error in interface AgentInterfaceerror in class Agent
public boolean executeInsert(java.lang.String tableName,
Props p)
public java.util.Vector executeQuery(java.lang.String sql)
public java.util.Vector executeQuery(java.lang.String tableName,
java.lang.String uniqueKey,
java.lang.String uniqueValue)
public boolean executeUpdate(java.lang.String sql)
public boolean executeUpdate(java.lang.String tableName,
Props p,
java.lang.String uniqueKey,
java.lang.String uniqueValue)
public java.lang.String getInsertPropsSQL(java.lang.String tableName,
Props p)
public java.sql.Connection getConnection()
throws java.sql.SQLException
java.sql.SQLException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||