B4J Question [Solved] Recompile JRDC2 after modify config.properties?

aeric

Expert
Licensed User
Longtime User
Hi,
I just purchased a cheap VPS. I selected Ubuntu 18.04 and start installing all necessary software from scratch.
I try to deploy my JRDC2 app and it runs on ip address and port 17178. I uploaded the jar file and www (static files/assets) folder using FTP.

Now my question is the config.properties compiled into the jar file?

Is that mean every time I modify the content of this file then I need to recompile the jar?
 

OliverA

Expert
Licensed User
Longtime User
Yes. It's part of its security. No external accessible config file. You have the source though and can modify it to take an external file and to look for new sql statements
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Now my question is the config.properties compiled into the jar file?
Yes, as it is a file in the Files Folder.
Is that mean every time I modify the content of this file then I need to recompile the jar?
This is one possible solution.

Another one is to edit your RDCConnector and change the sub LoadConfigMap to load it from anywhere else

B4X:
Private Sub LoadConfigMap As Map
    Return File.ReadMap(File.DirAssets, "config.properties")
End Sub

It shouldn´t be a Public accessible folder though as @OliverA already mentioned it would be a security risc.

The Files folder and even the jar are probably NOT in a public space on your server (hopefully :D). So you should be fine with using the Files folder.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Yes. Please realize, you still have to stop/start the jRDC2 process in order to read any changes in the file. For testing purposes, I just have another server handler (that you can reach via /restart) that I can use to restart the server. Main is rewritten to work with the handler.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Yes. Please realize, you still have to stop/start the jRDC2 process in order to read any changes in the file. For testing purposes, I just have another server handler (that you can reach via /restart) that I can use to restart the server. Main is rewritten to work with the handler.
I would not store important server settings inside the file that related to the RDC server.
I may use the file to store other settings such as mysql and smtp user name and password or values that will be replaced in the html page. The purpose of the file is like config.php in my PHP web api system.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please realize, you still have to stop/start the jRDC2 process in order to read any changes in the file. For testing purposes, I just have another server handler (that you can reach via /restart) that I can use to restart the server.
You can configure to read the propertiesfile each time before handling a request.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
You can configure to read the propertiesfile each time before handling a request.
Yes. Let say I can access http://127.0.0.1:17178/test/readini to read the file.
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
    Select req.RequestURI
        Case "/test/sendemail"
            Utility.SendEmail
        Case "/test/readini"
            Dim m As Map = Utility.ReadMap("appsetting.ini")
            Log(m.Get("SMTP_SERVER"))
        Case Else
            Dim Map1 As Map = CreateMap("result": 1, "message": "success")
            resp.ContentType = "application/json"
            resp.Write(Utility.Map2Json(Map1))
    End Select
End Sub

*Utility is a code module where I put all my reusable functions.
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Note the Comments about Debug=true
That must be one of your mods. The source of jRDC2 only turns the reloading of the SQL statements on if jRDC2 is ran in Debug mode of the IDE. At least this is how it is in the jRDC2 2.21 source.

I'm leaving the statement above, but it's actually not @DonManfred's mod. It's on the page for jRDC2. Something must have happened along the line, since it is not part of the source distro (nor has it been for a long time, since none of the sources I have have it).
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Actually I don't understand how the Debug=true works.
"Debug - Option not used any more. It is automatically enabled when you run the server in debug mode (from the IDE). "

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
You must separate the Connections (Pool) from the requests.

you have to modify the JRDC2 server.

so you can add or edit requests without restarting JRDC2.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Actually I don't understand how the Debug=true works.
In release mode, we can't modify the settings.
In debug mode, I prefer to stop the execution, modify the sql queries and run debug again.

tell me what you have done to help modify JRDC2.
We already did what you are looking for.
and I'll tell you what to modify in JRDC2, to add or edit requests without rebooting
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Hi,
I just purchased a cheap VPS. I selected Ubuntu 18.04 and start installing all necessary software from scratch.
I try to deploy my JRDC2 app and it runs on ip address and port 17178. I uploaded the jar file and www (static files/assets) folder using FTP.

Now my question is the config.properties compiled into the jar file?

Is that mean every time I modify the content of this file then I need to recompile the jar?
With this, the config.properties file is available in the applications directory

Private Sub LoadConfigMap As Map
File.Copy(File.DirAssets, "config.properties", File.DirApp, "config.properties")
Return File.ReadMap(File.DirApp, "config.properties")
End Sub

1590913253465.png
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I recommend 2 files.

1. (config.connections) Connections config file (POOL)
2. (config.sql) Requests file (SQL)

file config.sql to edit or add SQL requests

so you don't have to restart the JRDC2 server
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I recommend 2 files.

1. (config.connections) Connections config file (POOL)
2. (config.sql) Requests file (SQL)

file config.sql to edit or add SQL requests

so you don't have to restart the JRDC2 server
Yes, I am also thinking to use a separate file to handle the sql so we do not need to recompile and restart the jrdc server. But this will less secure if "someone" can access my files and modify the sql file.

Maybe another idea is to store the queries in database?
My thought is the following: if I store the query texts into a database table and fetch them as needed, I will avoid the source code changes if something in a query being changed and I will achieve any change without restarting the application!
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
But this will less secure if "someone" can access my files .

can encrypt the file:

Example:

File.WriteBytes
File.ReadBytes

or use



Maybe another idea is to store the queries in database?

if it's better, but they can also access their database or use KVS2
 
Upvote 0
Top