clearSessionVariablesOnCommit
void sqlDataManager.clearSessionVariablesOnCommit ( boolean clearVars ) (professional and enterprise editions only)
Description
Clear session variables corresponding to a committed table automatically.
Parameters
- clearVars If true then session variables whose names match field names (case insensitive) will be automatically cleared when the table is 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 );
// Clear session variables on commit
// to avoid carry over
dm.clearSessionVariablesOnCommit( true );
See Also
- addSessionVariables() [SqlDataManager] - Adds the session variables to a database table for columns that match the session variable names
- addSessionVariablesOnCommit() [SqlDataManager] - Adds the session variables to a database table when a row of the table is committed
- clearSessionVariables() [SqlDataManager] - Clears the session variables corresponding to columns in a database table