LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Web app - multiple database connections (https://www.linuxquestions.org/questions/linux-software-2/web-app-multiple-database-connections-738378/)

nbcohen 07-07-2009 01:02 PM

Web app - multiple database connections
 
I have been building some web applications (using Netbeans) that access a MySQL database using Hibernate on the server. Works fine. But I have a new application that has a local database and one of the tables contains a list of remote databases that I need to access. I'm not sure of the correct way to connect to and manipulate those remote databases. The remote systems are also mysql databases, and I just need to add/update/delete information from them. Don't need to do anything complicated like joins or searches - at least not at the moment.

Can someone point me at either some sample code or a tutorial that would get me started? Do I want to try to use Hibernate for the remote access or just open a jdbc connection and use sql statements across the net?

Thanks in advance,

nbc

jlinkels 07-07-2009 04:44 PM

MySQL supports connections from other hosts. For most languages a MySQL connector exists where you can specify both the host and database on the host. When you have made a connection, the connector function usually returns a handle which can be used for further references to that connection.

It seems to me that Hibernate is no different as you have to specify the host when making a connection, but the Hibernate documentation should make that clear.

If you access the remote databases make sure the access rights in those databases are set correct for remote access. This is not normally so by default, each [range of] host[s] must be allowed explicit access in the database.

jlinkels


All times are GMT -5. The time now is 11:59 PM.