JDBC over SSH?

I have a shared web hosting plan with a web hosting provider. They provide typical web server, PHP, MySQL, etc as well as the ability to SSH in to my account, but no JVM on the server. I have a web app on that server that stores a bunch of data in MySQL.

I'd like to write a Java app, which I'd run locally on my dev machine, that would use JDBC to connect to the MySQL database on my shared web host. The problem is that the MySQL server, for security reasons, doesn't accept remote connections.

I can SSH to the shared server and access MySQL via command-line. Is there any way to setup an SSH connection that JDBC can use, so I can access that MySQL database remotely?

[693 byte] By [zcox123a] at [2007-11-27 4:09:09]
# 1
No. I give you an A for effort because it's a creative-hacky idea but no and don't waste your time on it.
cotton.ma at 2007-7-12 9:14:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I'm not sure you're right. It's possible to use ssh to establish tunnels between hosts. Depending upon his account access it may actually be possible for him to do this!

That said there are probably better solutions to whatever the fundamental problem he's trying to solve is (e.g. rich admin client for this web app probably implies a need for SOA).

dcmintera at 2007-7-12 9:14:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
dcminter - do you know how to establish an ssh tunnel that JDBC can use?
zcox123a at 2007-7-12 9:14:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Look, as cotton so rightly intimates, it's going to be an almighty pain in the butt to do this if it's even possible (it depends on what privileges and constraints you have on your environment). I really don't recommend it either.

You have a task you need to achieve. That task is not "communicating with the database over ssh to subvert the mean restrictions placed on me by my hosting provider." It's something like "administrate certain tables required by my web application" or "experiment with JDBC on MySQL" or "use my nice GUI to design the database instead of the command line."

Tell me what the actual task is and I'll advise you on the best way to achieve it. Don't be blinkered by your preconceptions about the implementation.

dcmintera at 2007-7-12 9:14:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
You can run a Java SSH client library such as http://www.jscape.com/articles/ssh_using_java.html and then send MySQL commands. OK, this is not JDBC but it will allow you to interact with your MySQL database. P.S. There are several other Java SSH client libraries. Google is your
sabre150a at 2007-7-12 9:14:33 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...