Android Question Issues in executing RDC_Server, RDC_Client feature

beelze69

Active Member
Licensed User
Longtime User
Hi !

I am a new user of B4A.

I am having issues in implementing the RDC_Server RDC_Client feature. I have set up the RDC_Server and RDC_Client. Also downloaded the SQLLITE Driver as mentioned in Erel's post https://www.b4x.com/android/forum/threads/rdc-simple-way-to-create-your-own-back-end-database.31616/ . I have set up the appropriate config properties ....

Some doubts:

i) I presume that the file test.db will be created by the Application. There is no test.db in my machine.. Somebody please correct me if my understanding is wrong.

ii) I am getting the following error message in the LOG FILE:

Error: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.0.100:17178 refused


The output of RUNRLC bat shows:

:BEGIN DISPLAY CONTENT:

I:\..\RemoteDatabaseConnector>"C:\Program F
iles\Java\jdk1.8.0_11\bin\java" -Xmx256m -cp .;libs\*;jdbc_driver\* anywheresoft
ware.b4a.remotedatabase.RemoteServer
B4A Remote Database Connecter (version 0.9)
loading: I:\..\RemoteDatabaseConnector\conf
ig.properties
2017-10-21 21:38:51.352:INFO::jetty-7.4.2.v20110526
2017-10-21 21:38:51.381:INFO::started o.e.j.s.ServletContextHandler{/,null}
Oct 21, 2017 9:38:51 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
Oct 21, 2017 9:38:51 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.2.1 [built 20-March-2013 11:16:28 +0000; debug? true
; trace: 10]
2017-10-21 21:38:51.679:INFO::Started SelectChannelConnector@0.0.0.0:17178 START
ING


:END DISPLAY CONTENT:

What could be the problem ?
 

beelze69

Active Member
Licensed User
Longtime User
Hi All !

Refer earlier post..

I have configured my RemoteServer Correctly, it seems.

I am now getting the message:

:BEGIN MESSAGE:

RemoteServer is running (Sat Oct 21 23:22:38 IST 2017)
Connection successful.

:END MESSAGE:

But unable to progress further ... Requesting for help ... Thanks ...
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi All !

Refer earlier post...

1) First I disabled Internet Connection and gave IP 192.168.1.100 to my machine (with 192.168.1.1 as gateway) and 255.255.255.0 as subnet mask.

Restarted RUNRLC.BAT ..

Code compiles fine but I am unable to go ahead...

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
reqManager.Initialize(Me, "http://192.168.1.100:17178")
End If
End Sub

FAILS !!


Even after changing to below it fails !


Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
reqManager.Initialize(Me, "http://127.0.0.1:17178")
End If
End Sub


Ps help ....
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi Erel,

I tried the new JRDC2 ..

I am getting the following error message at the Server Side...

http://127.0.0.1:17178/?method=test

gives me


RemoteServer is running (Sun Oct 22 23:24:16 IST 2017)
java.sql.SQLException: Connections could not be acquired from the underlying database!

followed by (after about a minute)...


RemoteServer is running (Sun Oct 22 23:19:48 IST 2017)
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

What could be the issue ?

Thanks for all the guidance you are giving me...
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi Erel,

I am attaching the zip file of the code that I am executing ..

And the Config.Properties file is:

#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.

#DATABASE CONFIGURATION
#DriverClass=com.mysql.jdbc.Driver
#JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
DriverClass=org.sqlite.JDBC
JdbcUrl=jdbc:sqlite:C:\temp\test.db
#User=root
#Password=
#Java server port
ServerPort=17178

#example of MS SQL Server configuration:
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<server address>/<database>

#example of postegres configuration:
#JdbcUrl=jdbc:postgresql://localhost/test
#DriverClass=org.postgresql.Driver

#SQL COMMANDS
#sql.create_table=CREATE TABLE IF NOT EXISTS animals (\
# id INTEGER PRIMARY KEY AUTO_INCREMENT,\
# name CHAR(30) NOT NULL,\
# image BLOB)
#sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
#sql.select_animal=SELECT name, image, id FROM animals
sql.create_table=CREATE TABLE article (id numeric(10,4) ,articleName text);
sql.select_article=select * from article where articleName=?
sql.insert_article=INSERT INTO article VALUES(?, ?)


I am executing RUNRLC.BAT in the background..


Ps. tell me where I am erring..

Thanks..
 

Attachments

  • RDCExample.zip
    8.6 KB · Views: 197
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi Erel,

I have used JRDC2 in the above example .. The subroutines that you have mentioned in your post where you have covered JRDC2 have been changed accordingly (in the Zip File).....

Can you post me / direct me to a link containing a complete working example of the said implementation ?

Thanks...
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Can you post me / direct me to a link containing a complete working example of the said implementation ?
1. Create a new project.
2. Add DBRequestManager module (Project - Add Existing modules)
3. Add the code from the tutorial:
B4X:
Sub CreateRequest As DBRequestManager
   Dim req As DBRequestManager
   req.Initialize(Me, rdcLink)
   Return req
End Sub

Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
   Dim cmd As DBCommand
   cmd.Initialize
   cmd.Name = Name
   cmd.Parameters = Parameters
   Return cmd
End Sub

Sub GetRecord (id As Int)
   Dim req As DBRequestManager = CreateRequest
   Dim cmd As DBCommand = CreateCommand("select_animal", Array(id))
   'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
   Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
   If j.Success Then
     req.HandleJobAsync(j, "req")
     Wait For (req) req_Result(res As DBResult)
     'work with result
     req.PrintTable(res)
   Else
     Log("ERROR: " & j.ErrorMessage)
   End If
   j.Release
End Sub

Sub InsertRecord (Name As String)
   Dim cmd As DBCommand = CreateCommand("insert_animal", Array(Name, Null))
   Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
   Wait For(j) JobDone(j As HttpJob)
   If j.Success Then
     Log("Inserted successfully!")
   End If
   j.Release
End Sub

You need to go over this code and understand it. If you have any question about the code then feel free to post it.
 
Upvote 0
Top