B4J Question Internal Packager, Inno Installer, MS SQL using jtds, invalid database address [Solved]

swChef

Active Member
Licensed User
Longtime User
I have a B4J app I've been using for years, that connects to a MS SQL server using jtds.
This new problem (for me), is when I package it and install it, using the internal Build Standalone Package
and then run the app, the db connection fails with "java.sql.SQLException: invalid database address".
It works fine when run from the IDE in Debug or Release.
I also have an older version that works when installed using the older packaging method (same code).
The only other difference between the older version and this new one is I converted it to B4XPages (which shouldn't matter).

I have another app that uses a Webview to connect to 'services' that required user/pw auth that is packaged and installed and I have no problem there.
I was hoping to 'upgrade' to the internal packager to make updates more convenient, which worked nicely with the 'webview' based app.


There isn't anything special about it, it is similar to examples in the forum.
I'll include below what I'm using.

B4X:
Private sqlX As SQL

#PackagerProperty: IncludedModules = javafx.web
#MergeLibraries: True ' didn't used to have this, didn't help

#AdditionalJar: sqlite-jdbc-3.7.2
#AdditionalJar: bcprov-jdk15on-154
#AdditionalJar: jtds-1.3.1.jar

sqlX.Initialize2("net.sourceforge.jtds.jdbc.Driver", _ ' tried Initialize too along with adding a specific /databasename (I'm just grabbing the list of databases with this App)
    "jdbc:jtds:sqlserver://"&sServer, "user", "pw")

I've read many forum threads/posts but perhaps just not hit on the right combination?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hard to give an answer without the connection string.

yet i believe that simply using jtds is an error, you should use the oficial drivers from microsoft. i dont have any problem with those.
 
Upvote 0

swChef

Active Member
Licensed User
Longtime User
Hard to give an answer without the connection string.

yet i believe that simply using jtds is an error, you should use the oficial drivers from microsoft. i dont have any problem with those.

? copied from above
sqlX.Initialize2("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://"&sServer, "user", "pw")

The question is why does it work w/o packaging/installation and not w/. How is the that process impacting the jtds driver, which works w/o.
I will try a MS driver.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
what i mean is that you are not showing this variable. i understand is senstive information but at least the fields you used and how you arranged them could be helpful.

The question is why does it work w/o packaging/installation and not w/.
i dont know, last update of jtds was on 2013 with java 5, you are using java 11 most likely something changed along the way. that or your connection string is incorrect
 
Upvote 0

swChef

Active Member
Licensed User
Longtime User
what i mean is that you are not showing this variable. i understand is senstive information but at least the fields you used and how you arranged them could be helpful.

it was just the hostname, although I did try adding a /dbname in the statement, too.
I didn't go into detail of everything I tried that didn't improve the issue because I think it isn't the 'connection statement' at this point.
As you say maybe the other driver is better for packaging/installation, but I'd like to get feedback on why if someone knew that... is there a technical limitation or am I just missing a specifier to the process.
I also read in one thread that the jtds was something like 4* faster... so I didn't want to go backwards in performance, and after many years of it working in the 'old packager' exe I thought I was just missing something for the new packager or installer.
I did test in two different environments, and the current code still works in Debug or Release mode even over my employer's VPN, so again figured it is related to the packager/installer.
The only functionality affected negatively is the db connection, when packaging/installing/testing.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
also read in one thread that the jtds was something like 4* faster
i dont think this is correct, the only reason to use jtds over the oficial driver is if you want to use it with B4A.

, and after many years of it working in the 'old packager' exe I thought I was just missing something for the new packager or installer.
it is actually possible, in this packager you have to include certain modules manually for it work, but with the official drivers you dont have to do anything.
 
Upvote 0

swChef

Active Member
Licensed User
Longtime User
@Enrique Gonzalez R
Thank you for your persistent help. Including related threads (this and this) (and @OliverA for the link in his post, saved a bit o time)

I switched to MS's 9.2.1 using
driver from https://docs.microsoft.com/en-us/sq...c-driver-for-sql-server?view=sql-server-ver15
(includes the other java versions including 11), and replacing jtds-1.3.1

and the following statements in B4J
B4X:
#AdditionalJar: mssql-jdbc-9.2.1.jre11.jar
#AdditionalJar: sqlite-jdbc-3.7.2
sqlXSoft.Initialize2( _
    "com.microsoft.sqlserver.jdbc.SQLServerDriver", _
    "jdbc:sqlserver://"&sServer, _
    "user", "pw")
 
Upvote 0
Top