The password must be exposed to the application, that's for sure, otherwise how is your application connect to the DB?
But this is not a big security flaw. The machine where the application runs is what must be secure at all costs. This is the main thing! If a hacker or even a naive user has access to the machine where the application runs, they could wreck havoc in your systems even without knowing much at all if they have enough privileges. Once a person has access to your application's source code AND to the machine it's running on, there's just no way in the world you can make it secure, unless maybe if you have a very good user account management system.
You can externalize the password to a text file and store it hashed, maybe even with a salt, which is basically the best/most used way I know of... but this just makes the life of someone who has access to your machine slightly harder... having access to the source code they can still break into your database if they are smart, or if they are not, they can simply delete or corrupt it.
So there's nothing wrong with JDBC... if you disagree, please convince the millions of users of JDBC otherwise. Security is not something you build on a single technology. It involves protecting ALL of your systems and adding layer after layer of protection at each different node, but beware that each layer of protection compromises more and more usability and flexibility (this is the reason people don't just add 1000 layers of passwords on top of an application/database, it's just impractical and mostly unnecessary, even).