Android Tutorial Remote Database Connector (RDC) - Connect to any remote DB

Status
Not open for further replies.

Tom1s

Member
Licensed User
Longtime User
Check the values before you add them to cmd.Parameters.

You are right it is rounded version when putting it to cmd.parameters. I checked that value is ok when storing it to litesql but when reading it something is not right in the code I previously send.
 

lvdp

Member
Licensed User
Longtime User
I'm trying to connect to SQLserver (SQLEXPRESS) on my PC (using the SQLServer driver), but I get:
RemoteServer is running (Mon Aug 24 14:50:28 CEST 2015)
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

When looking in the log I see:
Unknown Server host name '192.168.1.13\SQLEXPRESS'

I've put in config.properties:
DriverClass=net.sourceforge.jtds.jdbc.Driver
JdbcUrl=jdbc:jtds:sqlserver://192.168.1.13\\SQLEXPRESS/InfoSystem
User=****
Password=****
ServerPort=1433

and in jdbc_driver\conf\connection.properties.tmpl
driver=net.sourceforge.jtds.jdbc.Driver
url=jdbc:jtds:sqlserver://192.168.1.13\\SQLEXPRESS/InfoSystem
USER=****
PASSWORD=****
SERVERNAME=192.168.1.13\\SQLEXPRESS
PORTNUMBER=1433
DATABASENAME=InfoSystem
SERVERTYPE=1XA
EMULATION=true
TDS=8.0

I tried different server names, but none worked.
The 192.168.1.13 I found with ipconfig.
What server name should I use?
 

lvdp

Member
Licensed User
Longtime User
Thank you for the quick answer.

However: I also tried this already, and when I try again it gives the same error:
RemoteServer is running (Mon Aug 24 15:25:10 CEST 2015)
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

This is the full log (I put in bold what I thought was most important):


Any further suggestions (I put the Firewall off) ?
Thank you...
 
Last edited:

lvdp

Member
Licensed User
Longtime User
By the way: I was trying with SQLEXPRESS, but finally I'd like to use Microsoft Azure as cloud database.
Anyone knows how to do this (and were to put the server code) ?
 

lvdp

Member
Licensed User
Longtime User
Thank you for the excellent support!
I now get "Connection successful" with these settings:

DriverClass=net.sourceforge.jtds.jdbc.Driver
JdbcUrl=jdbc:jtds:sqlserver://127.0.0.1:1433;instance=SQLEXPRESS;DatabaseName=InfoSystem
 

John Decowski

Member
Licensed User
Longtime User
Just curious does this system implement any safe guards against sql injection type hacking "ie . Max request lengths or illegal characters?
Just curious in regards to security.
 

John Decowski

Member
Licensed User
Longtime User
Ok i see that but... I was wanting to make sure it wasnt possible to inject sql code into the argument variable passed between console and app. "?" Portion?
Sorry didn't explain it right
 

jsanchezc

Member
Licensed User
Longtime User
By the way: I was trying with SQLEXPRESS, but finally I'd like to use Microsoft Azure as cloud database.
Anyone knows how to do this (and were to put the server code) ?

You can use Sql Server Management Studio.
To connect you must use IP but at SSManagement Studio is this format:
Server= 127.0.0.1,1433
User: (indicate sql server username)
Password: xxxxxxxx

Notice: If you indicate port number you don't need to indicate instance name.
Be sure port is 1433. This is standard port for SQL but sometimes other number is configured, also SQL allow dynamic ports.
If you can connect by app, then you will connect by SSManager Studio.

Each version of SQL Server Management Studio allow to admin same version of SQL Server and previuos versions.
There are free versions you can install on your PC.
You can manage Tables, Views, Stored Procedures, User Functions.....

See this link:
https://azure.microsoft.com/es-es/documentation/articles/sql-database-manage-azure-ssms/

hope this help.
 

lvdp

Member
Licensed User
Longtime User
@jsanchezc

With the info you gave me, I got access to my SQL Server database on Azure from SQL Server Management Studio.
I have a database Samagis_db with a table Messages, in whcich I put 2 records.
I created a user dbacces with a pasword that should have read access (exec sp_addrolemember 'db_datareader', 'dbaccess'; )
I added my local IP address in the Azure firewall.

Next I'm trying to use this with the RDC connector, at first located on my local PC (in the future it should also reside on Azure).
I found somewhere I should add ";ssl=require" in the JdbcUrl, so in the config.properties file I wrote:

B4X:
DriverClass=net.sourceforge.jtds.jdbc.Driver
JdbcUrl=jdbc:jtds:sqlserver://mvr8bm4spa.database.windows.net:1433/Samagis_db;ssl=require
User=dbaccess
Password=*******
ServerPort=1433
Debug=true
#commands
sql.select_Messages=SELECT [ID], [Message] FROM [Samagis_db].[dbo].[Messages] ORDER BY TimeCreated
sql.select_Message=SELECT [ID], [Message] FROM [Samagis_db].[dbo].[Messages] WHERE ID = ?

Then I start RunRLC.bat and try http://127.0.0.1:1433/?method=test
But I get:

RemoteServer is running (Sat Aug 29 13:50:01 CEST 2015)
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

Any suggestions ?

This is the log:

 

galimpic

Member
Licensed User
Longtime User
Can server commands from the config.properties file be executed through a web browser, or is just "method=test" parameter available?
 

galimpic

Member
Licensed User
Longtime User
If you only released the source code for this server, I am sure it would be easy to make changes and improvements... I know you haven't planned it, I'm just saying it would be the easiest way for us who asked for small changes (eg. encoded instead of plain communication) to just work on existing code instead of building it from scratch after reading about Jetty, c3po etc.
 
Last edited:

chrisinky

Member
Licensed User
Longtime User
Assuming I'm overlooking something... I'm trying to run a SQL statement similar to this:
Select * from table where field like 'x%'

How would I make this work? In my config file I have the "x" replaced with the ? and that doesn't work, I've put the ? after LIKE and have the program send "'x%' but that doesn't work either.
Thanks!
Chris
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…