Hi

I am still trying to get a running (working) native JDBC database connection to a SQL Anywhere 17 database. I tried with the following URL and Driver settings on Windows Server (2008 R2) and OS X 10.11.5. On both platforms, a SQL Anywhere version 17.0.4.2129 is running. It's a standard install done by the installer (wizard). Unfortunately I have no success on making a connection on either OS.

In the database server connection fields URL and Driver, I use:

URL: jdbc:sqlanywhere:DSN=<database>;Links=tcpip(host=<ip-address>;port=2638);
Driver: sybase.jdbc4.sqlanywhere.IDriver

This settings are based on my older thread about JDBC database connections. Read thread here if appropriate: http://sqlanywhere-forum.sap.com/questions/16414/jdbc-driver-for-oracle-data-modeler

Using following settings works with jconn3.jar on both platforms:

URL: jdbc:sybase:Tds:<ip-adress>:2638?ServiceName=<database>&CHARSET=utf8
Driver: com.sybase.jdbc3.jdbc.SybDriver

What settings and driver files are other people using? Where are they located?

I still have hope to get the native connection run. The motivation for me is that as far as I understood it is a (much) faster connection.

Regards, Robert

asked 02 Nov '16, 11:17

robert's gravatar image

robert
563263446
accept rate: 0%


Your use of DSN= is incorrect. That should probably be DBN= given you are specifying a database name.

If you have a working ODBC DataSource (DSN) you can use DSN= to pick that up (and all the settings saved in the ODBC.ini registry under that will get picked up as well; ie. with that you may not need anything else)

If Links= is giving you a problem you can switch to HOST= instead now.

permanent link

answered 02 Nov '16, 12:03

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 31%

Thanks a lot. Seems logical. I changed it to DB=<database name="">. Also changed LINKS= to HOST= (seems also more logical to me).

I get the following error when testing the connection: Test failed: Driver class not found. Verify the Driver location.

When trying to establish a connection in the Eclipse IDE and entering the Driver (text into the the field), the Driver text gets read, indicating something is wrong. Could it be that sybase.jdbc4.sqlanywhere.IDriver ist not the correct description?

(03 Nov '16, 08:00) robert
Replies hidden

Looking again at your answer, I am not sure any more what you mean by your last sentence (If Links= is giving ...?

As the text part is: Links=tcpip(host=<ip-address>;port=2638) you mean to write it like this: Host=tcpip(host=<ip-address>;port=2638)?

That does not seem very logical so I mustn't have understood what you meant.

(03 Nov '16, 08:09) robert
Replies hidden

Did you really use DB as a keyword or was that a typo? A Nick stated, DBN would be the correct identifier.

(03 Nov '16, 08:49) Reimer Pods

No, look at Nick's link for the HOST connection parameter, HOST implies TCP/IP and specifies the machine name or IP address and optionally the port, such as

  • ...;HOST=MyMachineName;...
  • ...;HOST=MyIpAddress;...
  • ...;HOST=MyIpAddress:2638;...
(03 Nov '16, 08:51) Volker Barth

@Reimer: Sorry, DB was I typo, I used DBN. And thanks for looking very closely.

(03 Nov '16, 11:03) robert

Make sure the JDBC driver is in your classpath (Windows example here).

set CLASSPATH=.;path-to-sqla\java\sajdbc4.jar

If you are writing the JDBC app, your connection code should look something like this (add/replace whatever connection parameters you like).

Connection  conn;    
try
{
    conn = DriverManager.getConnection("jdbc:sqlanywhere:uid=DBA;pwd=sql" );
}
catch( Exception e )
{
    System.err.println( "Error! Could not connect" );
    System.err.println( e.getMessage() );
    conn = null;
}
permanent link

answered 03 Nov '16, 10:39

JBSchueler's gravatar image

JBSchueler
2.0k2837
accept rate: 16%

A small remark. No need to clear conn, because it is in the catch-exception block. I suggest to use try with resources.

(03 Nov '16, 11:06) Vlad
Replies hidden

The code is a fragment of a method that returns "conn" to the caller.

(03 Nov '16, 11:12) JBSchueler

Sorry if I was unclear, the settings are to be done within the Eclipse IDE (Servoy Developer plug-in), i. e. there are fields like User name, password, URL, Driver etc. to fill with the correct data. I described only Url and Driver, as the other fields are not a problem (I think).

(04 Nov '16, 10:44) robert

If "conn" is null, this will not help the caller :) It is better to propagate the exception, or wrap it with the application-related exception.

Sorry, I know this is not a Java forum, simply couldn't pass by.

(04 Nov '16, 11:41) Vlad

It seems, according to this thread: https://blogs.sap.com/2014/05/02/connecting-to-sql-anywhere-using-jdbc-2/comment-page-1/#comment-352678

that the Driver name is now sap.jdbc4.sqlanywhere.IDriver

Unfortunately, it still does not work on OS X 10.11. But at least the driver can be loaded. The remaining problems may have something to do with the lib files not being accessible.

(07 Nov '16, 12:46) robert
Replies hidden

Any hint how to get SQL Anywhere to work with it's native driver (on OS X)? Is anyone using the native driver on Windows Server (2008 R2)? Your help is very welcome.

(09 Nov '16, 05:41) robert

Re: But at least the driver can be loaded. The remaining problems ...

Can you update us on what messages you now see?

(09 Nov '16, 09:41) JBSchueler

Yes, I like to. The euro message is: "no dbjdbc17 in java.library.path". I included the path to the libraries but there are somehow not accessible by the connection/driver. I now assume this is the still existing SQL Anywhere problem discussed on my earlier thread: http://sqlanywhere-forum.sap.com/questions/16414/jdbc-driver-for-oracle-data-modeler

May be it has also something to do with the naming on OS X of the libraries. The error message is for a Windows OS and should not occur on a UNIX flavor OS, should it? The equivalent to the dbjdbc17.dll and the other needed native libraries is libdbjdbc17.dylib etc.

I thought in SQL Anywhere 17 the problem is solved but it does not seem to be. Except I am missing something.

I would very much like to hear about the solution.

(23 Nov '16, 04:01) robert
showing 4 of 8 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:

×125
×67

question asked: 02 Nov '16, 11:17

question was seen: 314 times

last updated: 23 Nov '16, 04:01