Is this Java thing running from on the DreamHost server, on a remote server that you control, or inside a user’s browser?
If it’s running from on a DreamHost server, then there’s probably not much I can do except tell you to make sure that your syntax is right and that you’re using the right username and password. Someone with a bit of Java applet experience could probably do better, but that someone is not me
If it’s running on a separate server that you control, then the reason for the access denied error might be that your server is not in the list of servers which MySQL will accept connections from. By default, for security reasons, DreamHost only allows connections to MySQL from DreamHost servers. You can add your own server by going to your web control panel under Manage -> MySQL, clicking the name of your MySQL user, and adding your server to the “Allowable Hosts” section.
If this is running inside a user’s browser, then I strongly suggest you find a different method. To begin with, you’ll have the exact same problem as using your own server with regard to where connections are being allowed from, but you won’t have the single easily identifiable server to add as an allowable host. While it is possible to open access to everyone, that comes with major security risks. Even more importantly, it is a very bad idea to make your password accessible from the user’s browser. Passwords of that sort should always be kept server-side in an environment you control.