buildSchemas

void sqlDataManager.buildSchemas ( ) (professional and enterprise editions only)
void sqlDataManager.buildSchemas ( List tables ) (professional and enterprise editions only)

Description

Collect the database schema information, including foreign key relations between tables.

Schemas must be built for any tables that will be used by this DataManager before data can be added.

Parameters

  • tables (option) A list of table names, as strings, for which to build schemas.

Return Values

Returns void.

Change Log

Version Description
5.0 Available for professional and enterprise editions.

Examples

Build Database Schema using a BasicDataSource

 // 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();

Build Database Schema using an SshDataSource

 import com.screenscraper.datamanager.sql.*;

 // SshDataSource
 ds = new SshDataSource( "[email protected]", "ssPass" );
 ds.setDriverClassName( "com.mysql.jdbc.Driver" );
 ds.setUsername( "user" );
 ds.setPassword( "psswrd" );

 // Accepted values for the first parameter of setUrl are:
 //   SshDataSource.MYSQL
 //   SshDataSource.MSSQL
 //   SshDataSource.ORACLE
 //   SshDataSource.POSTGRESQL
 ds.setUrl( SshDataSource.MYSQL, 3306, "database" );

 // Create Data Manager
 dm = new SqlDataManager( ds, session );

 // Build Schemas For all Tables
 dm.buildSchemas();