Android Question How can I connect B4A app to MySQL in Shared Hosting Server?

Diego Roman

Member
Licensed User
Hello, how can I use the new library JRDBC2 for MySQL to use it in a shared Hosting like Hostinger?
How can I run the B4J program that works as a server in Hostinger to be able to access it from a B4A application?
I don´t have VPS, how can I access MySQL with JRDBC2 in shared Hosting Server?
Thanks
 
Last edited:

josejad

Expert
Licensed User
Longtime User
Hi Diego.
You can’t, you need a VPS to run the jRDC2 server.
To connect to a sharing folder you need a webservice (i.e. with php or similar) or jdbcSQL access.
 
Upvote 0

Diego Roman

Member
Licensed User
Thanks José, but Basic4android SQL library is only for SQLite, I need connect with MySQL in Hostinger, please How can I do?
In the B4X forums there are many posts about connecting to databases, there are some very old ones, supposedly the best current way to connect to a database is through JRDBC2 but you say that it doesn't work on a shared server, then which one Is it the solution? In the forum they talk about many libraries and there are different versions, I am really lost, I don't really know how I should connect to MYSQL from B4X. Can you help me to know what is the method or library that I should use please?
 
Upvote 0

emexes

Expert
Licensed User
I don't think you need a VPS to run a MySQL database on your shared server with Hostinger. Just create the database, then connect via IP address. The shared server will be hosting other unrelated domains too, hence the (user id? domain id?) prefix for the database name and username.

Just had a poke around on my Hostinger account just now, looks like it should work ok:

 
Upvote 0

Diego Roman

Member
Licensed User
thank you emexes. The database is ready, but I don't know what is the library or method to access the database from B4X. JRDBC2 needs a VPN, but I only have Hostinger. And the B4A 'SQL' library only works for SQLite, which library or tool allows me to connect to MySQL from B4X?
thanks
 
Upvote 0

emexes

Expert
Licensed User
The database is ready, but I don't know what is the library or method to access the database from B4X.
I set up a test database but I don't have my usual tools on this laptop. I do have Libre Office which includes Libre Base, so I gave that a go, but now it's complaining:



and my better half is in the background reminding me that I have things to do here other than fiddle with MySQL so I'm going to have to bow out for now. ?

But it all looks like it should work, and forum posts like JDBCSQL Connector/J - Connect directly to MySQL, MSSQL, PostgreSQL, MariaDB and Oracle databases look like they head down the same path that you're on.
 
Upvote 0

emexes

Expert
Licensed User
I will look at the links you provided to see if I can find the correct way to do it, thank you very much.
I'd split the mission into two:
1/ first set up a test database on your Hostinger server, and make sure you can access it remotely from your computer
2/ then try access it from B4X
 
Upvote 0

Diego Roman

Member
Licensed User
I could already connect to MySQL. What I did was copy the B4J jSQL library in the B4A additional libraries folder and so far it has connected me well, I will continue doing more tests, but it seems strange to me that B4A does not bring by default a library to connect in a direct way to MySQL without having to depend on PHP, or it should have the jSQL library installed by default.

thanks a lot
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
It is existed but you need to read the disadvantages.

When the database is located far from clients, disconnection and timed out can happen easily. We need a middleware to manage the connection resources and security.

Since many cheap shared hosting have PHP installed, it is easier to use PHP. There are many tutorials in this forum.

Actually VPS is cheap nowadays. I use Hostinger VPS. If it is running on Linux, you need to learn to enter some commands but all the commands can be copy and paste from other tutorial.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…