B4J Question jRDC2 Example Not Working

Stefano Di Chiano

Active Member
Licensed User
Hi everyone,
I followed the tutorial of jRDC2 step by step (this one to be clear). In the tutorial the two spinners are loaded with the list of cities and countries retrieved by sql. On my screen nothing happen. The two spinners are empty. No error is shown in the logs (neither B4A client's logs nor B4J server's logs).
To provide some more information I'll write what I did step by step, this way it should be easier to see where I did something wrong:
So, first I downloaded the jRDC2 server from the tutorial page and I made a B4A project for the client. I downloaded the mysql connector jar file (mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin) and I put it into the libraries folder (I tried to put it into the additional libraries folder, but on running I received an error message telling me to put it in the libraries folder).
Then I added in the B4J project with the following lines:
B4J:
#AdditionalJar: mysql-connector-java-5.1.49-bin
#AdditionalJar: mysql-connector-java-5.1.49
On the config file I set the following parameters:
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
User=root
Password=
#Java server port
ServerPort=17178
I ran wampserver and the B4J server. On localhost it says it's running, no error appeared.
Then I just followed the video tutorial adding the layout, the RandomAccessFile and okHttpUtils2 libraries and all the code snippets from the tutorial page and made the changes shown on the video. The database too of course on phpmyadmin.
I also tried with xampp and mariadb connector but nothing changes.
I'm unsing B4A v10.0 and B4J v8.50. I'll share both the B4A and the B4J projects.
The server runs without errors, the client too, but something is clearly not working. What am I missing?
 

Attachments

  • jRDC_Server.zip
    70.5 KB · Views: 121
  • jRDC2_Client.zip
    205.7 KB · Views: 125
Last edited:

Stefano Di Chiano

Active Member
Licensed User
B4A logs:
Logger connected to: 4TE7N17829003978
--------- beginning of crash
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **

B4J logs:
Waiting for debugger to connect...
Program started.
2020-07-31 10:43:25.069:INFO::main: Logging initialized @582ms to org.eclipse.jetty.util.log.StdErrLog
lug 31, 2020 10:43:25 AM com.mchange.v2.log.MLog
INFORMAZIONI: MLog clients using java 1.4+ standard logging.
lug 31, 2020 10:43:25 AM com.mchange.v2.c3p0.C3P0Registry
INFORMAZIONI: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2020-07-31 10:43:26.044:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_251-b08
2020-07-31 10:43:26.102:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2020-07-31 10:43:26.102:INFO:oejs.session:main: No SessionScavenger set, using defaults
2020-07-31 10:43:26.104:INFO:oejs.session:main: node0 Scavenging every 600000ms
2020-07-31 10:43:26.111:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@1a1d6a08{/,file:///C:/Users/Stefano/Desktop/jRDC_Server/Objects/www,AVAILABLE}
2020-07-31 10:43:26.117:INFO:oejs.AbstractNCSARequestLog:main: Opened C:\Users\Stefano\Desktop\jRDC_Server\Objects\logs\b4j-2020_07_31.request.log
2020-07-31 10:43:26.138:INFO:oejs.AbstractConnector:main: Started ServerConnector@262b2c86{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2020-07-31 10:43:26.138:INFO:oejs.Server:main: Started @1655ms
Emulated network latency: 100ms
jRDC is running (version = 2.22)

On the test url it says:
RemoteServer is running (07/31/2020 10:45:11)
Connection successful.
Same from the device browser.
 
Upvote 0

Stefano Di Chiano

Active Member
Licensed User
Ok, I changed it, now I get the following error in the B4A logs:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.cities' doesn't exist, Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table &apos;test.cities&apos; doesn&apos;t exist</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table &apos;test.cities&apos; doesn&apos;t exist</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
ERROR: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table &apos;test.cities&apos; doesn&apos;t exist</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table &apos;test.cities&apos; doesn&apos;t exist</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>

and this in the B4J logs:
Waiting for debugger to connect...
Program started.
2020-07-31 10:56:00.352:INFO::main: Logging initialized @564ms to org.eclipse.jetty.util.log.StdErrLog
lug 31, 2020 10:56:00 AM com.mchange.v2.log.MLog
INFORMAZIONI: MLog clients using java 1.4+ standard logging.
lug 31, 2020 10:56:01 AM com.mchange.v2.c3p0.C3P0Registry
INFORMAZIONI: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2020-07-31 10:56:01.376:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_251-b08
2020-07-31 10:56:01.434:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2020-07-31 10:56:01.434:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2020-07-31 10:56:01.436:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2020-07-31 10:56:01.443:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@1a1d6a08{/,file:///C:/Users/Stefano/Desktop/jRDC_Server/Objects/www,AVAILABLE}
2020-07-31 10:56:01.449:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Users\Stefano\Desktop\jRDC_Server\Objects\logs\b4j-2020_07_31.request.log
2020-07-31 10:56:01.469:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@262b2c86{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2020-07-31 10:56:01.470:INFO:eek:ejs.Server:main: Started @1686ms
Emulated network latency: 100ms
jRDC is running (version = 2.22)
lug 31, 2020 10:56:42 AM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
INFORMAZIONI: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge4ykab19j02h4yv7adh|7bb11784, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge4ykab19j02h4yv7adh|7bb11784, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost/test?characterEncoding=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxI...
(MySQLSyntaxErrorException) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'test.cities' doesn't exist
Command: , took: 445ms, client=192.168.20.120
 
Upvote 0

Stefano Di Chiano

Active Member
Licensed User
I made the example database with the cities table as shown in the video tutorial, but where is it specified to use that db instead of others? Cause correct me if I'm wrong, but it looks like it is connecting to the default 'test' database, which has no table inside.
 
Upvote 0

Stefano Di Chiano

Active Member
Licensed User
But Erel in his video tutorial just added a new db and everything worked, he didn't have to rename the test db. I could do as you say, but I feel like there's something else wrong here.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Anyway, I did as you say and it doesn't work. It seems that it looks for a db named 'test', so i think there is a setting somewhere that specify that.
On the config file I set the following parameters:
JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
The JdbcUrl configuration parameter determines the db you connect to (see the test in the configuration string). Please note: If you change any settings in the config.properties file, you have to recompile the jRDC2 server
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Sorry, I think I didn’t write clearly. I mean if you use other db name let say countrydb then your jdbcUrl should be change accordingly.
B4X:
JdbcUrl=jdbc:mysql://localhost/countrydb?characterEncoding=utf8
 
Upvote 0
Top