B4J Question Version of SQL server for jtds

David Elkington

Active Member
Licensed User
Longtime User
Hi Everyone,

I have an application that is running on jtds 1.3.1 and MS sql server Express 11.0. Our databases are now growing too big and I need to migrate to full fat MSSQL and was wondering

1. is 1.3.1 still the go to driver
2. What is the most modern SQL server that will work with it.

Many thanks.
 

DarkoT

Active Member
Licensed User
Hi,
try to use clasic JDBC for Sql server... I'm using now mssql-jdbc-9.4.0.jre11.jar and work everything correct...

If you need - here are how to add jar into B4J:

1. Download microsoft Jdbc driver for sql server:

Download MS Jdbc

2. Copy jar to Additional libraries
3. Add Jar as Additional Jar into B4J Region project Attributes:

B4X:
#Region Project Attributes
    #MainFormWidth: 1024
    #MainFormHeight: 768
    #AdditionalJar: mysql-connector-java-5.1.48-bin.jar
    #AdditionalJar: mssql-jdbc-9.4.0.jre11.jar
    #AdditionalJar: sqlite-jdbc-3.31.1.jar
   
    #PackagerProperty: IconFile = ..\Files\IcoInvoices.ico
    #PackagerProperty: ExeName = OptInvoining

#End Region

4. Create Init routine to connect to Sql server database - like this:

B4X:
Sub InitIps As ResumableSub
    Dim dbInit As String = $"jdbc:sqlserver://${ip/server name}:${port - default: 1433};databaseName=${yourdatabasename};user=${username};password=${Password};"$
   
    Try
        IpsSql.Initialize2("com.microsoft.sqlserver.jdbc.SQLServerDriver", dbInit, username, password)
    Catch
        Log(LastException)
        Return False
    End Try
   
    Return True
End Sub

Change Ip of server, port, username, password and database name
IpsSql is declared as Sql

Last version of Sql server (express) is 2022 and has limited database size = 10Gb (per database). If is your database to big, you need to switch to sql server standard edition which is not free-of-charge. If are over database size and want not to pay microsoft, you have two options:
1. delete older data or trasfer it to another database or
2. create new database which will include data from now, older data can stay in old database. You can combine then data with select over two databases like:
SQL:
select datafromOld.*, datafromNew.*
from [datafromolddb].dbo.[mytable] as datafromOld inner join [datafromnewdb].dbo.[mytable] as datafromNew on datafromOld.id = datafromnew.Id

Hope, this will help you...
 
Last edited:
Upvote 0

DarkoT

Active Member
Licensed User
Great. Does that work with sql server 2022?
Take a last Jdbc from Microsoft download page and this will work with last sql server express (you need just to change a name of Jdbc in code). Look on my comments regarding the limitation (I edit my previus post)...
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
I tried swapping out the tds with the pre (8) but get the following error

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Sub appstart signature does not match expected signature.
 
Upvote 0

DarkoT

Active Member
Licensed User
I tried swapping out the tds with the pre (8) but get the following error

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Sub appstart signature does not match expected signature.
CAn you post a example with code?
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
I think it may be because I have an instance in the SQL server not just an IP or database name. I will try some experiments later.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Sub appstart signature does not match expected signature
Did you changed the sub signature of the appstart-sub? This is the error mentioned.
Correct this first.

Upload a small project showing the issue.
 
Upvote 0

DarkoT

Active Member
Licensed User
I think it may be because I have an instance in the SQL server not just an IP or database name. I will try some experiments later.
Here connection string: jdbc:sqlserver://[serverName[\instanceName][portNumber]][;property=value[;property=value]]
 
Upvote 0
Top