I was trying to run BasePeer.initTableSchema for my own table/database
and kept getting an error because my table does not exist in the Turbine
database. So I wrote a patch that basically does the following:
1. adds a method initTableSchema(String tableName, String dbName) the
dbName is the name in the TurbineResources file.
2. makes initTableSchema(String tableName) call initTableSchema(String
tableName, String dbName) with a null dbName.
If there is another way to do this please let me know. Otherwise Id
like to patch basepeer with the following patch:
############# Start patch #############################
Index: turbine/src/java/org/apache/turbine/om/peer/BasePeer.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/om/peer/BasePeer.java,v
retrieving revision 1.27
diff -u -r1.27 BasePeer.java
--- turbine/src/java/org/apache/turbine/om/peer/BasePeer.java 2000/07/07
13:06:42 1.27
+++ turbine/src/java/org/apache/turbine/om/peer/BasePeer.java 2000/07/10
16:36:19
@@ -192,28 +192,56 @@
}
return byteArray;
}
-
/**
* Sets up a Schema for a table. This schema is then normally used
as
* the argument for initTableColumns
- */
+ */
public static Schema initTableSchema(String tableName)
{
+ Schema schema = null;
+ String dbName = null;
+ try
+ {
+ schema = initTableSchema(tableName, dbName);
+ }
+ catch(Exception e)
+ {
+ Log.error(e);
+ throw new Error("Error in BasePeer.initTableSchema(" +
tableName + "): " +
+ e.getMessage());
+ }
+ return schema;
+ }
+ /**
+ * Sets up a Schema for a table. This schema is then normally used
as
+ * the argument for initTableColumns
+ * @param The name of the table
+ * @param the propery name for the database in the Turbineresources
file
+ */
+ public static Schema initTableSchema(String tableName, String
dbName)
+ {
// Log.note("Executing initTableSchema for table: " +
tableName);
Schema schema = null;
DBConnection db = null;
-
+
try
{
- // get a connection to the db
- db = DBBroker.getInstance().getConnection();
+ if (dbName == null)
+ {
+ // get a connection to the db
+ db = DBBroker.getInstance().getConnection();
+ }else{
+ // get a connection to the db
+ db = DBBroker.getInstance().getConnection( dbName );
+ }
+
Connection connection = db.getConnection();
-
+
schema = new Schema().schema(connection, tableName);
}
catch(Exception e)
{
-
+
Log.error(e);
throw new Error("Error in BasePeer.initTableSchema(" +
tableName + "): " +
e.getMessage());
@@ -229,7 +257,7 @@
}
}
return schema;
- }
+ }
/**
* Creates a Column array for a table based on its Schema.
############# End patch #############################
John
--
********************************
** John Thorhauer
** [EMAIL PROTECTED]
********************************
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]