org.apache.ojb.broker.platforms
Class TorqueDBHandling

java.lang.Object
  extended byorg.apache.ojb.broker.platforms.TorqueDBHandling
All Implemented Interfaces:
DBHandling

public class TorqueDBHandling
extends java.lang.Object
implements DBHandling

Provides basic database handling (drop, create, init) via torque.

Author:
Thomas Dudziak

Field Summary
protected static java.lang.String TORQUE_PLATFORM_DB2
          Torque db platforms
protected static java.lang.String TORQUE_PLATFORM_HYPERSONIC
           
protected static java.lang.String TORQUE_PLATFORM_INTERBASE
           
protected static java.lang.String TORQUE_PLATFORM_MSSQL
           
protected static java.lang.String TORQUE_PLATFORM_MYSQL
           
protected static java.lang.String TORQUE_PLATFORM_ORACLE
           
protected static java.lang.String TORQUE_PLATFORM_POSTGRESQL
           
protected static java.lang.String TORQUE_PLATFORM_SAPDB
           
protected static java.lang.String TORQUE_PLATFORM_SYBASE
           
 
Constructor Summary
TorqueDBHandling()
          Creates a new handling object.
 
Method Summary
 void addDBDefinitionFile(java.io.InputStream schemaStream)
          Adds an input stream of a db definition (in our case of a torque schema file).
 void addDBDefinitionFiles(java.lang.String srcDir, java.lang.String listOfFilenames)
          Adds the input files (in our case torque schema files) to use.
 void createCreationScript()
          Creates the db-creation sql script (but does not perform it).
 void createDB()
          Creates the database.
 void createInitScripts()
          Creates the initialization scripts (creation of tables etc.) but does not perform them.
 JdbcConnectionDescriptor getConnection()
          Returns the connection descriptor used by this handling object.
protected  java.lang.String getDBCreationUrl()
          Template-and-Hook method for generating the url required by the jdbc driver to allow for creating a database (as opposed to accessing an already-existing database).
protected  java.lang.String getDBManipulationUrl()
          Template-and-Hook method for generating the url required by the jdbc driver to allow for modifying an existing database.
 java.lang.String getTargetTorquePlatform()
          Returns the torque database platform used.
 void initDB()
          Creates the tables according to the schema files.
 void setConnection(JdbcConnectionDescriptor jcd)
          Sets the jdbc connection to use.
 void setWorkDir(java.lang.String dir)
          Sets the working directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TORQUE_PLATFORM_DB2

protected static final java.lang.String TORQUE_PLATFORM_DB2
Torque db platforms

See Also:
Constant Field Values

TORQUE_PLATFORM_HYPERSONIC

protected static final java.lang.String TORQUE_PLATFORM_HYPERSONIC
See Also:
Constant Field Values

TORQUE_PLATFORM_INTERBASE

protected static final java.lang.String TORQUE_PLATFORM_INTERBASE
See Also:
Constant Field Values

TORQUE_PLATFORM_MSSQL

protected static final java.lang.String TORQUE_PLATFORM_MSSQL
See Also:
Constant Field Values

TORQUE_PLATFORM_MYSQL

protected static final java.lang.String TORQUE_PLATFORM_MYSQL
See Also:
Constant Field Values

TORQUE_PLATFORM_ORACLE

protected static final java.lang.String TORQUE_PLATFORM_ORACLE
See Also:
Constant Field Values

TORQUE_PLATFORM_POSTGRESQL

protected static final java.lang.String TORQUE_PLATFORM_POSTGRESQL
See Also:
Constant Field Values

TORQUE_PLATFORM_SAPDB

protected static final java.lang.String TORQUE_PLATFORM_SAPDB
See Also:
Constant Field Values

TORQUE_PLATFORM_SYBASE

protected static final java.lang.String TORQUE_PLATFORM_SYBASE
See Also:
Constant Field Values
Constructor Detail

TorqueDBHandling

public TorqueDBHandling()
Creates a new handling object.

Method Detail

setConnection

public void setConnection(JdbcConnectionDescriptor jcd)
                   throws PlatformException
Sets the jdbc connection to use.

Specified by:
setConnection in interface DBHandling
Parameters:
jcd - The connection to use
Throws:
PlatformException - If the target database cannot be handled with torque

getConnection

public JdbcConnectionDescriptor getConnection()
Returns the connection descriptor used by this handling object.

Specified by:
getConnection in interface DBHandling
Returns:
The connection descriptor

getTargetTorquePlatform

public java.lang.String getTargetTorquePlatform()
Returns the torque database platform used.

Returns:
The target db platform

addDBDefinitionFiles

public void addDBDefinitionFiles(java.lang.String srcDir,
                                 java.lang.String listOfFilenames)
                          throws java.io.IOException
Adds the input files (in our case torque schema files) to use.

Specified by:
addDBDefinitionFiles in interface DBHandling
Parameters:
srcDir - The directory containing the files
listOfFilenames - The filenames in a comma-separated list
Throws:
java.io.IOException

addDBDefinitionFile

public void addDBDefinitionFile(java.io.InputStream schemaStream)
                         throws java.io.IOException
Adds an input stream of a db definition (in our case of a torque schema file).

Specified by:
addDBDefinitionFile in interface DBHandling
Throws:
java.io.IOException

createCreationScript

public void createCreationScript()
                          throws PlatformException
Creates the db-creation sql script (but does not perform it).

Throws:
PlatformException - If some error occurred

createDB

public void createDB()
              throws PlatformException
Creates the database.

Specified by:
createDB in interface DBHandling
Throws:
PlatformException - If some error occurred

createInitScripts

public void createInitScripts()
                       throws PlatformException
Creates the initialization scripts (creation of tables etc.) but does not perform them.

Throws:
PlatformException - If some error occurred

initDB

public void initDB()
            throws PlatformException
Creates the tables according to the schema files.

Specified by:
initDB in interface DBHandling
Throws:
PlatformException - If some error occurred

getDBCreationUrl

protected java.lang.String getDBCreationUrl()
Template-and-Hook method for generating the url required by the jdbc driver to allow for creating a database (as opposed to accessing an already-existing database).


getDBManipulationUrl

protected java.lang.String getDBManipulationUrl()
Template-and-Hook method for generating the url required by the jdbc driver to allow for modifying an existing database.


setWorkDir

public void setWorkDir(java.lang.String dir)
                throws java.io.IOException
Sets the working directory.

Specified by:
setWorkDir in interface DBHandling
Parameters:
dir - The directory
Throws:
java.io.IOException - If the directory does not exist or cannot be written/read


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14