Connecting to a Database in java

Hey everyone, this has been kind of blurry to to me for quite a while. I was wondering, what is needed to connect to a Java database…well not so much as “how do i do it” but for example, I created a program that let you type something, enter it and it sent it to the database and the next time you opened up the program it would read all the strings entered from other people or yourself. It all seemed to work fine until i gave my friend the executable Jar. When he ran it, nothing was displayed, which i guess meant it could not connect to the database (is it because its not local or something?)

But lets put it this way. (this has nothing to do with my old program)

I have a Database on my website (I used CPanel to create it) and I have the JDBC installed (not sure how to make sure i do have it installed but im pretty sure i do) but what is needed now for me to connect to my database?

If the database is provided by a web server hosting company, it’s usually behind a firewall (at least it would better be). Connecting to it would require creating a SSH tunnel for the database connection.

Remember that whoever can connect to the database directly, has also the permission drop all tables in the database (and to delete all files on your web site). It’s safer to create a PHP-frontend through which your program will access the data in the database.

Hmm ill check out that link, but im not sure what you mean by creating a php backend…Do you mean use the PHP file to read and write to the database and read the php file with the java application?