Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using ant sql task with mssql server 2000

 
Vikramjit Singh
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't that be a problem with your is.sql ? You might be using an SQL format not compatible with MSSQL Server 2000.
 
Vikramjit Singh
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
Hibernate IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic