Android Question B4A how to writes commands to remotely connect to an SQL database

yl0859

Member
B4A penetrates the remote connection to the SQL database through the peanut shell intranet, and I don't know the correct command format, I hope the teachers will point out!
(SQLException) java.sql.SQLException: The syntax of the connection URL 'jdbc:jtds:sqlserver:115.236.153.174,18241\\SQLEXPRESS;databaseName=MISDB;user=sa;password=123456;appname=SKMJL;wsid=TEST;loginTimeout=10;socketTimeout=10' is invalid.

How do you write it in the right format?
 

aeric

Expert
Licensed User
Longtime User
I think the jdbcUrl should look like jdbc:jtds:sqlserver://115.236.153.174:18241/MISDB;instance=SQLEXPRESS;user=sa;password=123456;

The recommended method to connect to remote databases is jRDC2: https://www.b4x.com/android/forum/threads/61801/#content

Connecting to the database directly has several disadvantages:

- Insecure - it will be quite simple for a hacker to get the username and password and directly access the database.
- Hard to maintain - changes to the database design will require updating the app.
- Server and client performance issues - The Jdbc drivers are not optimized for mobile usage.
- Reliability issues due to unstable connectivity.
 
Upvote 0

yl0859

Member
@aeric:I can connect to a remote database that is not accessible through the internal network using this format for reference.
a.setDatabase("101.34.213.13:1433","CBM123","CBM666","Cbm981209")
 
Upvote 0

yl0859

Member
@aeric:But I still can't use this method. Please help me to see what's going on.
a.setDatabase( "115.236.153.174:18241/SQLEXPRESS","MISDB","sa","123456")
 
Upvote 0

yl0859

Member
@aeric:My database is temporarily built on my office computer, through the peanut shell network penetration to get a fixed IP, if you want to test in my working time 8: 30-16: 40 test, other time the computer does not boot.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I can't see how you write the code to make the connection with the following code:
B4X:
a.setDatabase( "115.236.153.174:18241/SQLEXPRESS","MISDB","sa","123456")

1. Please post a sample code / project.
2. Please post your error message.
3. It is better to use jRDC2 if you have full control of the server.

Not sure what you mean by peanut shell network penetration due to lost translation.
I guessed you mean Virtual Private Network (VPN).
 
Upvote 0

yl0859

Member
Yes, I used the example you provided for the test. Since I did not have a fixed IP, I obtained the fixed IP through the company's Intranet. Now my data is as follows: IP:115.236.153.174; Port number: 18241; SQL database instance name: SQLEXPRESS; DataBase=MISDB; Uid=sa; Pwd=123456; So now the question is, how to combine the above data into a correct connection command, or how to fill in the above parameters in a correct format to the routine interface you provided, please teach, thank you!
 
Upvote 0
Top