开发者

ant sql task problem

I have this ant script which should create the table customer. I see the message "Updating database..." so I know it's being called, however when it hits the sql task, nothing is outputed and so I have difficulty understanding what went wrong. The "Upgrade开发者_Python百科 complete." message is never shown so I figure there was a fatal error somewhere.

I placed sqljdbc4.jar drivers with the other libraries in %ANT_HOME%/lib which are read without problems. If I knew where it was going wrong, I could at least search for a solution, but as it stands now I'm at the mercy of anyone who has had a similar problem. Surely it's an obvious problem that I just can't spot. Any input would be greatly appreciated.

The code for the task is below:

<!-- ================================= 
          target: execute-script        
         ================================= -->      
<target name="execute-script">
        <echo message="Updating database..." />
        <sql print="true" failOnConnectionError="true"
              driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
              url="jdbc:sqlserver://localhost:1433;DatabaseName=database;selectmethod=cursor"
              userid="ctsql"
              password="ctsqlone">
           <transaction>
              CREATE TABLE customer
                 (First_Name char(50),
                 Last_Name char(50),
                 Address char(50),
                 City char(50),
                 Country char(25),
                 Birth_Date datetime);              
           </transaction>
        </sql>
        <echo message="Upgrade complete." />
</target>


You don't normally issue DDL statements (create table and the like) within a transaction. Can you try removing the enclosing transaction?

Sybase, for example, does not allow such statements raising the error:

The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'xxxxx' database.

I don't have a SQL Server instance to play with but would expect similar behaviour.


I have answered my own question. I called the target from my own custom task and the exception was caught and the build continued normally without any error message being shown. I have other problems at the moment, but I think I can get it to work now that I see what error I'm getting.

Again my apologies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜