addSessionVariablesOnCommit
void sqlDataManager.addSessionVariablesOnCommit ( boolean automate ) (professional and enterprise editions only)
Description
Add corresponding session variables to the tables automatically when it is committed.
Parameters
- automate If true then session variables whose names match field names (case insensitive) will be automatically added to queries when the fields are committed.
Return Values
Returns void.
Change Log
Version |
Description |
5.0 |
Available for professional and enterprise editions. |
Examples
Automate Session Variables
// Import classes
import com.screenscraper.datamanager.*;
import com.screenscraper.datamanager.sql.*;
import org.apache.commons.dbcp.BasicDataSource;
// Set Variables
host = "127.0.0.1:3306";
database = "mydb";
username = "user";
password = "pwrd";
parameters = "autoReconnect=true&useCompression=true";
// Build the BasicDataSource for the database connection
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName( "com.mysql.jdbc.Driver" );
ds.setUsername( username );
ds.setPassword( password );
ds.setUrl( "jdbc:mysql://" + host + "/" + database + "?" + parameters );
// Get MySQL datamanager
dm = new SqlDataManager( ds, session );
// Build Schemas For all Tables
dm.buildSchemas();
// Write Information to Database
// automatically using session variables
dm.addSessionVariablesOnCommit( true );
See Also
- addSessionVariables() [SqlDataManager] - Adds the session variables to a database table for columns that match the session variable names
- clearSessionVariables() [SqlDataManager] - Clears the session variables corresponding to columns in a database table
- clearSessionVariablesOnCommit() [SqlDataManager] - Clears the session variables corresponding to columns in a database table when a row of data is committed to the table