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 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 tableand the like) within a transaction. Can you try removing the enclosing transaction?Sybase, for example, does not allow such statements raising the error:
I don’t have a SQL Server instance to play with but would expect similar behaviour.