I've converted a PowerBuilder from PB8 to 12.5. I would also like to get rid of the ODBC drivers installed on each client pc using JDBC. But before I change app code.

In PowerBuilder itself, I want to setup a JDBC profile to connect to my SQLanywhere 12 DB. In the connect information I supplied:

DRIVER NAME: sybase.jdbc4.sqlanywhere.IDriver

URL: sqlanywhere:DBN=mydb;Servername=Test_sqlanywhere12;AStart=NO;

LOGINID:dba

PASSWORD:***

When I test the connection I the error popup: POWERBUILDER Non SQL Error: cound not load class sybase.jdbc4.sqlanywhere.IDriver

asked 27 Jan '12, 11:19

KevinG's gravatar image

KevinG
31227
accept rate: 0%

edited 15 Mar '13, 21:26

Mark%20Culp's gravatar image

Mark Culp
22.9k9129269


The CLASSPATH used by PB does not include %sqlany12%\java\sajdbc4.jar. You can add this by opening the menu item Tools | System Options and adding this jar on the Java tab or in a CLASSPATH environment variable that is visible to PB. You may need to restart PB for the change to be visible.

permanent link

answered 27 Jan '12, 15:54

Chris%20Keating's gravatar image

Chris Keating
2.8k1649
accept rate: 29%

edited 29 Jan '12, 11:29

Volker%20Barth's gravatar image

Volker Barth
30.3k300452659

Your advice has been a big help to get the JDBC profile setup in PB.

  1. I added C:Program FilesSQL Anywhere 12Javasajdbc4.jar to the JAVA tab of the System Options in PB
  2. I changed the URL slightly, adding jdbc: to the front. jdbc:sqlanywhere:DBN=myDBN;ServerName=test_sqlanywhere12;ASTART=NO;Host=dhhbgbfhsql101:2638

That worked to get me a JDBC profile connection in PB12.5

Then I wanted to get my app changed.

//SQLCA.DBMS = "ODBC" *became*
SQLCA.DBMS = "JDBC"

//SQLCA.dbparm = "ConnectString='DSN=" + ls_server + ";UID=" + trim(sle_userid.text) + &
                 ";PWD=" + string(ls_dbpassword)  + "'"   *became*

    SQLCA.dbparm = "URL='jdbc:sqlanywhere:DBN=" + ls_server + ";UID=" + trim(sle_userid.text) + ";PWD=" + string(ls_dbpassword)  +  ";ServerName=test_sqlanywhere12;ASTART=NO;Host=dhhbgbfhsql101:2638',Driver='sybase.jdbc4.sqlanywhere.IDriver'"

That works fine on my development PC, when I make an executable and install, still runs fine from my development machine. When I attempt to run the same executable from another machine I get the following error:

SQLCA.sqlerrtext = "NON SQL Error: Could not load class sybase.jdbc4.sqlanywhere.IDriver"

Why won't it connect when I run the exe from another PC?

permanent link

answered 31 Jan '12, 14:52

KevinG's gravatar image

KevinG
31227
accept rate: 0%

edited 31 Jan '12, 14:55

Add that same jar to the CLASSPATH environment variable on the deployment machine(s).

(31 Jan '12, 14:58) Chris Keating

I did add to the jar to the reg settings. It did work. But that is not the solution I was looking for. I want to be able to make the JDBC connection without making driver installs or registry changes. If I need to change the client, I will not be gaining much over just continuing to use ODBC.

Is there something I can add to my powerscript connection logic to update the classpath with the jar location?

http://www.sybase.com/detail?id=47902

Why use the JDBC Interfaces? Depending on which product you are using, the use of the JDBC interface enables you to develop several types of components and/or applications in PowerBuilder: Thin client/server applications If a client is already running a Java VM (in a running Web browser or inside the operating system), the use of the JDBC interface to access a database does not require the client-side installation and administration of a database driver such as what is required when using ODBC. The major advantage of using JDBC over ODBC drivers in PowerBuilder is zero client site configurations.

permanent link

answered 02 Feb '12, 08:48

KevinG's gravatar image

KevinG
31227
accept rate: 0%

edited 02 Feb '12, 08:49

3

I have not used the JDBC interface in PB until now so you may want to ask this in a PowerBuilder focused forum as someone may know other mechanisms to resolve this.

I looking at the options that can be set in code, I see nothing that allows you to identify the JDBC driver jar. But what you can do is create a launcher app or a batch that defines an isolated environment for the application to use and launches the application. Sybase Central and dbisql use this technique.

A simple batch could be

set CLASSPATH=<desired classpath=""> YourApp.exe

(02 Feb '12, 11:25) Chris Keating
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:

×409
×67
×34

question asked: 27 Jan '12, 11:19

question was seen: 2,340 times

last updated: 15 Mar '13, 21:26