public final class MckoiConnection extends Object
Example,
Connection connection = java.sql.DriverManager.getConnection( .... ); MckoiConnection mckoi_connection = new MckoiConnection(connection); // 'mckoi_connection' is used for mckoi specific comms.
Constructor and Description |
---|
MckoiConnection(Connection connection)
Constructs the Mckoi specific extension access object.
|
Modifier and Type | Method and Description |
---|---|
void |
addTriggerListener(String trigger_name,
TriggerListener trigger_listener)
Registers a TriggerListener to listen for any triggers that are fired
with the given name.
|
static String |
quote(String java_string)
Given a string, this will use escape codes to convert the Java string into
a Mckoi SQL string that can be parsed correctly by the database.
|
void |
removeTriggerListener(String trigger_name,
TriggerListener trigger_listener)
Removes a TriggerListener that is listening for triggers with the given
name.
|
void |
setStrictGetObject(boolean status)
This method can be used to disable strict get object in ResultSet.
|
void |
setVerboseColumnNames(boolean status)
This method is used to enable verbose column names in ResultSetMetaData.
|
public MckoiConnection(Connection connection)
public void setStrictGetObject(boolean status)
Strict get is enabled by default.
public void setVerboseColumnNames(boolean status)
public void addTriggerListener(String trigger_name, TriggerListener trigger_listener)
NOTE: All trigger events are fired on a dedicated trigger thread. All triggers are fired from this thread in sequence.
trigger_name
- the name of the database trigger to listen for.trigger_listener
- the listener to be notified when the trigger
event occurs.public void removeTriggerListener(String trigger_name, TriggerListener trigger_listener)
trigger_name
- the name of the database trigger to stop listening
for.trigger_listener
- the listener to stop being notified of trigger
events for this trigger name.public static String quote(String java_string)
String user_input = [some untrusted string] Statement statement = connection.createStatement(); ResultSet result = statement.executeQuery( "SELECT number FROM Part WHERE number = " + MckoiConnection.quote(user_input));If the user supplies the string "Gr's\nut\'", this method will generate the SQL query string;
SELECT number FROM Part WHERE number = 'Gr\'s\\nut\\\''This is used for generating secure dynamic SQL commands. It is particularly important if the quoted strings are coming from an untrusted source.
This security precaution is not necessary if using PreparedStatement to form the SQL parameters.
Copyright © 2015. All rights reserved.