brekke 01/12/14 14:14:06 Modified: src/java/org/apache/torque/adapter DBFactory.java src/java/org/apache/torque/task TorqueDataDumpTask.java Added: notes sybase-status.txt profile sybase.profile src/templates/sql/db-init/sybase createdb.vm src/templates/sql/load/sybase row.vm val.vm Removed: src/templates/sql/db-init/sybase unix.vm windows.vm Log: From patch submitted by Byron Foster: Support for sybase updated and testbed passes. Needed to re-implement TorqueDataDump.TableTool with village due to the sybase jdbc driver not being jdbc 2.0 compliant. Notes about the support for sybase have been added in the notes directory. Revision Changes Path 1.1 jakarta-turbine-torque/notes/sybase-status.txt Index: sybase-status.txt =================================================================== -------------------------------------------------------------------------- S Y B A S E S T A T U S -------------------------------------------------------------------------- o Sybase support is working and passing the testbed. JConnect, the jdbc driver distributed by Sybase, is not completely jdbc 2.0 compliant, so certain items will not work. The database metadata is not supported so the JDBCToXMLSchema tasks will not generate the schema properly at this time. o TorqueDataDumpTask will need to know about contraints. On databases without constrains, the load generated sql will work, but with constraints, the insert statements need to be in the correct order or they will fail with constaint violations. 1.1 jakarta-turbine-torque/profile/sybase.profile Index: sybase.profile =================================================================== # location of jar that you will be using for testing # so that it can be copied into the dist/lib directory. torque.testDatabaseJar = ${lib.repo}/jconnect-5.5.jar torque.idMethod = idbroker torque.defaultDatabase = bookstore torque.sqlTest.defaultDatabase = sqltest torque.sqlTest.databaseUrl = jdbc:sybase:Tds:localhost:5000/sqltest lib.dir = ../lib # ------------------------------------------------------------------- # # T O R Q U E C O N F I G U R A T I O N F I L E # # ------------------------------------------------------------------- project = bookstore # ------------------------------------------------------------------- # # T A R G E T D A T A B A S E # # ------------------------------------------------------------------- database = sybase # ------------------------------------------------------------------- # # O B J E C T M O D E L I N F O R M A T I O N # # ------------------------------------------------------------------- # These settings will allow you to customize the way your # Peer-based object model is created. # ------------------------------------------------------------------- # addSaveMethod=true adds tracking code to determine how to save objects # # addGetByNameMethod=true adds methods to get fields by name/position # # complexObjectModel=true generates an om with collection support # # addTimeStamp=true puts time stamps in generated files # # addIntakeRetrievable=implement Intake's Retrievable interface # ------------------------------------------------------------------- targetPackage=org.apache.torque.test basePrefix=Base addSaveMethod=true addGetByNameMethod=true complexObjectModel=true addTimeStamp=true addIntakeRetrievable=false # ------------------------------------------------------------------- # # D A T A B A S E S E T T I N G S # # ------------------------------------------------------------------- # JDBC connection settings. This is used by the JDBCToXML task that # will create an XML database schema from JDBC metadata. These # settings are also used by the SQL Ant task to initialize your # Turbine system with the generated SQL. # ------------------------------------------------------------------- createDatabaseUrl = jdbc:sybase:Tds:localhost:5000/master databaseUrl = jdbc:sybase:Tds:localhost:5000/bookstore databaseDriver = com.sybase.jdbc2.jdbc.SybDriver databaseUser = sa databasePassword = databaseHost = localhost # Tells JDBC task that javaName attribute for the tables and columns # should be made same as SQL name. sameJavaName=false # ------------------------------------------------------------------- # You should NOT have to edit anything below here. # ------------------------------------------------------------------- # ------------------------------------------------------------------- # # T E M P L A T E P A T H # # ------------------------------------------------------------------- templatePath = ../templates # ------------------------------------------------------------------- # # C O N T R O L T E M P L A T E S # # ------------------------------------------------------------------- SQLControlTemplate = sql/base/Control.vm OMControlTemplate = om/Control.vm idTableControlTemplate = sql/id-table/Control.vm DataDTDControlTemplate = data/Control.vm DataDumpControlTemplate = data/dump/Control.vm DataSQLControlTemplate = sql/load/Control.vm # ------------------------------------------------------------------- # # O U T P U T D I R E C T O R Y # # ------------------------------------------------------------------- outputDirectory=src # ------------------------------------------------------------------- # # S C H E M A D I R E C T O R Y # # ------------------------------------------------------------------- schemaDirectory=schema 1.19 +2 -1 jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java Index: DBFactory.java =================================================================== RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBFactory.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- DBFactory.java 2001/11/15 18:22:14 1.18 +++ DBFactory.java 2001/12/14 22:14:06 1.19 @@ -68,7 +68,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Brett McLaughlin</a> * @author <a href="mailto:[EMAIL PROTECTED]">Ralf Stranzenbach</a> * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a> - * @version $Id: DBFactory.java,v 1.18 2001/11/15 18:22:14 mpoeschl Exp $ + * @version $Id: DBFactory.java,v 1.19 2001/12/14 22:14:06 brekke Exp $ */ public class DBFactory { @@ -160,6 +160,7 @@ driverToAdapterMap.put("org.postgresql.Driver", "DBPostgres"); driverToAdapterMap.put("com.sap.dbtech.jdbc.DriverSapDB", "DBSapDB"); driverToAdapterMap.put("com.sybase.jdbc.SybDriver", "DBSybase"); + driverToAdapterMap.put("com.sybase.jdbc2.jdbc.SybDriver", "DBSybase"); driverToAdapterMap.put("weblogic.jdbc.pool.Driver", "DBWeblogic"); } 1.6 +22 -18 jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataDumpTask.java Index: TorqueDataDumpTask.java =================================================================== RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataDumpTask.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TorqueDataDumpTask.java 2001/11/05 10:12:19 1.5 +++ TorqueDataDumpTask.java 2001/12/14 22:14:06 1.6 @@ -71,13 +71,16 @@ import org.apache.torque.engine.database.model.Database; import org.apache.torque.engine.database.transform.XmlToAppData; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + /** * An extended Texen task used for dumping data from db into XML * * @author <a href="mailto:[EMAIL PROTECTED]"> Fedor Karpelevitch </a> * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a> * @author <a href="[EMAIL PROTECTED]">Daniel Rall</a> - * @version $Id: TorqueDataDumpTask.java,v 1.5 2001/11/05 10:12:19 dlr Exp $ + * @version $Id: TorqueDataDumpTask.java,v 1.6 2001/12/14 22:14:06 brekke Exp $ */ public class TorqueDataDumpTask extends TorqueDataModelTask @@ -293,9 +296,10 @@ */ public class TableTool implements Iterator { - private ResultSet rs; + private QueryDataSet qds; private boolean isEmpty; - + private int curIndex = -1; + private Record curRec = null; /** * Constructor for the TableTool object @@ -312,10 +316,11 @@ * @exception SQLException Problem using database record set * cursor. */ - protected TableTool(ResultSet rs) throws SQLException + protected TableTool(QueryDataSet qds) throws Exception { - this.rs = rs; - this.isEmpty = !rs.isBeforeFirst(); + this.qds = qds; + this.qds.fetchRecords(); + this.isEmpty = !(qds.size() > 0); } @@ -328,14 +333,13 @@ * @exception SQLException Problem creating connection or * executing query. */ - public TableTool fetch(String tableName) throws SQLException + public TableTool fetch(String tableName) throws Exception { log("Fetching data for table " + tableName, Project.MSG_INFO); // Set Statement object in associated TorqueDataDump // instance - stmt = conn.createStatement(); return new TableTool - (stmt.executeQuery("SELECT * FROM " + tableName)); + (new QueryDataSet(conn, "SELECT * FROM " + tableName)); } @@ -348,11 +352,11 @@ { try { - return !(rs.isLast() || this.isEmpty); + return ((this.curIndex < this.qds.size()-1) && (!isEmpty)); } - catch (SQLException se) + catch (Exception se) { - System.err.println("SQLException :"); + System.err.println("Exception :"); se.printStackTrace(); } return false; @@ -370,11 +374,11 @@ try { System.err.print("."); - rs.next(); + this.curRec = this.qds.getRecord(++curIndex); } - catch (SQLException se) + catch (Exception se) { - System.err.println("SQLException while iterating:"); + System.err.println("Exception while iterating:"); se.printStackTrace(); throw new NoSuchElementException(se.getMessage()); } @@ -392,11 +396,11 @@ { try { - return rs.getString(columnName); + return(this.curRec.getValue(columnName).asString()); } - catch (SQLException se) + catch (Exception se) { - log("SQLException fetching value " + columnName + ": " + + log("Exception fetching value " + columnName + ": " + se.getMessage(), Project.MSG_ERR); } return null; 1.1 jakarta-turbine-torque/src/templates/sql/db-init/sybase/createdb.vm Index: createdb.vm =================================================================== #foreach ($databaseName in $databaseNames) USE MASTER ; DROP DATABASE $databaseName ; CREATE DATABASE $databaseName ; #end 1.1 jakarta-turbine-torque/src/templates/sql/load/sybase/row.vm Index: row.vm =================================================================== INSERT INTO $row.Table.Name (## #set ($comma="")#foreach($col in $row.ColumnValues)$comma${col.Column.Name}#set($comma=",")#end) VALUES (#set ($comma="")#foreach($col in $row.ColumnValues)$comma${generator.parse("sql/load/sybase/val.vm", "", "column", $col)}#set ($comma=",")#end); 1.1 jakarta-turbine-torque/src/templates/sql/load/sybase/val.vm Index: val.vm =================================================================== #if($column.Column.TorqueType=="VARCHAR")'$column.Value'#else$column.Value#end
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>