B4J Question B4JPackager11 JTDS Charset Problem

Johan Schoeman

Expert
Licensed User
Longtime User
Is there any solution for.....

B4X:
java.sql.SQLException: Could not find a Java charset equivalent to DB charset Cp1252
.....when making use of #AdditionalJar: jtds-1.3.1 and compiling the B4J project to a standalone package?

Running the B4J app from the IDE is working perfectly but cannot get the standalone exe to run
Have tried adding various charset's to the Initialize string but it always fails - tried UTF-8, ISO-8859-1, Cp1252

eg:
B4X:
    SQL1.Initialize("net.sourceforge.jtds.jdbc.Driver","jdbc:jtds:sqlserver://xx.x.xxx.xx:1433/Syspro_Live_xxx_x;integratedSecurity=true;useNTLMv2=true;charset=UTF-8;")

Have searched the forum but cannot find a solution. Really don't want to switch to a Microsoft driver
 

Johan Schoeman

Expert
Licensed User
Longtime User
Yes Erel - have tried that. Got the folder in two places:
1. in the parent folder of the project

1629642388123.png


2. In the bin folder of the project:

1629642512997.png


No joy with it....
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Add this code at the beginning of the program:
B4X:
Dim jo As JavaObject
jo.InitializeStatic("net.sourceforge.jtds.util.Logger").RunMethod("setActive", Array(True))

Build a package and run it with run_debug.bat.
A file named log.out will be created in the bin folder. Please upload it. Also post the full logs from the console window.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hello Erel

This is what I get:
B4X:
C:\Users\johans\Documents\B4JApps\connectSyspro\connectSyspro\Objects\temp\build\bin>java.exe @release_java_modules.txt  -m b4j/b4j.example.main
main._button1_click (java line: -1)
java.sql.SQLException: Could not find a Java charset equivalent to DB charset Cp1252.
        at b4j/net.sourceforge.jtds.jdbc.JtdsConnection.loadCharset(Unknown Source)
        at b4j/net.sourceforge.jtds.jdbc.JtdsConnection.<init>(Unknown Source)
        at b4j/net.sourceforge.jtds.jdbc.Driver.connect(Unknown Source)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
        at b4j/anywheresoftware.b4j.objects.SQL.Initialize2(Unknown Source)
        at b4j/anywheresoftware.b4j.objects.SQL.Initialize(Unknown Source)
        at b4j/b4j.example.main._button1_click(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
        at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)


C:\Users\johans\Documents\B4JApps\connectSyspro\connectSyspro\Objects\temp\build\bin>pause
Press any key to continue . . .

Log.out is as follows:
B4X:
Can't load Charsets.properties
TdsSocket: Max buffer memory used = 0KB
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
I don't think it can be solved, that's why I used the Microsoft driver for B4J and the JTDS for B4A Good luck and tell us if you get it.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
I don't think it can be solved, that's why I used the Microsoft driver for B4J and the JTDS for B4A Good luck and tell us if you get it.
The answer is here and it is working 100%

 
Upvote 0
Top