An applet is Java code like any other code, so whatever you can do in a desktop application or a web app, you can do in an applet.
BUT, applets are only allowed to connect to the server where they are hosted. So if the database is not located on the same machine as the web server that hosts the applet itself, this won't work. Unless the applet is signed, about which you can find more information at
HowCanAnAppletReadFilesOnTheLocalFileSystem