cancel
Showing results for 
Search instead for 
Did you mean: 

Convert classic PowerBuilderApp to use JDBC instead of ODBC

Former Member
0 Kudos
5,806

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

Accepted Solutions (0)

Answers (3)

Answers (3)

chris_keating
Product and Topic Expert
Product and Topic Expert

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.

Former Member
0 Kudos

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.

chris_keating
Product and Topic Expert
Product and Topic Expert

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

Former Member
0 Kudos

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?

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

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