We recently got TDK running with SQL server and IDBroker.  The issue we
found was with
the IDBroker class.  For some reason when using SQL Server with the
IDBroker, the transaction
to commit the update to the ID_TABLE would fail when updating the NEXT_ID
field.
We patched the source code in IDBroker so it would not use transactions.  We
are

We added the following code to the storeIDs method
    transactionsSupported = false;

We are still testing this fix but it seems to work okay.
r,
Hugh

  private void storeIDs(String tableName,
                          boolean adjustQuantity)
        throws Exception
    {
        BigDecimal nextId = null;
        BigDecimal quantity = null;
        DatabaseMap dbMap = tableMap.getDatabaseMap();
        TableMap tMap = dbMap.getTable(tableName);

        // Block on the table.  Multiple tables are allowed to ask for
        // ids simultaneously.
//        synchronized(tMap)  see comment in the getNextIds method
//        {
            if (adjustQuantity)
                checkTiming(tableName);

            DBConnection dbCon = null;
            try
            {
                String databaseName = dbMap.getName();

                // Get a connection to the db by starting a
                // transaction.
                transactionsSupported = false;

                if (transactionsSupported)
                {
                    dbCon = BasePeer.beginTransaction(databaseName);
                }
                else
                {
                    dbCon = TurbineDB.getConnection(databaseName);
                }
                Connection connection = dbCon.getConnection();

                // Write the current value of quantity of keys to grab
                // to the database, primarily to obtain a write lock
                // on the table/row, but this value will also be used
                // as the starting value when an IDBroker is
                // instantiated.
                quantity = getQuantity(tableName);
                Criteria criteria = new Criteria(2)
                    .add( QUANTITY, quantity );
                Criteria selectCriteria = new Criteria(2)
                    .add( TABLE_NAME, tableName );
                criteria.setDbName(dbMap.getName());
                selectCriteria.setDbName(dbMap.getName());
                BasePeer.doUpdate( selectCriteria, criteria, dbCon );

                // Read the next starting ID from the ID_TABLE.
                BigDecimal[] results = selectRow(connection, tableName);
                nextId = results[0]; // NEXT_ID column

                // Update the row based on the quantity in the
                // ID_TABLE.
                BigDecimal newNextId = nextId.add(quantity);
                updateRow(connection, tableName, newNextId.toString() );

                if (transactionsSupported)
                {
                    BasePeer.commitTransaction(dbCon);
                }
            }
            catch (Exception e)
            {
                if (transactionsSupported)
                {
                    BasePeer.rollBackTransaction(dbCon);
                }
                throw e;
            }
            finally
            {
                if (!transactionsSupported)
                {
                    // Return the connection to the pool.
                    TurbineDB.releaseConnection(dbCon);
                }
            }

            List availableIds = (List)ids.get(tableName);
            if ( availableIds == null )
            {
                availableIds = new ArrayList();
                ids.put( tableName, availableIds );
            }

            // Create the ids and store them in the list of available ids.
            int numId = quantity.intValue();
            for (int i=0; i<numId; i++)
            {
                availableIds.add(nextId);
                nextId = nextId.add(ONE);
            }
//        }
    }


----- Original Message -----
From: "Pugh, Eric" <[EMAIL PROTECTED]>
To: "'Turbine Users List'" <[EMAIL PROTECTED]>
Sent: Tuesday, November 27, 2001 7:55 AM
Subject: RE: Followup: RE: Running Ant Init task for Microsoft SQL server


> Hi all,
>
> As the original poster of this message, I did eventually get the answer..
I
> think the issue (it was a while ago) was that there was an extra carriage
> return on unique.vm.  I also had to play around with the table ID,
> eventually ending up with NONE to force it to use MSSQL identity columns.
>
> The other reason I had problems was I heavily hacked a download of
> turbine-torque to generate my .xml file.  I then used that version of
torque
> to generate my OM.  When I copied the .java files over to my tdk2.1
> installation, they all failed because the OM files all reference torque,
but
> the TDK expected them to reference itself.  This was because of the
> decoupling process going on for Torque.
>
> I think there are other emails posted on getting SQL server to work with
the
> default TDK 2.1.
>
> Eric
>
> -----Original Message-----
> From: James Coltman [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 27, 2001 6:14 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Followup: RE: Running Ant Init task for Microsoft SQL
> server
>
>
> Did anyone ever manage to find out what the problem described in this mail
> was?
>
> James
>
> -----Original Message-----
> From: Pugh, Eric [mailto:[EMAIL PROTECTED]]
> Sent: 12 September 2001 14:46
> To: '[EMAIL PROTECTED]'
> Subject: Followup: RE: Running Ant Init task for Microsoft SQL server
>
>
> I downloaded and tried to run torque by itself, and continued to get the
> same problem...  I have velocity installed, and have successfully used it
> before.  Could it be possible that the current release version of velocity
> (1.1) that I downloaded and have been using is incompatable with Torque,
and
> that the version being used in not the velocity that comes with torque?
>
> I don't have Velocity in my PATH statement or classpath.
>
> Or is it that the table.vm file for MS SQL server is incorrent?
>
> I am running on Windows 2K with MS SQL.
>
> Eric
>
> Here is my velocity log:
> Wed Sep 12 09:29:22 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/columns.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Wed Sep 12 09:29:22 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/primarykey.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Wed Sep 12 09:29:22 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/unique.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Wed Sep 12 09:29:22 EDT 2001  [error] Method chop threw exception for
> reference $strings in template sql/base/mssql/table.vm at  [14,24]
> Wed Sep 12 09:29:22 EDT 2001  [error] Method parse threw exception for
> reference $generator in template sql/base/Control.vm at  [17,17]
>
> -----Original Message-----
> From: Pugh, Eric [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 11, 2001 4:59 PM
> To: '[EMAIL PROTECTED]'
> Subject: Running Ant Init task for Microsoft SQL server
>
>
> Hi,
>
> I have implemented and played around with Velocity, and am now trying to
> integrate Turbine in with it.  However, as I try and compile the sample
> application "newapp", I am running into problems with the ant init task.
>
> I get this error below:
>
> C:\java\tdk-2.1\tdk\webapps\newapp\WEB-INF\build>ant init
> Buildfile: build.xml
>
> init:
>
> init-tasks:
>
> set-os:
>
> set-windows2000:
>
> set-windowsNT:
>
> set-windows98:
>
> set-unix:
>
> unix-ext:
>
> windows-ext:
>
> ext:
>      [echo] Platform = windows
>      [echo] Extension = bat
>
> create-database:
>
> init-tasks:
>
> turbine-sql:
>      [echo] +------------------------------------------+
>      [echo] |                                          |
>      [echo] | Generating SQL for Turbine base system!  |
>      [echo] |                                          |
>      [echo] +------------------------------------------+
> C:\java\tdk-2.1\tdk\webapps\newapp\WEB-INF\src\sql\turbine-schema.sql
>
> BUILD FAILED
>
> C:\java\tdk-2.1\tdk\webapps\newapp\WEB-INF\build\build.xml:207: Exception
> thrown by 'generator.parse'. For more informat
> ion consult the velocity log.
> --- Nested Exception ---
> org.apache.velocity.exception.MethodInvocationException: Invocation of
> method 'chop' in  class org.apache.velocity.util.
> StringUtils threw exception class java.lang.ArrayIndexOutOfBoundsException
>         at
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.ja
> va)
>         at
>
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.jav
> a)
>         at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
> .java)
>         at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
>         at org.apache.velocity.Template.merge(Template.java)
>         at org.apache.velocity.texen.Generator.parse(Generator.java)
>         at java.lang.reflect.Method.invoke(Native Method)
>         at
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.ja
> va)
>         at
>
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.jav
> a)
>         at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
> .java)
>         at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
>         at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav
> a)
>         at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
>         at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement
> .java)
>         at
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
>         at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java)
>         at
>
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav
> a)
>         at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
>         at org.apache.velocity.Template.merge(Template.java)
>         at org.apache.velocity.texen.Generator.parse(Generator.java)
>         at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java)
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:124)
>         at org.apache.tools.ant.Target.execute(Target.java:153)
>         at org.apache.tools.ant.Project.runTarget(Project.java:898)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:536)
>         at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:213)
>         at
> org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:103)
>         at org.apache.tools.ant.Target.execute(Target.java:153)
>         at org.apache.tools.ant.Project.runTarget(Project.java:898)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:536)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:510)
>         at org.apache.tools.ant.Main.runBuild(Main.java:421)
>         at org.apache.tools.ant.Main.main(Main.java:149)
>
> The last couple lines of the velocity log are:
>
> Tue Sep 11 16:51:12 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/table.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Sep 11 16:51:12 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/drop.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Sep 11 16:51:12 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/columns.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Sep 11 16:51:12 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/primarykey.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Sep 11 16:51:12 EDT 2001   [info] ResourceManager : found
> sql/base/mssql/unique.vm with loader
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Sep 11 16:51:12 EDT 2001  [error] Method chop threw exception for
> reference $strings in template sql/base/mssql/table.vm at  [14,24]
> Tue Sep 11 16:51:12 EDT 2001  [error] Method parse threw exception for
> reference $generator in template sql/base/Control.vm at  [28,17]
>
> If I comment out the call to the task turbine-sql  then it will fail later
> on when it does the inserts...  Does someone have a version of the
> turbine-schema.sql that is already compiled that I could use?  Will I have
> this problem when I try and compile my own sql for the newapp project?
>
> Thanks,
>
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to