I am running a third party program (let's call it TPP) that uses a SQL Anywhere database for storing data. I have written a Java program that can perform some reporting on the TPP's data by connecting to its proprietary database and running SQL queries. My Java program uses the JDBC/ODBC driver provided by SQL Anywhere to connect to the database. My Java program works great if I start it while running the TPP or the Interactive SQL program that comes with SQL Anywhere 10. If one of these programs is not running and connected to the database then my Java program will bomb out trying to connect. Here is the top of the stack trace:

java.sql.SQLException: [Sybase][ODBC Driver][SQL Anywhere]Database server not found
at ianywhere.ml.jdbcodbc.jdbc3.IDriver.makeODBCConnection(Native Method)
at ianywhere.ml.jdbcodbc.jdbc3.IDriver.connect(IDriver.java:557)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)

The SQL Anywhere version being used is 10.0.1 build 4213.

The JDBC/ODBC driver was obtained from here:

C:\Program Files\SQL Anywhere 10\java\jodbc.jar
Size: 342318 bytes
MD5: 0d358bb2b7178893a1955b0bc594a47f

Here are my JDBC connection parameters:

jdbc.driverClassName=ianywhere.ml.jdbcodbc.jdbc3.IDriver
jdbc.url=jdbc:ianywhere:Driver=SQL Anywhere 10;DSN=TPP

Does anyone have a clue what I could be doing wrong? Thanks.

asked 17 Nov '11, 09:15

techguy's gravatar image

techguy
21114
accept rate: 0%


What are the connection parameters inside the DSN TPP?

It looks like you only give parameters to connect to a running database, which works when other programs have already started the database, whereas it fails when the database is not running.

You might have to specify the START parameter inside your DSN in order to give enough details to start a database engine that loads the required database. If so, you might also set the AUTOSTOP to YES (though that's the default) to close the database automatically.


Note: This does assume that your app and the database are running on the same machine. AFAIK, it's not possible to start a database on a different box automatically during the connection.

permanent link

answered 17 Nov '11, 09:24

Volker%20Barth's gravatar image

Volker Barth
30.3k300452659
accept rate: 32%

edited 17 Nov '11, 09:28

Thanks for the reponse, Volker.

I am running all applications and database on the same machine. I am running on Windows 7 so I configure the DSN parameters in the ODBC Data Source Administrator. Here is a description of the settings I see for the DSN in question:

ODBC tab

Data source name: TPP

Database tab

Server name: tpp
Start line: C:\Program Files\SQL Anywhere 10\x64\dbeng10.exe -zr SQL+REPLACE -zo H:\TppAccess.log

Database name: tpp
Database file: H:\\tpp.db

(Checked) Start database automatically
(Checked) Stop database after last disconnect

I feel like all three programs (TPP, Interactive SQL, and my Java program) are using the same User Data Source; DSN TPP. Why would 2 programs be able to start the database ok and my Java program require that it is already running? Also, the settings for the Tpp DSN are very similar to the ones for the SQL Anywhere 10 Demo which was added by the setup program.

Thanks.

(17 Nov '11, 10:24) techguy
Replies hidden

According to the SQL Anywhere 10\x64 path, you seem to be using the 64-bit database engine. Do TPP, Interactive SQL and your Java app share the same bitness?

Otherwise, you might have to check whether there are different ODBC DSNs for 32-bit and 64-bit - see some forum questions regaring these differences...

Besides that, I have no further suggestions - except adding the LOG connection param to generate a client-side log file:

LOG=H:TppClientLog.txt

(17 Nov '11, 10:59) Volker Barth

Turns out I was using a 32 bit JRE to run my app but that was not the problem. I switched to a 64 bit JRE and I got the same error.

Adding the logging on the client and server side helped out a bit. I was able to compare the connection strings between my Java app and the 2 apps that work. I enhanced my connection string (as you suggested in your first response) to include the START option and all of the others from the User DSN in the ODBC Data Source Administrator.

jdbc.url=jdbc:odbc:Driver=SQL Anywhere 10;DSN=TPP;DBN=tpp;DBF=H:\\tpp.db;ENG=tpp;START='C:\\Program Files\\SQL Anywhere 10\\x64\\dbeng10.exe';ASTOP=YES;INT=NO;DBG=YES;LOG=h:\\TppClient.log

With that connection string my app will successfully start a database server and work ok even if TPP is not running. I guess I was thinking that specifying DSN=TPP was enough to get all of the necessary parameters from Windows since all that is configured in the ODBC Data Source Administrator. I still feel like something is off because my Java app will always start its own database server even if there is one running. Also, my Java app never causes logs to be written to the server side logfile that I have configured in ODBC Data Source Administrator. I always see the following in the client side log even if a database server is already running:

06:17:33 Attempting to connect to a running server...
06:17:33 Trying to start SharedMemory link ...

06:17:33     SharedMemory link started successfully

06:17:33 Attempting SharedMemory connection (no sasrv.ini cached address)

06:17:33 Failed to connect over SharedMemory

06:17:33 No server found, attempting to run START line...
06:17:33 Autostarted server, attempting to connect using:
...

Feels like I am not going through the User DSN I have set up in the ODBC Data Source Administrator. Any insight is appreciated.

At least my app is running now. Thanks, Volker.

(19 Nov '11, 06:38) techguy

I think I just figured out why my Java app was starting a new database server even if one was running. I had a different START line set in my app vs the User Data Source in the ODBC Administrator (One specified logging options and the other did not). Once I made the 2 start parameters identical, my Java app was able to connect over SharedMemory.

(19 Nov '11, 06:57) techguy
Replies hidden

I'm glad you solved the issue!

W.r.t. the DSNs, is there a change you have both system and user DNSs (or 32-bit and 64-bit ones) so that different programs might use different DSNs?


Just in case you feel this question "closed", feel free to accept the answer...

(19 Nov '11, 08:44) Volker Barth

I started out with just a User DSN and I did not modify it when fixing my issue. I am assuming that the DSN I am using is a 64 bit one since it is listed from the ODBC Data Source Administrator that is found in the Administrative tools.

i.e. - %windir%system32odbcad32.exe

(I am running 64 bit Win7)

(20 Nov '11, 09:42) techguy
Replies hidden

You can see the bitness in Task Manager's Processes tab: 32-bit processes show " *32" at the end of the image name. Also, if you use All Programs>SQL Anywhere 12>Administration Tools to find it, the shortcut name includes the bitness.

(21 Nov '11, 12:12) Graham Hurst
showing 4 of 7 show all flat view
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×124
×67
×64

question asked: 17 Nov '11, 09:15

question was seen: 4,908 times

last updated: 21 Nov '11, 12:14