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
Author

using ant sql task with mssql server 2000

Vikramjit Singh
Greenhorn

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" />
</fileset>
</path>

<!-- - - - - - - - - - - - - - - - - -
target: setup database
- - - - - - - - - - - - - - - - - -->
<target name="setup_db" >
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
src="is.sql"
print="yes"
classpathref="lib.path"
encoding="UTF-8">
</sql>
</target>

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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
Greenhorn

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]
GO

CREATE 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
) ON [PRIMARY]
GO

but it still not work with this script
Denys Kovalenko
Greenhorn

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">
<classpath>
<pathelement path="${driver.jar}" />
</classpath>
</sql>
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

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(?)