B4J Tutorial [NOT YET A TUTORIAL] How to set up and run your B4J based RDC server from SCRATCH

Hi Guys...

So, This hopefully will become a tutorial about how to set up and run your B4J based RDC server on your vps...
This tutorial is aimed at those that, like me, take their very first steps in VPS management and RDC.

There are a few tutos provided by EREL, but they are aimed at those that know already a few things about this subject.
They are:
https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.59251/
https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/

So, lets Start!

I got myself a shining new VPS at 1 and 1 and set it up with basic functionalities...
Along with the VPS, I registered a Domain name...
It was not straight forward to make the domain name point to the vps IP but thanks to @Enrique Gonzalez R I managed to do it. He also helped me setting up a Test Database and to connect to it using HeidiSQL.

So now, I would Like to be able to inquire my Database from a B4x app, (J & A), so I chose RDC for it... BUT, HOW DO I IMPLEMENT SUCH A FEATURE? (Remember, all this is NEW to me!)

Gathering tools:
Erel kindly pointed me to start by installing WampServer, wich I did...
So... checked!
What now?
 
Last edited:

Harris

Expert
Licensed User
Longtime User
Hi Guys...

So, This hopefully will become a tutorial about how to set up and run your B4J based RDC server on your vps...
This tutorial is aimed at those that, like me, take their very first steps in VPS management and RDC.

There are a few tutos provided by EREL, but they are aimed at those that know already a few things about this subject.
They are:
https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.59251/
https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/

So, lets Start!

I got myself a shining new VPS at 1 and 1 and set it up with basic functionalities...
Along with the VPS, I registered a Domain name...
It was not straight forward to make the domain name point to the vps IP but thanks to @Enrique Gonzalez R I managed to do it. He also helped me setting up a Test Database and to connect to it using HeidiSQL.

So now, I would Like to be able to inquire my Database from a B4x app, (J & A), so I chose RDC for it... BUT, HOW DO I IMPLEMENT SUCH A FEATURE? (Remember, all this is NEW to me!)

Gathering tools:
Erel kindly pointed me to start by installing WampServer, wich I did...
So... checked!
What now?

This is where it gets grey...

On Windows servers
, I HAD to employ a product called AlwaysUp. ( https://www.coretechnologies.com/products/AlwaysUp/ )
It is a windows service (and manager). It will start as a true service and manage all of the rest (which are not services) AS (sudo?) services.

On server (re) boot, AlwaysUp (which is a service) would start (batch file, jar, exe) just like a windows service - other apps - and watch and maintain it.

I tried other methods on a Windows server with no success.

THIS IS WHY LINUX is so much better suited for web.
Learn it, love it and enjoy the freedom (I certainty do - when possible (some clients want win - un-educated) ).

Thanks
 

Cableguy

Expert
Licensed User
Longtime User
My web based vps is running Linux (centos OS 6), I installed locally (my PC) wamp according to Erel's suggestion...
Awaiting further instructions...
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
So the best approach is to replicate my "real" DB
 

Cableguy

Expert
Licensed User
Longtime User
Ok, so, I may have not been clear enough about my issue...

I HAVE A WEBHOSTED VPS ( at 1 and 1), running Centos OS 6, Apache, PHP (with MyPHPAdmin).
This is where I will have my "REAL" DB and to/from where I need doing RDC.
Still, the idea of "replicating" the webhosted enviromemnt locally for dev purposes does appeal me, so I will keep the Wamp server installed locally...

Getting back to subject...
I have a DB (MySQL) named PAL22 that, for now, only has a single table with 3 columns, being that one of them is auto-incremental.
I can access this DB using HeidiSQL.
SO now, and this is what I can't figure out exactly what to do, is how to install, configure and run the B4J RDC server.

BTW, the vps is already hosting a website (just a "here I am" page) at www.pg-engineering.net
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Download jRDC2.
2. Open Files\config.properties with a text editor.

You will see something like:

SS-2016-12-18_14.51.08.png


You need to update the User and Password fields.

RDC will listen on the ServerPort (17178). This means that this port should be open in the server firewall.

You should configure the SQL commands based on your tables and requirements.

3. Run the project locally in Release mode. It will create the jar file and will fail.
You will need to add #AdditionalJar: mysql-connector-java-5.1.27-bin (or similar based on the connector version).
If you haven't downloaded the driver before then download it and copy the jar to the additional libraries folder: https://dev.mysql.com/downloads/connector/j/

4. Upload the jar file to your server.

5. Run the jar file explained here: https://www.b4x.com/android/forum/threads/server-run-a-server-on-a-vps.60378/#content
 

Cableguy

Expert
Licensed User
Longtime User
I did what was proposed in the above post, except for the running the server (jar file) since ssh connection takes me straight into "Plesk command line only" mode...
Any hints?

PS. I also have plesk web based access, but I can't find where to run a jar
 

Cableguy

Expert
Licensed User
Longtime User
So I managed to work out why I had no rights in PLESK in SSH...
Now I can navigate my domainname space and the folders within
I tried to run the NoHup command line, but am getting a permission denied message at the end

-sh-4.1$ sudo nohup /var/www/vhosts/pg-engineering.net/java8/jre1.8.0_112/bin/java -jar jRDC.jar > nohup.out &
[1] 50357
-sh-4.1$ -sh: nohup.out: Permission denied
 

Cableguy

Expert
Licensed User
Longtime User
so, another update on this...

After a lot, and I mean, A LOT, of fiddling and trial and error, I decided to download the .rpm file version of the JAVA jre and then ftp it to a folde in the server...
Runned a yum command like
sudo yum localinstall jdk-8u112-linux-x64.rpm
and decompiled it to /usr/bin/java (by default)

I then ran a few "alternatives" commands just to be on the safe side... this creates alias if I understand correctly, so I only need to type Java -jar instead of the complete path to the "/bin/java"

When I try the mohup command I still get the same error BUT if I run the Java -jar jRDC.jar it runs!!!

-sh-4.1$ java -jar jRDC.jar
2016-12-18 21:05:39.594:INFO::main: Logging initialized @193ms
Dec 18, 2016 9:05:39 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
Dec 18, 2016 9:05:39 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]
2016-12-18 21:05:40.086:INFO:eek:ejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-12-18 21:05:40.180:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@7c16905e{/,file:///var/www/vhosts/pg-engineering.net/MyRDC/www,AVAILABLE}
2016-12-18 21:05:40.184:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened /var/www/vhosts/pg-engineering.net/MyRDC/logs/b4j-2016_12_18.request.log
2016-12-18 21:05:40.215:INFO:eek:ejs.ServerConnector:main: Started ServerConnector@41f4c8d2{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2016-12-18 21:05:40.217:INFO:eek:ejs.Server:main: Started @818ms
jRDC is running (version = 2.1)

So I just need to figure out why the nohup command fails...
 

Cableguy

Expert
Licensed User
Longtime User
BY GOD I THINK I'VE DONE IT!!!!!

-sh-4.1$ nohup java -jar jRDC.jar > nohup.out &
[1] 54677
-sh-4.1$ nohup: ignoring input and redirecting stderr to stdout
 

Harris

Expert
Licensed User
Longtime User
Linux is fun... once you understand it.

Fortunately, there are only a few things we must understand to make it work for us.

Like automatically starting the RDC jar after a reboot of server. I shall have to dig and study for this since @warwound set this up for me so many years ago.

If you reboot your server, you may find RDC didn't run... or your jar...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
After a lot, and I mean, A LOT, of fiddling and trial and error, I decided to download the .rpm file version of the JAVA jre and then ftp it to a folde in the server...
Runned a yum command like
Another option is to download the Linux JRE to your PC and then upload it to the server. Java doesn't need to be installed.
 

Cableguy

Expert
Licensed User
Longtime User
Another option is to download the Linux JRE to your PC and then upload it to the server. Java doesn't need to be installed.
I was having problems decompressing the tar.gz file as I was always getting 3 files at 0k, so I decided to opt for the rpm file and to decompress in the vps
 

Cableguy

Expert
Licensed User
Longtime User
I tried to find how to unzip as admin but didn't find it so I forked the road
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
One of the best things of Linux is that they have repositories, easy to find, easy to install. I use ubuntu so i do not know the specifics for Cent Os, but this should help:

https://www.digitalocean.com/community/tutorials/how-to-install-java-on-centos-and-fedora

----

I just installed a webserver on a ubuntu machine without the need of Nohup, how? easy, if you run it with a graphical interface (linux desktop with XRDP) you will have access to several terminal GUI, just run: sudo java -jar yourJar.jar AND THATS ALL, you can exit linux without the worries of your server going down just dont close the terminal because if you do the service will be killed.
 
Top