Hey,

I have a quick java question. I am building a Java application that uses an SQL database. I was wondering if it was possible to have this desktop application use the internet to connect to an SQL database setup on a remote server? This way the program data would be accessible by any computer with this application?

Thanks,
-Josh

Certainly. It's just a matter of using that url when you obtain the connection through DriverManager. There are examples of that with most JDBC drivers.

Thanks for your response. I have another question or two. I apologize for these - I'm trying to piece things together (the textbook for school doesn't explain this very well).

My server is setup with MySQL. I located the JDBC driver: for MySQL. I've read through my textbooks and some docs that I found online, but my answer still is not clear. Do I need to install this JDBC on my server with the database or on my computer with the java application? I'm just a little confused about what needs to go where in order to make this work.

Thanks,
-Josh

The Type 4 JDBC Driver for the MySQL database which you are talking about needs to be on the client, where your java application is running.
Its exactly like using third party java libraries in your program. The "jar" file needs to be in your classpath while you are compiling and running your program.

Josh also make sure that your database server is capable of external access, MySQL is often installed as local and cannot be accessed from outside world

peter_budo: thanks for that tip! I contacted my host and made sure that my MySQL is able to be configured for external access - it can be (and I went ahead and configured it).

stephen84s: Thanks a lot for your response. It was really helpful!

Thanks guys,
-Josh

This article has been dead for over six months. Start a new discussion instead.