Android Question How to use JDTS or JRDC to get successful connections to SQL Server 2019 DB?

Tamer El-Shimy

Member
Licensed User
Longtime User
I've tried the following with a simple DB which has only windows authentication for experimental purposes :

#AdditionalJar : mssql-jdbc-10.2.0.jre17.jar #AdditionalJar : JDBCSQL.jar ''#AdditionalRes : sqljdbc_xa.dll #AdditionalJar :jtds-1.3.1.jar:
#AdditionalJar : mssql-jdbc-10.2.0.jre17.jar
    #AdditionalJar : JDBCSQL.jar
    ''#AdditionalRes : sqljdbc_xa.dll
    #AdditionalJar :jtds-1.3.1.jar
 
    Public Sub KPI_Ready(Success As Boolean)
    If Success = False Then
    Log ("Failed to connect")
    Else if Success=True Then
        Log ("Succesful Connection")
    End If 
End Sub
Private Sub ButtonAdd_Click
    ''Private connectionString As String="jdbc:sqlserver://localhost;Port=80;databaseName=KPI"
    '' Private connectionString As String="jdbc:sqlserver://{SERVER}/{INSTANCE};Port={PORT};databaseName={DATABASE}"
    Private connectionStringTrusted As String="jdbc:jtds:SQLServer://Localhost:17178;databaseName='KPI';integratedSecurity=false;"
    AnySQL.InitializeAsync("KPI","net.sourceforge.jtds.jdbc.driver",connectionStringTrusted,"","")
    ''AnySQL.InitializeAsync("KPI","com.microsoft.sqlserver.jdbc.SQLServerDriver" , connectionStringTrusted,"","")
    If AnySQL.IsInitialized Then
   AnyResultSet= AnySQL.ExecQuery("Select * from Department")
    Log(AnyResultSet.GetString("Department_Name"))
    End If
    B4XPages.ShowPageAndRemovePreviousPages("Item")
End Sub

And I get the message "Failed to connect". What could be the problem?
 

MrKim

Well-Known Member
Licensed User
Longtime User
I have never gotten jtds to work with a windows connection on Android. Only with a username/pw.
And as I understand it it is an accident that it works at all with a wireless connection.
Use JRDC2.

Edit: Oh, and I have only been able to make jtds work with ip address. NEVER with a URL.
 
Last edited:
Upvote 0
Top