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

Status
Not open for further replies.

coldtech

Member
Licensed User
Longtime User
OK got it working, you may want to point out that the client example only shows the results in the log.

It took me a little while staring at the emulators black screen to realize

Thanks Erel
 

Sytek

Active Member
Licensed User
Longtime User
OS: Windows 8. (64-Bits)
Tested on MySQL connection on Wampserver...Works just fine....Ok!

The only problem that I face is that if I Put the Server Online and execute the RDC Batch it throws the following error
2013-08-07 21:45:18.738:WARN::FAILED org.eclipse.jetty.server.Server@5f7e8f: jav
a.net.BindException: Address already in use: bind
Exception in thread "main" java.net.BindException: Address already in use: bind

..And I need to put the Server Online 'cause there's my data information system (inventory)
If I don't put the Server online I cannot Access the php system(inventory).

Please Help; How can I solve this one.
Thanks in advance.
Best Regards!
 

Sytek

Active Member
Licensed User
Longtime User
This error means that there is already another app that listens to the port. You can change RDC port in the config file.

Thank's Erel; I will change it arriving home.

By the way THIS IS THE BEST CONNECTOR 'TIL TODAY, Nice one young man!...nice one !!! Appreciate.

Best Regards!

EDIT:
This error means that there is already another app that listens to the port. You can change RDC port in the config file.
This solution solves my problem; As I said Before...
THIS IS THE BEST CONNECTOR 'TIL TODAY!
Cheers Erel...Thank's

....and Remove the 'TIL TODAY.....THIS IS THE BEST CONNECTOR.
 
Last edited:

Sytek

Active Member
Licensed User
Longtime User
Hello Erel!
How Do I send the Parameters for the Insert command ?
config command
sql.insert_serial=insert into serials (serial,status,name,endaccess) values (?,?,?,?)


Thank's for your Help
Best Regards!
 

Sytek

Active Member
Licensed User
Longtime User
B4X:
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "insert_serial"
cmd.Parameters = Array As Object(2, 3, "name 22", 1)
reqManager.ExecuteCommand(cmd, "tag")
Thank's That was quick ..Appreciate!
 

yckhor

Member
Licensed User
Longtime User
B4X:
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "insert_serial"
cmd.Parameters = Array As Object(2, 3, "name 22", 1)
reqManager.ExecuteCommand(cmd, "tag")
Hi Erel, any example of inserting a BLOB object as one of the parameters, taking your example? A BLOB like a photograph taken using the android device camera?
Thanks in anticipation!
 

Sytek

Active Member
Licensed User
Longtime User
Hello Erel!
When I Insert a datetime field value
PHP:
cmd.Initialize
cmd.Name = "insert_serial"
cmd.Parameters = ArrayAsObject(md5imei,ima.Input,"adddate(current_timestamp,30)","current_timestamp","current_timestamp")
reqManager.ExecuteCommand(cmd, "tag")
...The RDC throws me this error.
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '
current_timestamp' for column 'endaccess' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4094)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2734)


I can insert in the phpmyadmin sql command without problem.
PHP:
insert into serials(serial,name,endaccess,lastaccess,firstaccess) values ('111111','serial name',adddate(current_timestamp,30),current_timestamp,current_timestamp)

I'm I Missing Something?

Thank's in advance for your help
Best Regards!

SOLUTION: see this thread
http://www.b4x.com/android/forum/threads/rdc-connector-insert-a-datetime-field-value.31797/
 
Last edited:

derez

Expert
Licensed User
Longtime User
Working with SQLITE on PC and devices.
I get a complete table (=all the records) from the pc almost immediately, since the response for "SELECT * ..." comes in one answer. When I send the records from the device to the pc I use "INSERT" to fill in the records, but this is done one by one and takes about 14 seconds (because the program waits for each job to be done, otherwise they somtimes get lost...).
Is there a way to send all the records in one reqmanager command ?
 

georgelbs

Member
Licensed User
Longtime User
I have trouble running the server script on Linux Ubuntu, anybody have a working sample?
 

georgelbs

Member
Licensed User
Longtime User
"/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java" -Xmx256m -cp .:libs\*:jdbc_driver\* anywheresoftware.b4a.remotedatabase.RemoteServer
pause


Run in a terminal, but closes quickly without a error
 

kanaida

Active Member
Licensed User
Longtime User
I'm trying to use the following driver, found one for oldschool foxpro. I'm not exactly sure how to modify the properties etc... never really used JDBC.
http://www.caigen.com/dbf/doc.html#url
http://www.caigen.com/dbf/

I tried this and changed my java path in the Batch file:
B4X:
#Foxpro Server
DriverClass=com.caigen.sql.dbf.DBFDriver
JdbcUrl=jdbc:dbf://\\\\scoserver\\livedata\\1103
#If Debug is true then this file will be reloaded on every query.
#This is useful if you need to modify the queries.
versionNumber=02

Got this:
B4X:
C:\Users\user\Google Drive\android_projects\RDC-Server>"C:\Program Files (x86)\Java\jre7\bin\java" -Xmx256m -cp .;libs\*
;jdbc_driver\* anywheresoftware.b4a.remotedatabase.RemoteServer
B4A Remote Database Connecter (version 0.9)
loading: C:\Users\user\Google Drive\android_projects\RDC-Server\config.properties
Exception in thread "main" java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at anywheresoftware.b4a.remotedatabase.RemoteServer.main(RemoteServer.java:33)

C:\Users\user\Google Drive\android_projects\RDC-Server>pause
Press any key to continue . . .

It's an interesting find indeed, perhaps this means I can finally overcome my samba+foxpro performance issues in ubuntu 8.04 + ASP.net back end if I switch other stuff to use this new provider possibly. This b4a app i'm making will be a good trial.
 

slydog43

Member
Licensed User
Longtime User
Love this new interface to a remote database, but I have some trouble. When I try and update many tables quickly the sqllite db gets corrupted. Here is a short example of 1 table getting updated. It works if it only updates 4 times, but if I increase the loop to 5 or more it fails. Any ideas?



Sub JobDone(Job As HttpJob)

Dim lNumRecs As Long
Dim iCounter As Int
Dim dIncValue As Double
Dim dCurrValue As Double
Dim iTempID As Int
Dim iTempSEQ As Int
Dim sTempDesc As String
Dim sTempAbbrev As String

Dim iTemp2 As Int
Dim iTemp3 As Int
Dim sTemp1 As String
Dim sTemp2 As String

Dim cmd As DBCommand


cmd.Initialize

If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
If Job.JobName = "DBRequest" Then
Dim result As DBResult = reqManager.HandleJob(Job)
Select Case result.Tag
Case "SelectBody"
Label3.Text = "Downloading Body"
ProgressBar1.Progress = 0
Dim result As DBResult = reqManager.HandleJob(Job)
lNumRecs = result.Rows.size
Label5.Text = lNumRecs
iCounter = 0
Label4.Text = iCounter
dIncValue = 100/lNumRecs
dCurrValue = 0
ProgressBar1.Progress = dCurrValue
DoEvents
For Each records() As Object In result.Rows
iCounter = iCounter + 1
Label4.Text = iCounter
dCurrValue = dCurrValue + dIncValue
ProgressBar1.Progress = dCurrValue
iTempID = records(result.Columns.Get("BodyID"))
iTempSEQ = records(result.Columns.Get("BodySEQ"))
sTempDesc = records(result.Columns.Get("BodyDesc"))
sTempAbbrev = records(result.Columns.Get("BodyAbbrev"))
mySQL1.BeginTransaction
Try
mySQL1.ExecNonQuery("INSERT INTO Body (BodyID, BodySEQ, BodyDesc, BodyAbbrev) VALUES (" & iTempID & ", " & iTempSEQ & ", '" & sTempDesc & "', '" & sTempAbbrev & "'" & ")")
mySQL1.TransactionSuccessful
Catch
Msgbox("Error writing to Body Table","")
Log(LastException.Message)
End Try
mySQL1.EndTransaction
DoEvents
Next

myTesting = myTesting + 1
If myTesting < 4 Then '1,2,3 works 4 stops working
cmd.Name = "select_body"
reqManager.ExecuteQuery(cmd, 0, "SelectBody")
End If
End Select
End If
End If
Job.Release
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…