This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes using ant sql task with mssql server 2000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "using ant sql task with mssql server 2000" Watch "using ant sql task with mssql server 2000" New topic

using ant sql task with mssql server 2000

Vikramjit Singh

Joined: Sep 01, 2005
Posts: 15
Am trying to build database using sql script with ant sql task :

<property name="lib.dir" location="lib"/>

<property file=""/>

<path id="lib.path">
<fileset dir="${lib.dir}">
<include name="*.jar" />

<!-- - - - - - - - - - - - - - - - - -
target: setup database
- - - - - - - - - - - - - - - - - -->
<target name="setup_db" >
<sql driver="${db.driver}"

and providing all values using .properties file, this is working fine with mysql but if I use it with MSSQL Server 2000, it give me this error :

[sql] Failed to execute:
java.sql.SQLException: [
SYNNET-SRV]Line 1: Incorrect syntax near 'E'.

any idea will be helpfull
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Wouldn't that be a problem with your is.sql ? You might be using an SQL format not compatible with MSSQL Server 2000.

[My Blog]
All roads lead to JavaRanch
Vikramjit Singh

Joined: Sep 01, 2005
Posts: 15
the content for is.sql is :

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AKATYPE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AKATYPE]

[AKATYPEN] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[AKATYPE] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

but it still not work with this script
Denys Kovalenko

Joined: Oct 26, 2012
Posts: 1

I had the same issue, the problem was that SQL file doesn't have an appropriate encoding. I fixed it saving SQL dump file in ANSII encoding. Otherwise, you can indicate encoding of your dump file in SQL ant task:
<sql driver="${driver.class}" url="${db.url}" userid="${user}" password="${password}" src="${script}"delimiter="GO" encoding="utf-16">
<pathelement path="${driver.jar}" />
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Denys, welcome to Java Ranch!

And thank you for pointing out that incorrect encoding can cause various issues! I have been bitten by improper encoding in more ways than I care to count.

JBoss In Action
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: using ant sql task with mssql server 2000
It's not a secret anymore!