• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using ant sql task with mssql server 2000

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
IntelliJ IDE Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic