org.glite.data.common.db
Class SchemaLoader

java.lang.Object
  extended byorg.glite.data.common.db.SchemaLoader

public class SchemaLoader
extends java.lang.Object

Utility class to conditionally load schema into a database.


Constructor Summary
SchemaLoader()
           
 
Method Summary
static void loadSchema(java.sql.Connection conn, java.lang.String schemaName, java.lang.String createStatement)
          Look for the specified schema, and create it if it does not exist.
static void loadSchemaFromResource(java.sql.Connection conn, java.lang.String schemaName, java.lang.String classpathResource)
          Look for specified schema, and load it into the database if it does not exist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaLoader

public SchemaLoader()
Method Detail

loadSchema

public static void loadSchema(java.sql.Connection conn,
                              java.lang.String schemaName,
                              java.lang.String createStatement)
                       throws java.sql.SQLException
Look for the specified schema, and create it if it does not exist.

Parameters:
conn - the database connection to load into
schemaName - the create statement to create the schema
Throws:
java.sql.SQLException - if there are problems loading the schema into the DB

loadSchemaFromResource

public static void loadSchemaFromResource(java.sql.Connection conn,
                                          java.lang.String schemaName,
                                          java.lang.String classpathResource)
                                   throws java.io.IOException,
                                          java.sql.SQLException
Look for specified schema, and load it into the database if it does not exist. The schema is taken from the specified classpath resource file.

Parameters:
conn - the DB connection to use
schemaName - the name of the schema to check
classpathResource - the name of the file that contains the schema definition
Throws:
java.io.IOException - if the classpath resource could not be found or read
java.sql.SQLException - if there are problems loading the schema into the DB