Android Question Microsoft JDBC driver working perfectly on B4J but NOT on B4A

M.SALIM

Member
I'm currently testing the latest Microsoft JDBC driver and noticed that it works well on with B4J but NOT on B4A.
Please see code below

query:
#AdditionalJar: mssql-jdbc-12.6.1.jre11

Private Sub RunQuery
    Dim  zJDBC    As JdbcSQL
    Dim  myCNS       As String  ="jdbc:sqlserver://YOURSRRVER:PORT;databaseName=TESTDB;encrypt=true;trustServerCertificate=true"
    zJDBC.Initialize2("com.microsoft.sqlserver.jdbc.SQLServerDriver",myCNS,userid,pwd)
    Dim R As JdbcResultSet =  zJDBC.ExecQuery("SELECT * FROM Table1")
    Do While r.NextRow
        Log ( r.GetString("data1") )
    Loop
    R.Close
End Sub

When same code is being executed on B4A (i.e Android), the system crashes and throws the following error:

err:
com.microsoft.sqlserver.jdbc.SQLServerException: "encrypt" property is set to "true" and "trustServerCertificate" property is set to "true" but the driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption: Error: Socket is closed. ClientConnectionId:ee69fa1f-a59f-47f4-857f-3e4647e2b558
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:4266)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1965)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3792)

I've been searching around several blogs without any resolution.
Anyone kindly advised how to resolve same.

Note that JTDS driver from sourceforge works on both platforms, but it seems they are no longer updating the driver since 2013.
 

M.SALIM

Member
Thank you for your reply.

Your are right for using JRDC2 & webservice and I'm already using same in some of my applications (specially internet).

My posting was just to have an update on the MS JDBC driver if anyone has come with a solution
given MS has recently release an update (mssql-jdbc-12.6.1.jre11 dated Feb 2024) and the above related thread dates back some years ago.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I think the answer from the above link still applies.
 
Upvote 0
Top