Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,105 members, 7,814,882 topics. Date: Wednesday, 01 May 2024 at 09:53 PM

Connecting To A Remote Database(jdbc) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Connecting To A Remote Database(jdbc) (1789 Views)

Android App With Remote Database / Connecting To A Remote Database / Connecting To A Database Using Visual Basic (2) (3) (4)

(1) (Reply) (Go Down)

Connecting To A Remote Database(jdbc) by Fayimora(m): 9:01pm On Jul 03, 2011
Hey guys, just a little problem. How do you connect to a remote database that doesn't allow remote connections, lol Ok doesn't make much sense. You have a remote database that doesnt allow remote database connections, what are your alternatives given that you have to access that database?
Re: Connecting To A Remote Database(jdbc) by samm(m): 5:09am On Jul 04, 2011
Broad answer is Data Access layer using Web Services or custom assembly. An understanding of the environment will help provide better answer.
Re: Connecting To A Remote Database(jdbc) by Mobinga: 10:11am On Jul 04, 2011
remote database that doesn't allow remote connections

Remote? Make it allow connections.
Its hard to solve your problem with insufficient data. cool
Re: Connecting To A Remote Database(jdbc) by Fayimora(m): 10:24am On Jul 04, 2011
Haha i can't make it. My host(for ma site) doesn't allow remote connectionS. That means i can't. Connect to my database frm my local computer using my java code, i have to go online to access dat database. So wata a work around?
Re: Connecting To A Remote Database(jdbc) by Mobinga: 10:35am On Jul 04, 2011
Nope. I don't even know what you're talking about. tongue
Re: Connecting To A Remote Database(jdbc) by Fayimora(m): 1:46pm On Jul 04, 2011
hmm are you sure? what dont u understand?
Re: Connecting To A Remote Database(jdbc) by dellnet: 2:55pm On Jul 04, 2011
usually you should put a request to your host to whitelist your IP to connect the to the DB. I know CPanel have a feature called php mysql remote or something like that where you put your IP.
On the other hand if they absolutely do not allow remote connections then you need to create some sort of proxy script on the server to take your sql request, query the server and return the result.
Re: Connecting To A Remote Database(jdbc) by Fayimora(m): 3:01pm On Jul 04, 2011
Hmmm but i wanna access the database with a java software, gat any ideas? Am so lost,
Re: Connecting To A Remote Database(jdbc) by dellnet: 3:17pm On Jul 04, 2011
1. Proxy script
2. whitelist IP

In the proxy script just make a http request to it from your java software. The script will act as a connector i.e get query, query server, return result.
Re: Connecting To A Remote Database(jdbc) by wassolldas: 3:34pm On Jul 04, 2011
Just an idea, never had to do this before,

Use RMI to make access to the database available from your server. You need a port to use for the RMI registry.
Use RMI to obtain the access from your local machine,
Re: Connecting To A Remote Database(jdbc) by Fayimora(m): 3:37pm On Jul 04, 2011
Never used a proxy script and have never used the Java RMI before, ok so which do i go for now
Re: Connecting To A Remote Database(jdbc) by wassolldas: 3:41pm On Jul 04, 2011
proxy is probably less complicated. Don't know if your host supports java. To expose the interface through RMI, your host has to support java.
Re: Connecting To A Remote Database(jdbc) by dellnet: 3:52pm On Jul 04, 2011
Your problem indicate that your server does not allow remote IP, so you have to have 127.0.0.1 as your IP or the localhost IP. RMI is definitely a no.

A proxy script is just a self made script that will act as an intermediary in this case take sql query from your java application, query the webserver and return the result to your java application.

<?php
$query = $_REQUEST['query_java_app']; //HTTP post sql query.

//mysql connection settings goes here.

mysql_query($query);

mysql_fetch_array(); //get result

//echo result back to java application.
?>


Your application should parse and filter out the result.
Re: Connecting To A Remote Database(jdbc) by Fayimora(m): 4:06pm On Jul 04, 2011
Ok i think thats just what i need, When you gonna be on chat so we can talk more or do ou have any documentation for this online?
Re: Connecting To A Remote Database(jdbc) by dellnet: 4:42pm On Jul 04, 2011
URLConnection see class urlconnection for more info. This class should be able to handle the http communication between your application and the script on the web server. Imagine it as an n-tier application in this case 3 tier i.e the app, the script and the database.
Re: Connecting To A Remote Database(jdbc) by Nobody: 2:47am On Jul 05, 2011
use a tunnell. like in the above script
u may need to secure it though
Re: Connecting To A Remote Database(jdbc) by logica(m): 4:23pm On Jul 05, 2011
If it's a Java host, you can even have a servlet. It simply acts as a proxy similar to what dell_net suggested. All your JDBC code will be in the servlet, and you just expose some commands to the servlet (Command Pattern).

And yes, you can also similar use a web-service (but that's overkill).

(1) (Reply)

How does The Gocredit Feature Of The 2go App Work? / Any One With Win 10 Product Key / Asp.net Mvc Deployment

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.