B4J Tutorial Testing jRDC2 start to end on a VM

Discussion in 'B4J Tutorials' started by AymanA, Aug 14, 2019.

Tags:
  1. AymanA

    AymanA Member Licensed User

    Hi I have wrote this just in case someone needs to implement the jRDC2 on a VM on cloud, I know a lot of members already know this and it is definitely not a new information, but for someone that have not tried this before I think it will be useful to have a start to end process.

    Steps in brief:

    1 - Create a VM.
    2 - Install mysql.
    3 - Create a test database.
    4 - Download/install java on your VM.
    5 - Download mysql connector.
    6 - Edit the file config.properties.
    7 - Run the jRDC2.
    8 - Test the connection.

    Steps in details:

    1 - Create a VM:
    • Sure you can select the cloud vendor you would like, but for this example I am creating a VM on Digital ocean:
    https://m.do.co/c/ec09983edd71
    • Register on digital ocean.
    • Once you are logged in, select Create --> Droplet (VM is named droplet in their dashboard).
    • Choose the plan you would like, for my setup I have selected:
      • Ubuntu 18.04, Standard, 5$/month - this is for testing.

    upload_2019-8-15_0-32-2.png
    • Select the authentication method, I suggest try the One-Time password at the beginning if this is your first time to create a VM, once you are confident and find it easy, then start generating and adding ssh keys to your droplet while creating the VM, I find this more easier:
    https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/

    upload_2019-8-15_0-33-3.png

    If you do not have a linux OS, or do not know how to generate the keys, then you can use a mobile App named JuiceSSH to generate the keys (use at your own risk).
    • After following the steps on the email or used the ssh keys option, download and install a terminal emulator like putty, I personally I prefer mobaxterm since it provides a lot of features In one App:
    https://mobaxterm.mobatek.net/
    • Create a session and enter the IP of your VM in the Remote host on mobaxterm, in case you have used the ssh keys option, make sure to select the "use private key" --> browse to the file where you have saved the private key.

    Note: By default there is no users created on Digital ocean's VMs except the root user, if you think it is helpful to add these steps here, please let me know, for now we will be using the root user.

    2 - Install mysql:

    Please follow the link below to install mysql on your VM:

    https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04

    Some notes:
    • I didn't create another mysql user, I only used the root user.
    • Read carefully step 3, I have spent 2 hours trying to troubleshoot the error "java.sql.SQLException: Access denied for user 'root'@'localhost'" and turned out that I didn't follow this part where root shall have mysql_native_password instead of auth_socket!
    3 - Create a test database.
    • For jRDC2 example to work you need to have a database already in place named as test, so to create a database in mysql please follow the link below:
    https://www.digitalocean.com/commun...abases-in-mysql-and-mariadb-on-a-cloud-server

    4 - Download/install java on your VM:

    a. You can either download java and unzip it and upload to your server (steps are explained on the b4x link below:

    Source: https://www.b4x.com/android/forum/threads/server-run-a-server-on-a-vps.60378/#content

    b. Or you can install java on your VM:

    On ubuntu 18.04:
    $ sudo apt update
    $ sudo apt install default-jre
    $ sudo apt install default-jdk

    Source: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04

    Now we are finished with the VM part, let us work with the jRDC2 part.

    5 - Download mysql connector:

    https://dev.mysql.com/downloads/connector/j/

    Select Platform Independent --> Unzip/unar until you find the "mysql-connector-java-8.0.17.jar" (this is the current version on their site)
    • Copy "mysql-connector-java-8.0.17.jar" to your b4J additional library.
    6 - Edit the file config.properties:
    • Download the jRDC2 example on the link below --> Open the b4j file (jRDC file) --> File Manager --> open config.properties file --> edit the user and password to match the user and password that you have created on step 2.
    • Save and close the file.
    • On the b4j jRDC2 edit this part to match the sql connector version you have added to the b4J additional library:
    upload_2019-8-15_0-40-49.png

    https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/

    7 - Run the jRDC2.
    • Run the jRDC - b4j example in release mode in order to have the output file.
    • Copy jRDC2.jar file that is located in the objects in your project folder into the VM.
    • Mobaxterm is useful here as you already can ssh/ftp the file to your VM.
    • On the VM command line run:
    In case you installed Java on the VM you can run the below:
    $ java -jar <path to your jRDC2 file>/jRDC2.jar

    If not then:
    https://www.b4x.com/android/forum/threads/server-run-a-server-on-a-vps.60378/#content

    8 - Test the connection:
    • Open you PC browser and type: <VM_IP address>:17178/test
    Additional step after you test the connection, can be found on the link below to keep your jRDC2 server running even if the terminal was closed:

    https://www.b4x.com/android/forum/threads/server-run-a-server-on-a-vps.60378/#content

    Hope this is helpful! thanks
     

    Attached Files:

    Last edited: Aug 14, 2019
    Erel, yfleury, inakigarm and 2 others like this.
  2. AymanA

    AymanA Member Licensed User

    Apologies I will edit this seems a problem happened while editing!
     
  3. yfleury

    yfleury Active Member Licensed User

    I will use this tutorial next year after testing before I go to production
     
    AymanA likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice