Android Tutorial Tutorial of connecting Android to MS SQL Server using jRDC2

Hi

Here is a tutorial that shows the steps of how to make an Android connection to MS SQL Server using jRDC2.

Download tutorial here:
Attached the Mobile Project in B4A and the JRDC2 Project in B4J

Any questions please ask in the forum

Bladimir Silva Toro
Teacher programming software
 

Attachments

  • Example B4A.zip
    10.4 KB · Views: 2,057
  • jRDC SQL Server.zip
    5.2 KB · Views: 1,897
  • Script TestSQLServer.txt
    857 bytes · Views: 1,758

Vikjh

Member
Licensed User
I use online method to get commands:
B4X:
Public Sub GetSQLCommand(SqlKey As String)As String
    Dim GetSQL as String="SELECT [Sql] FROM JRDC_SQL WHERE [Sql] is not null AND [Key]=?"
    Dim res As String = pool.GetConnection.ExecQuerySingleResult2(GetSQL,Array As String(SqlKey)).ToLowerCase.trim
    Return res
End Sub
I think this is more convenient than the commands in a text file
 
Last edited:

Shelby

Well-Known Member
Licensed User
Longtime User
In step 6 of your tutorial, I find that my config.properties file is a pdf; your file in the tutorial is a text file. I get an error when I double click the pdf. The error message says: Adobe Acrobat Reader could not open 'config.properties' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). I'll look into my c:\\drive at the file.
 

josejad

Expert
Licensed User
Longtime User
Right click the file and open it with notepad instead of adobe acrobat. Probably you have assigned .properties extension with adobe acrobat
 

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Hello @Shelby

Here are the steps to configure the notepad as editor for the config.properties file in JRDC2

1. Go to configure the external editor

1609767693576.png


2. Type the path to Notepad in my case it would be: C: \ Windows \ system32 \ notepad.exe

1609767767087.png



3. Verify that Notepad already appears as your default editor.

1609767859275.png


Any other questions let me know it will be a pleasure to help you
 

Shelby

Well-Known Member
Licensed User
Longtime User
Thanks, however, I don't have a file or folder called notepad.exe. In my Windows 10 System32 folder, I have an empty notepad file called 'notepad' of type Application. Edited: What I did was to remove the config.properties file which was a PDF I think it was and reintroduce it after opening it as a text file as Jose suggested in post # 6. Now I'll see if I can proceed as your tutorial instructs me to.
 
Last edited:

Shelby

Well-Known Member
Licensed User
Longtime User
Thanks kisoft, I solved the problem with my above **edited post #9. Now I'm tryng to get a URL either for my browser or my computer for the step #7 in Bladimir's tutorial. It's not clear for me to understand which URL I need.
 

josejad

Expert
Licensed User
Longtime User
It's not clear for me to understand which URL I need.
Where's your MS SQL database? In another computer in your network? In the same computer you're developing? In internet?
 

Shelby

Well-Known Member
Licensed User
Longtime User
Same computer: desktop>B4X>A New Idea>JRDC2......etcetera
 

josejad

Expert
Licensed User
Longtime User
Same computer
If it's the same computer, you can write "localhost"
B4X:
JdbcUrl=jdbc:jtds:sqlserver://localhost/TestSQLServer

That's because your jRDC2 server and your MS SQL server are in the same computer.
In the client (B4A app?) you should write your pc local network IP (you can get it going to console and writing "ipconfig", or in your network card properties, it will be something similar to 192.168.0.x or 192.168.1.x"
 

Shelby

Well-Known Member
Licensed User
Longtime User
I don't know why when using run>ipconfig, a window blinks but does not display (windows10). I'll try the network card properties (I'll do search to find the card) OK I found it; so I put the 192.168..... in the file, not local host like you mentioned in post #14, right?
 
Last edited:

josejad

Expert
Licensed User
Longtime User
Try run->cmd, press enter, then in console, write ipconfig.
 

Shelby

Well-Known Member
Licensed User
Longtime User
Oh yeah the cmd first; I forgot, Thanks. It verified that the IPv4 address is the same as the settings entry...... so I put the 192.168..... in the file, not local host like you mentioned in post #14, right? Maybe I should write 'local host'. Right now it reads:

#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
User=root
Password=
#Java server port
ServerPort=17178
 
Last edited:

josejad

Expert
Licensed User
Longtime User
Top