wood burning stoves 2.0*
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="build.properties"/>

<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: 14687

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: 5812

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
Don't get me started about those stupid light bulbs.
subject: using ant sql task with mssql server 2000
Similar Threads
Warning Message When I Ran My ANT build.xml File
Building Seam projects in Eclipse
Ant, windows xp, and a funky infinite loop
persistent class not found
Classpath problems(?)