> -----Oryginalna wiadomość-----
> Od: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]W imieniu Jeff Brekke
> Wysłano: Friday, May 26, 2000 2:05 PM
> Do: Turbine
> Temat: Re: [Turbine + Sybase ASE 11.9.2 for Linux]

> I don't belive you are correct.  In the release notes for
> jconnect there are
> specific methods that are not implemented since they require
> a change to the
> TDS stream (hence the above exception).  Sybase says all
> products will have to
> change and don't excpect it until version 12.5 of the server
> product.  Since
> it is really a problem with the TDS stream, third-party JDBC
> driver vendors,
> it seems, cannot implement these methods.  While 5.2 has
> implemented a few
> more than the 4.x version of the driver, there are still
> important ones
> missing.

I snipped metadata access method calls from village/Column.java
and checked what is working and what is not. The good news
is that only getTableName is not implemented. All the other stuff
that village uses is working just fine. This means that creating a
schema for specific table WILL work, because you know the
name of the table you are processing, don't you? This also means
that QueryData for a statements with a  JOIN clause, there is no
simple way of determining what table is specific column coming from.
But of course you can always parse the query...

> If you really wanted to hack a
> way to use sybase with Turbine's default behavior, just hack
> Village to support it.

Sure, why not!? :) You can find my patch enclosed at the end
of the message.

It's transparent to the drivers that support
ResultSetMetaData.getTableName(int column); On Sybase, it will work
correctly in "Schema(table)" and "QueryDataSet(statement)" will have
bogus "statement" table name in all columns in it's schema.
This calls for another patch for turbine.om.peer.BasePeer.initTableSchema,
to use
"Schema(table)" constructor insead of duplicating it's functionality with
QueryDataSet.
The patch is also at the end of the message.

I have little knowledge about OM's inner workings, and usage of schemes
througout
I, so it's hard for me to determine if schemes from
"QueryDataSet(statement)" are
important. At least, this simple patch lets Turbine run on Sybase. By the
way -
I discovered an error in the sql scripts I posted earlier - You cannot
update timestamp
columns under Sybase, therefore Visitor.LASTLOGIN must be changed to
datetime
type. A patch for that is on the very end of message.


Rafal


---- patch for village 1.2 (today
CVS) -------------------------------------------------

diff -r -u com.orig/workingdogs/village/Column.java
com/workingdogs/village/Column.java
--- com.orig/workingdogs/village/Column.java    Tue Nov 30 00:15:18 1999
+++ com/workingdogs/village/Column.java Fri May 26 14:30:51 2000
@@ -110,11 +110,19 @@
     }

     /** internal package method for populating a Column instance */
-    void populate (ResultSetMetaData rsmd, int colNum) throws SQLException
+    void populate (ResultSetMetaData rsmd, int colNum, String tableName)
throws SQLException
     {
         this.columnNumber = colNum;
         this.name = rsmd.getColumnName (columnNumber);
-        this.tableName = rsmd.getTableName(columnNumber);
+       //workaround for Sybase jConnect 5.2 and older
+       try
+       {
+           this.tableName = rsmd.getTableName(columnNumber);
+       }
+       catch (Exception e)
+       {
+           this.tableName = tableName;
+       }
         this.columnTypeName = rsmd.getColumnTypeName (columnNumber);
         this.columnType = rsmd.getColumnType (columnNumber);
         this.nullAllowed = rsmd.isNullable(columnNumber) == 1;
diff -r -u com.orig/workingdogs/village/QueryDataSet.java
com/workingdogs/village/QueryDataSet.java
--- com.orig/workingdogs/village/QueryDataSet.java      Tue Nov 30 00:15:18 1999
+++ com/workingdogs/village/QueryDataSet.java   Fri May 26 14:11:19 2000
@@ -111,7 +111,7 @@
         stmt = conn.createStatement();
         resultSet = stmt.executeQuery(selectStmt);
         schema = new Schema();
-        schema.populate (resultSet.getMetaData());
+        schema.populate (resultSet.getMetaData(),"statement");
     }

     /**
diff -r -u com.orig/workingdogs/village/Schema.java
com/workingdogs/village/Schema.java
--- com.orig/workingdogs/village/Schema.java    Tue Nov 30 00:15:18 1999
+++ com/workingdogs/village/Schema.java Fri May 26 14:07:50 2000
@@ -133,7 +133,7 @@
                 Schema schema1 = new Schema();
                 schema1.setTableName (tableName);
                 schema1.setAttributes (columnsAttribute);
-                schema1.populate (rs.getMetaData());
+                schema1.populate (rs.getMetaData(), tableName);
                 return schema1;
             }
             else
@@ -351,7 +351,7 @@
       * @exception   SQLException
       * @exception   DataSetException
       */
-    void populate (ResultSetMetaData meta) throws SQLException,
+    void populate (ResultSetMetaData meta, String tableName) throws
SQLException,
     DataSetException
     {
         this.numberOfColumns = meta.getColumnCount();
@@ -359,7 +359,7 @@
         for (int i = 1; i <= numberOfColumns(); i++)
         {
             Column col = new Column();
-            col.populate (meta, i);
+            col.populate (meta, i, tableName);
             columns[i] = col;
             if ( i>1  &&
col.getTableName().equalsIgnoreCase( columns[i-1].getTableName() ))
                 singleTable = false;

---- patch for Turbine (today
CVS) -------------------------------------------------------

diff -r -u src.orig/java/org/apache/turbine/om/peer/BasePeer.java
src/java/org/apache/turbine/om/peer/BasePeer.java
--- src.orig/java/org/apache/turbine/om/peer/BasePeer.java      Tue May 23
14:08:22 2000
+++ src/java/org/apache/turbine/om/peer/BasePeer.java   Fri May 26 16:50:15
2000
@@ -200,7 +200,6 @@
     public static Schema initTableSchema(String tableName)
     {
         // Log.note("Executing initTableSchema for table: " + tableName);
-        QueryDataSet qds = null;
         Schema schema = null;
         DBConnection db = null;

@@ -210,13 +209,7 @@
             db = DBBroker.getInstance().getConnection();
             Connection connection = db.getConnection();

-             //  assumes column 1 contains integer id's
-            String stmt = "SELECT * FROM " + tableName +
-                          " WHERE 1 = -10";
-
-            // execute the query
-            qds = new QueryDataSet( connection, stmt );
-            schema = qds.schema();
+            schema = new Schema().schema(connection, tableName);
         }
         catch(Exception e)
         {
@@ -227,13 +220,6 @@
         }
         finally
         {
-            try
-            {
-                if (qds!=null) qds.close();
-            }
-            catch(Exception e)
-            {
-            }
             try
             {
                 DBBroker.getInstance().releaseConnection(db);

---- patch for sybase_users_roles_permissions.sql (posted earlier by
me) ---------------------

--- Sybase_users_roles_permissions.sql.orig     Fri May 26 17:25:30 2000
+++ Sybase_users_roles_permissions.sql  Fri May 26 17:34:48 2000
@@ -79,7 +79,7 @@
     EMAIL           varchar(99)            null    ,
     MODIFIED        timestamp              not null,
     CREATED         char(10)               null    ,
-    LASTLOGIN       timestamp              not null,
+    LASTLOGIN       datetime               not null,
     OBJECTDATA      char(10)               null    ,
     PREFIX_NAME     varchar(16)            null    ,
     MIDDLE_NAME     varchar(99)            null    ,



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to