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
When I test the connection I the error popup: POWERBUILDER Non SQL Error: cound not load class sybase.jdbc4.sqlanywhere.IDriver
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.
Your advice has been a big help to get the JDBC profile setup in PB.
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?
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?
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.