I make large use of b4j servers so this may help you.
B4j server is a non-ui object so you can install it wherever JRE (8.40+ if I recall well) goes. This "java requirement" means that you generally can't deploy it on a shared hosting server because on those plans you're not allowed to install/activate java. But if you run your own hw server or make use of a VPS plan (there are cheap ones), you can easily deploy a b4j server.
It will be the responsability of the b4j component to access your database (I use mainly MySql) because for security reasons you won't expose the DB on the Internet. In order to do so, use the ConnectionPool object to make your server talk to your DB.
Just to share an idea: in my case I have my B4A apps to query a server-module that I named "dispatcher"; its use is to verify credentials and return the full address of the b4j server needed for that specific program. This way I'm free to move my b4j server from physical server to physical server not touching my mobile apps. And, even decompiling those apps, you end up just with the dispatcher address, nothing more.
udg