You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2001/10/19 16:56:27 UTC
cvs commit: jakarta-turbine-torque/src/templates/sql/security db.props
mpoeschl 01/10/19 07:56:27
Modified: src/templates/sql/security db.props
Added: src/conf/database db2400
src/java/org/apache/torque/adapter DBDB2400.java
src/templates/sql/base/db2400 columns.vm table.vm unique.vm
tablefk.vm sequence.vm primarykey.vm index.vm
foreignkey.vm drop.vm db.props
src/templates/sql/db-init/db2400 windows.vm
src/templates/sql/id-table idtable.db2400
Log:
add support for db2 on as400
patch by "Weaver, Scott" <Sw...@rippe.com>
Revision Changes Path
1.1 jakarta-turbine-torque/src/conf/database/db2400
Index: db2400
===================================================================
database.driver=com.ibm.as400.access.AS400JDBCDriver
database.url=jdbc:as400://yourAS400/${database.name}
database.adaptor=DBDB2400
1.1 jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBDB2400.java
Index: DBDB2400.java
===================================================================
package org.apache.torque.adapter;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.sql.Connection;
import java.sql.SQLException;
/**
* Turbine Database Adapter for DB2/400 on the IBM AS400 platform.
*
* @author <a href="mailto:sweaver@rippe.com">Scott Weaver</a>
* @version $Id: DBDB2400.java,v 1.1 2001/10/19 14:56:27 mpoeschl Exp $
*/
public class DBDB2400 extends DBDB2App
{
/**
* DBDB2400 constructor.
*/
protected DBDB2400()
{
super();
}
/**
* This method is used to ignore case. Had to override the
* <code>org.apache.turbine.util.db.adapter.DBDB2App</code>
* until I figure out the best way to accomplish this.
*
* @param in The string whose case to ignore.
* @return The string in a case that can be ignored.
*/
public String ignoreCase(String in)
{
return in;
}
/**
* This method is used to ignore case. Ditto ignoreCase ;).
*
* @param in The string to transform to upper case.
* @return The upper case string.
*/
public String toUpperCase(String in)
{
return in;
}
}
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/columns.vm
Index: columns.vm
===================================================================
#foreach ($col in $table.Columns)
#set ( $type = $dbprops.get($col.Type) )
#set ( $size = $col.printSize() )
#set ( $default = $col.DefaultSetting )
#set ( $autoIncrement = $strings.select($col.isAutoIncrement(), $dbprops.get("AUTOINCREMENT"),"") )
#set ( $nullString = $strings.select($col.isNotNull(), $dbprops.get("NOTNULL"),"") )
#set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
$strings.sub($strings.collapseSpaces($entry)," ,",",")
#end
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/table.vm
Index: table.vm
===================================================================
-----------------------------------------------------------------------------
-- $table.Name
-----------------------------------------------------------------------------
$generator.parse("$basepath/drop.vm", "", "table", $tbl)
CREATE TABLE $table.Name
(
#set ( $cols = $generator.parse("$basepath/columns.vm", "", "table", $tbl) )
#set ( $unique = $generator.parse("$basepath/unique.vm", "", "table", $tbl) )
#if($strings.allEmpty([$unique]))$strings.chop($cols,2)#else$cols#end
#if($unique.length()>0)$strings.chop($unique,2)#end
);
#set ( $pk = $generator.parse("$basepath/primarykey.vm", "", "table", $tbl) )
#if($pk.length()>0)$pk#end
#set ( $fk = $generator.parse("$basepath/foreignkey.vm", "", "table", $tbl) )
#if ($fk.length()>0)$fk#end
#set ( $index = $generator.parse("$basepath/index.vm", "", "table", $tbl) )
#if($index.length() > 0)$index#end
##set $sequence = $generator.parse("$basepath/sequence.vm", "", "table", $tbl)
##if ($sequence.length()>0)$sequence#end
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/unique.vm
Index: unique.vm
===================================================================
#foreach ($unique in $table.Unices)
UNIQUE ($unique.ColumnList),
#end
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/tablefk.vm
<<Binary file>>
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/sequence.vm
Index: sequence.vm
===================================================================
#if ($table.IdMethod == "sequence")
CREATE SEQUENCE $table.SequenceName;
#end
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/primarykey.vm
Index: primarykey.vm
===================================================================
ALTER TABLE $table.Name
ADD CONSTRAINT ${table.Name}_PK
PRIMARY KEY ($table.printPrimaryKey());
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/index.vm
Index: index.vm
===================================================================
#foreach ($index in $table.Indices)
CREATE #if($index.IsUnique)UNIQUE#end INDEX $index.IndexName ON $table.Name ($index.IndexColumnList);
#end
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/foreignkey.vm
Index: foreignkey.vm
===================================================================
#foreach ($fk in $table.ForeignKeys)
ALTER TABLE $table.Name
ADD CONSTRAINT ${table.Name}_FK_${velocityCount} FOREIGN KEY ($fk.LocalColumnNames)
REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames);
#end
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/drop.vm
Index: drop.vm
===================================================================
drop table $table.Name;
#*
DB2 looks like oracle but I'm not sure
about the sequences.
#foreach ($col in $table.Columns)
#if ($col.isAutoIncrement())
drop sequence if exists ${table.Name}_SEQ;
#end
#end
*#
1.1 jakarta-turbine-torque/src/templates/sql/base/db2400/db.props
Index: db.props
===================================================================
# Taken from java.sql.Types in the IBM 1.3 JDK
# JDBC to DB2/400 mappings.
BIT =
TINYINT = SMALLINT
SMALLINT = SMALLINT
INTEGER = INT
BIGINT = BIGINT
FLOAT = FLOAT
REAL = REAL
DOUBLE = DOUBLE PRECISION
NUMERIC = NUMERIC
DECIMAL = DEC
CHAR = VARCHAR
VARCHAR = VARCHAR
LONGVARCHAR = LONG VARCHAR
DATE = DATE
TIME = TIME
TIMESTAMP = TIMESTAMP
BINARY =
VARBINARY = VARCHAR (32000) FOR BIT DATA
LONGVARBINARY =LONG VARCHAR FOR BIT DATA
NULL =
OTHER =
JAVA_OBJECT =
DISTINCT =
STRUCT =
ARRAY =
BLOB =
CLOB =
REF =
AUTOINCREMENT =
NOTNULL = NOT NULL
removeNotNullWithAutoIncrement = true
suppressDefaults = false
1.1 jakarta-turbine-torque/src/templates/sql/db-init/db2400/windows.vm
Index: windows.vm
===================================================================
ECHO DB2/400 Not implemented
1.1 jakarta-turbine-torque/src/templates/sql/id-table/idtable.db2400
Index: idtable.db2400
===================================================================
delete from ID_TABLE where id_table_id >= $initialID;
#foreach ($tbl in $tables)
insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES ($initialID, '$tbl.Name', 100, 10);
#set ( $initialID = $initialID + 1 )
#end
1.2 +1 -0 jakarta-turbine-torque/src/templates/sql/security/db.props
Index: db.props
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/templates/sql/security/db.props,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- db.props 2001/08/02 05:08:40 1.1
+++ db.props 2001/10/19 14:56:27 1.2
@@ -5,6 +5,7 @@
hypersonic=default
oracle=default
db2=default
+db2400=default
interbase=default
sybase=default
mssql=default
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org