Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Problems accessing SQL Anywhere with jdbc

4 posts in iAnywhere General Discussion (German) Last posting was on 2010-02-22 09:21:01.0Z
Klemens Waldhör Posted on 2010-02-18 14:14:25.0Z
Sender: 2bbd.4b7d4757.1804289383@sybase.com
From: Klemens Waldhör
Newsgroups: ianywhere.public.german.general
Subject: Problems accessing SQL Anywhere with jdbc
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4b7d4b41.2c71.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 18 Feb 2010 06:14:25 -0800
X-Trace: forums-1-dub 1266502465 10.22.241.41 (18 Feb 2010 06:14:25 -0800)
X-Original-Trace: 18 Feb 2010 06:14:25 -0800, 10.22.241.41
Lines: 65
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.german.general:556
Article PK: 1184

I would like to access SQL Anywhere with my TM software.

It is done using the jconnect driver.

Access is done using first to access the server with
(com.sybase.jdbc4.jdbc.SybDriver) using
"jdbc:sybase:Tds:localhost:2638".

Next I create a database 'c://araya/database/arayaserver.db'
(CREATE DATABASE 'c://araya/database/arayaserver.db' ) and
then (try) connect using
"jdbc:sybase:Tds:localhost:2638?SERVICENAME='c://araya/database/arayaserver.db'"

Although this works if I start now creating tables thru jdbc
the tables are created in the database directly associated
with "jdbc:sybase:Tds:localhost:2638" and not with
'c://araya/database/arayaserver.db'. I do not understand
why. Tables are created like that:
CREATE TABLE MONO (id INT PRIMARY KEY DEFAULT AUTOINCREMENT,
idref VARCHAR(40), idno VARCHAR(40), segment VARCHAR(255),
language VARCHAR(5), locktime DATETIME DEFAULT CURRENT DATE,
lockstate INT DEFAULT 1, lockuser VARCHAR(30) DEFAULT
'lockuser', readaccess INT DEFAULT 1, writeaccess INT
DEFAULT 1, tmuser VARCHAR(30), groups VARCHAR(30) DEFAULT
'lockuser', segmentfull TEXT, domain VARCHAR(30), document
VARCHAR(255), creationdate VARCHAR(30), modificationdate
VARCHAR(30), creationauthor VARCHAR(30), modificationauthor
VARCHAR(30), replclasses INT DEFAULT 1, documentid
VARCHAR(30), attributes VARCHAR(255), changedate VARCHAR
(100), TIMER INT)
...
All done using jdbc.

What I basically want to do is:

a) create a connection to an Anywhere SQL Server (actually
no need that a database is asscoiated with it at this
momment)
b) create a (new) database
c) connect to this (new) database again
d) create the tables
e) do some prcessing

As I have written before what actually happens is that in
this way the taboles are created with sever associated
database and not with the new one.

I am applying the same methodology to many other database
types like MS SQL Server, MySQL, HSQL (just to name some)
and there this procedure works fine.

Maybe the main problem is also that I am running the server
(or personal database) in wrong way. I tried several ways
but neither worked in the way I needed.

I tried starting like this:
dbsrv11 -n ArayaServer
dbsrv11 -n ArayaServer c://araya/database/arayaserver.db

but neither worked as I liked.

Any idea what I am doing wrong? Maybe the URL specification?

Regards
Klemens


Volker Barth <No_VBarth Posted on 2010-02-18 14:47:55.0Z
From: Volker Barth <No_VBarth@Spam_GLOBAL-FINANZ.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0
MIME-Version: 1.0
Newsgroups: ianywhere.public.german.general
Subject: Re: Problems accessing SQL Anywhere with jdbc
References: <4b7d4b41.2c71.1681692777@sybase.com>
In-Reply-To: <4b7d4b41.2c71.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b7d531b$1@forums-1-dub>
Date: 18 Feb 2010 06:47:55 -0800
X-Trace: forums-1-dub 1266504475 10.22.241.152 (18 Feb 2010 06:47:55 -0800)
X-Original-Trace: 18 Feb 2010 06:47:55 -0800, vip152.sybase.com
Lines: 81
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.german.general:557
Article PK: 1185

SQL Anywhere names databases by their filename by default (without
extension), so your newly created db should be named "arayaserver". (You
can check this in the server's console or -o log file).

So you might try to "jdbc:sybase:Tds:localhost:2638?SERVICENAME=arayaserver"

Besides that, I would recommend you try the iAnywhere JDBC driver. That
driver (based on ODBC) is easier to configure to connect to different
databases on the same database server.
Have a look at the docs (here for SA 11.0.1)
http://dcx.sybase.com/1101en/dbprogramming_en11/choosing-jdbc-jdbc.html

HTH
Volker

Klemens Waldhör wrote:
> I would like to access SQL Anywhere with my TM software.
>
> It is done using the jconnect driver.
>
> Access is done using first to access the server with
> (com.sybase.jdbc4.jdbc.SybDriver) using
> "jdbc:sybase:Tds:localhost:2638".
>
> Next I create a database 'c://araya/database/arayaserver.db'
> (CREATE DATABASE 'c://araya/database/arayaserver.db' ) and
> then (try) connect using
> "jdbc:sybase:Tds:localhost:2638?SERVICENAME='c://araya/database/arayaserver.db'"
>
> Although this works if I start now creating tables thru jdbc
> the tables are created in the database directly associated
> with "jdbc:sybase:Tds:localhost:2638" and not with
> 'c://araya/database/arayaserver.db'. I do not understand
> why. Tables are created like that:
> CREATE TABLE MONO (id INT PRIMARY KEY DEFAULT AUTOINCREMENT,
> idref VARCHAR(40), idno VARCHAR(40), segment VARCHAR(255),
> language VARCHAR(5), locktime DATETIME DEFAULT CURRENT DATE,
> lockstate INT DEFAULT 1, lockuser VARCHAR(30) DEFAULT
> 'lockuser', readaccess INT DEFAULT 1, writeaccess INT
> DEFAULT 1, tmuser VARCHAR(30), groups VARCHAR(30) DEFAULT
> 'lockuser', segmentfull TEXT, domain VARCHAR(30), document
> VARCHAR(255), creationdate VARCHAR(30), modificationdate
> VARCHAR(30), creationauthor VARCHAR(30), modificationauthor
> VARCHAR(30), replclasses INT DEFAULT 1, documentid
> VARCHAR(30), attributes VARCHAR(255), changedate VARCHAR
> (100), TIMER INT)
> ...
> All done using jdbc.
>
> What I basically want to do is:
>
> a) create a connection to an Anywhere SQL Server (actually
> no need that a database is asscoiated with it at this
> momment)
> b) create a (new) database
> c) connect to this (new) database again
> d) create the tables
> e) do some prcessing
>
> As I have written before what actually happens is that in
> this way the taboles are created with sever associated
> database and not with the new one.
>
> I am applying the same methodology to many other database
> types like MS SQL Server, MySQL, HSQL (just to name some)
> and there this procedure works fine.
>
> Maybe the main problem is also that I am running the server
> (or personal database) in wrong way. I tried several ways
> but neither worked in the way I needed.
>
> I tried starting like this:
> dbsrv11 -n ArayaServer
> dbsrv11 -n ArayaServer c://araya/database/arayaserver.db
>
> but neither worked as I liked.
>
> Any idea what I am doing wrong? Maybe the URL specification?
>
> Regards
> Klemens


Klemens Waldhör Posted on 2010-02-20 13:55:34.0Z
Sender: 2bbd.4b7d4757.1804289383@sybase.com
From: Klemens Waldhör
Newsgroups: ianywhere.public.german.general
Subject: Re: Problems accessing SQL Anywhere with jdbc
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4b7fe9d6.1224.1681692777@sybase.com>
References: <4b7d531b$1@forums-1-dub>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 20 Feb 2010 05:55:34 -0800
X-Trace: forums-1-dub 1266674134 10.22.241.41 (20 Feb 2010 05:55:34 -0800)
X-Original-Trace: 20 Feb 2010 05:55:34 -0800, 10.22.241.41
Lines: 102
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.german.general:558
Article PK: 1187

Thanks! I'll try this.

The basic problem I have found is that only one anywhere db
can be run on one port (at least it looks like that). This
seems to be in contrast to a SQL server where you have one
port with multiple databases whcih you can access.

Another question: Is there a simple way to determine which
anywhere servers are running? And how can the port be
determined if one kknows the server name?

Thanks!

Klemens

> SQL Anywhere names databases by their filename by default
> (without extension), so your newly created db should be
> named "arayaserver". (You can check this in the server's
> console or -o log file).
>
> So you might try to
> "jdbc:sybase:Tds:localhost:2638?SERVICENAME=arayaserver"
>
> Besides that, I would recommend you try the iAnywhere JDBC
> driver. That driver (based on ODBC) is easier to
> configure to connect to different databases on the same
> database server. Have a look at the docs (here for SA
> 11.0.1)
>
http://dcx.sybase.com/1101en/dbprogramming_en11/choosing-jdbc-jdbc.html
>
> HTH
> Volker
>
> Klemens Waldhör wrote:
> > I would like to access SQL Anywhere with my TM software.
> >
> > It is done using the jconnect driver.
> >
> > Access is done using first to access the server with
> > (com.sybase.jdbc4.jdbc.SybDriver) using
> > "jdbc:sybase:Tds:localhost:2638".
> >
> > Next I create a database
> > 'c://araya/database/arayaserver.db' (CREATE DATABASE
> > 'c://araya/database/arayaserver.db' ) and then (try)
> > connect using
>
"jdbc:sybase:Tds:localhost:2638?SERVICENAME='c://araya/dat
> abase/arayaserver.db'" >
> > Although this works if I start now creating tables thru
> > jdbc the tables are created in the database directly
> > associated with "jdbc:sybase:Tds:localhost:2638" and not
> > with 'c://araya/database/arayaserver.db'. I do not
> > understand why. Tables are created like that:
> > CREATE TABLE MONO (id INT PRIMARY KEY DEFAULT
> > AUTOINCREMENT, idref VARCHAR(40), idno VARCHAR(40),
> > segment VARCHAR(255), language VARCHAR(5), locktime
> > DATETIME DEFAULT CURRENT DATE, lockstate INT DEFAULT 1,
> > lockuser VARCHAR(30) DEFAULT 'lockuser', readaccess INT
> > DEFAULT 1, writeaccess INT DEFAULT 1, tmuser VARCHAR(30)
> > , groups VARCHAR(30) DEFAULT 'lockuser', segmentfull
> > TEXT, domain VARCHAR(30), document VARCHAR(255),
> > creationdate VARCHAR(30), modificationdate VARCHAR(30),
> > creationauthor VARCHAR(30), modificationauthor
> > VARCHAR(30), replclasses INT DEFAULT 1, documentid
> > VARCHAR(30), attributes VARCHAR(255), changedate VARCHAR
> > (100), TIMER INT) ...
> > All done using jdbc.
> >
> > What I basically want to do is:
> >
> > a) create a connection to an Anywhere SQL Server
> > (actually no need that a database is asscoiated with it
> > at this momment)
> > b) create a (new) database
> > c) connect to this (new) database again
> > d) create the tables
> > e) do some prcessing
> >
> > As I have written before what actually happens is that
> > in this way the taboles are created with sever
> > associated database and not with the new one.
> >
> > I am applying the same methodology to many other
> > database types like MS SQL Server, MySQL, HSQL (just to
> > name some) and there this procedure works fine.
> >
> > Maybe the main problem is also that I am running the
> > server (or personal database) in wrong way. I tried
> > several ways but neither worked in the way I needed.
> >
> > I tried starting like this:
> > dbsrv11 -n ArayaServer
> > dbsrv11 -n ArayaServer c://araya/database/arayaserver.db
> >
> > but neither worked as I liked.
> >
> > Any idea what I am doing wrong? Maybe the URL
> specification? >
> > Regards
> > Klemens


Volker Barth <No_VBarth Posted on 2010-02-22 09:21:01.0Z
From: Volker Barth <No_VBarth@Spam_GLOBAL-FINANZ.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1
MIME-Version: 1.0
Newsgroups: ianywhere.public.german.general
Subject: Re: Problems accessing SQL Anywhere with jdbc
References: <4b7d531b$1@forums-1-dub> <4b7fe9d6.1224.1681692777@sybase.com>
In-Reply-To: <4b7fe9d6.1224.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b824c7d$1@forums-1-dub>
Date: 22 Feb 2010 01:21:01 -0800
X-Trace: forums-1-dub 1266830461 10.22.241.152 (22 Feb 2010 01:21:01 -0800)
X-Original-Trace: 22 Feb 2010 01:21:01 -0800, vip152.sybase.com
Lines: 141
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.german.general:559
Article PK: 1186


Klemens Waldhör wrote:

> The basic problem I have found is that only one anywhere db
> can be run on one port (at least it looks like that). This
> seems to be in contrast to a SQL server where you have one
> port with multiple databases whcih you can access.

That's not true. One SA server can host multiple databases. However, in
contrast to SQL Server (or Sybase Adaptive Server Enterprise), those
databases are totally separated by default. There is NO master database
or something like that.

You can run several databases on one server by:
a) specifying multiple dbs on the server start command line, e.g.
dbsrv11 -n MyServer C:\db1\db1.db -n db1 C:\db2\db2.db -n db2 ...
b) or you can start databases on an already running server by using the
START DATABASE statement, eg.
START DATABASE 'C:\db2\db2.db' as db2 on MyServer

As you can only connect to a database, not to a server (this is differen
to MS SQL, I think), the client has to specify a database name to which
to connect. In the case above, the SA server will listen on the same
port (default 2638) for requests to both databases.

Only when you run TWO different SA servers on the same box, then you
have to use different ports, as each server has to listen on its own
port. (This should be the same when you run to different MS SQL server
instances on the same box.)


> Another question: Is there a simple way to determine which
> anywhere servers are running? And how can the port be
> determined if one kknows the server name?

Have a look at the DBLOCATE command line tool to find all SA servers and
their ports.
When connected to a database, you can use
select property('TcpIpAddresses')
to get the port(s) the server listens to.

HTH
Volker

P.S. By the way, the newsgroup "sybase.public.sqlanywhere.general" is
focussed on such questions, and it gets much more attention,
particularly by very helpful Sybase and iAnywhere employees:)



>
> Thanks!
>
> Klemens
>
>> SQL Anywhere names databases by their filename by default
>> (without extension), so your newly created db should be
>> named "arayaserver". (You can check this in the server's
>> console or -o log file).
>>
>> So you might try to
>> "jdbc:sybase:Tds:localhost:2638?SERVICENAME=arayaserver"
>>
>> Besides that, I would recommend you try the iAnywhere JDBC
>> driver. That driver (based on ODBC) is easier to
>> configure to connect to different databases on the same
>> database server. Have a look at the docs (here for SA
>> 11.0.1)
>>
> http://dcx.sybase.com/1101en/dbprogramming_en11/choosing-jdbc-jdbc.html
>>
>> HTH
>> Volker
>>
>> Klemens Waldhör wrote:
>>> I would like to access SQL Anywhere with my TM software.
>>>
>>> It is done using the jconnect driver.
>>>
>>> Access is done using first to access the server with
>>> (com.sybase.jdbc4.jdbc.SybDriver) using
>>> "jdbc:sybase:Tds:localhost:2638".
>>>
>>> Next I create a database
>>> 'c://araya/database/arayaserver.db' (CREATE DATABASE
>>> 'c://araya/database/arayaserver.db' ) and then (try)
>>> connect using
>>
> "jdbc:sybase:Tds:localhost:2638?SERVICENAME='c://araya/dat
>> abase/arayaserver.db'">
>>> Although this works if I start now creating tables thru
>>> jdbc the tables are created in the database directly
>>> associated with "jdbc:sybase:Tds:localhost:2638" and not
>>> with 'c://araya/database/arayaserver.db'. I do not
>>> understand why. Tables are created like that:
>>> CREATE TABLE MONO (id INT PRIMARY KEY DEFAULT
>>> AUTOINCREMENT, idref VARCHAR(40), idno VARCHAR(40),
>>> segment VARCHAR(255), language VARCHAR(5), locktime
>>> DATETIME DEFAULT CURRENT DATE, lockstate INT DEFAULT 1,
>>> lockuser VARCHAR(30) DEFAULT 'lockuser', readaccess INT
>>> DEFAULT 1, writeaccess INT DEFAULT 1, tmuser VARCHAR(30)
>>> , groups VARCHAR(30) DEFAULT 'lockuser', segmentfull
>>> TEXT, domain VARCHAR(30), document VARCHAR(255),
>>> creationdate VARCHAR(30), modificationdate VARCHAR(30),
>>> creationauthor VARCHAR(30), modificationauthor
>>> VARCHAR(30), replclasses INT DEFAULT 1, documentid
>>> VARCHAR(30), attributes VARCHAR(255), changedate VARCHAR
>>> (100), TIMER INT) ...
>>> All done using jdbc.
>>>
>>> What I basically want to do is:
>>>
>>> a) create a connection to an Anywhere SQL Server
>>> (actually no need that a database is asscoiated with it
>>> at this momment)
>>> b) create a (new) database
>>> c) connect to this (new) database again
>>> d) create the tables
>>> e) do some prcessing
>>>
>>> As I have written before what actually happens is that
>>> in this way the taboles are created with sever
>>> associated database and not with the new one.
>>>
>>> I am applying the same methodology to many other
>>> database types like MS SQL Server, MySQL, HSQL (just to
>>> name some) and there this procedure works fine.
>>>
>>> Maybe the main problem is also that I am running the
>>> server (or personal database) in wrong way. I tried
>>> several ways but neither worked in the way I needed.
>>>
>>> I tried starting like this:
>>> dbsrv11 -n ArayaServer
>>> dbsrv11 -n ArayaServer c://araya/database/arayaserver.db
>>>
>>> but neither worked as I liked.
>>>
>>> Any idea what I am doing wrong? Maybe the URL
>> specification?>
>>> Regards
>>> Klemens