Android Question B4A - Direct connection with JdbcSQL to MSSQL with istance

Rodolfo Milan

Member
Licensed User
Hello everyone,
i tried successfully to connect my app an MSSQL Server without istance, but when i try to connect with another MSSQL that has an istance the connection doesn't work.
I specify the istance in the jdbcUrl after the IPServer; is it right?


Connection data:
    Public MsSql As JdbcSQL
    Private driver As String = "net.sourceforge.jtds.jdbc.Driver"
    Private DBName As String = "dbname"
    Private Username As String = "sa"
    Private Password As String = "pass"
    Private jdbcUrl As String = "jdbc:jtds:sqlserver://192.168.xx.xx/SQLEXPRESS2016:1433;databaseName=" & DBName & ";user=" & Username & ";password=" & Password & ";appname=SKMJL;wsid=MyWS;loginTimeout=10"
 

OliverA

Expert
Licensed User
Longtime User
With jTDS, instance is a property. See http://jtds.sourceforge.net/faq.html#urlFormat
So something like:
B4X:
Private jdbcUrl As String = "jdbc:jtds:sqlserver://192.168.xx.xx:1433;instance=SQLEXPRESS2016;databaseName=" & DBName & ";user=" & Username & ";password=" & Password & ";appname=SKMJL;wsid=MyWS;loginTimeout=10"
 
Upvote 0

Rodolfo Milan

Member
Licensed User
Thanks OliverA, i found in the link the section for the property "instance" but it didn't work yet. I also read other articles about jTDS and found that other users have issue with SQL with instance, but everyone use a different form for the connection string.
Tomorrow i will try and i hope to get the connection
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
What is the exact error message?
 
Upvote 0

Albert Kallal

Active Member
Licensed User
The connection string should look like this:

B4X:
jdbc:jtds:sqlserver://192.168.0.251;DatabaseName=TEST3;instance=SQLEXPRESS

As a general rule, you don't want to include the port number.
Make sure the SQL server browser service is running.

I have a sample "test" connection app here:
https://www.b4x.com/android/forum/t...ms-sql-server-2016-in-b4a.114798/#post-717800

(it lets you type in server (as IP address), the sql instance, and then user + password. Then you just hit test connection.)

I think in most cases, often the issue is no sql server browser running, and that you attempt to include the port number.
(the browser service for SQL handles the actual IP address and port assigned to the running instance of SQL server)

Regards,
Albert D. Kallal
Edmonton, Alberta, Canada
 
Upvote 0

Rodolfo Milan

Member
Licensed User
What is the exact error message?

It didn't find the server

The connection string should look like this:

B4X:
jdbc:jtds:sqlserver://192.168.0.251;DatabaseName=TEST3;instance=SQLEXPRESS

As a general rule, you don't want to include the port number.
Make sure the SQL server browser service is running.

Now it works! I don't really know which was the problem beacause i already tested this string last week but didn't work.. Maybe the problem was the server
Btw Thanks to everyone:)
 
Upvote 0
Top