This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The applet may or may not be able to connect to the database depending on the constraints placed on the applet by the browser. The actual method is the same as for your application. If you get a security exception then the browser is preventing you from reaching the database. You may want to think about setting up a servlet to act as a proxy for the applet.