clear.choi
clear.choi

Reputation: 855

Java Security Database connection

Hi I have client java program that execute with jar file.

However that client program contain JDBC with user name and password.

I think it's not really good for security because everyone can decompile jar file.

Which one is best way to make JDBC connection string with secured module.

Program is built by Java version 1.6. Database is Sql-server.

Thank you!

Upvotes: 1

Views: 271

Answers (2)

Alexander Ivanov
Alexander Ivanov

Reputation: 2143

First what came to mind is usage of input dialog

String userName = JOptionPane.showInputDialog("Enter DB username");
String password = JOptionPane.showInputDialog("Enter DB password");
String connectionURL = "jdbc:sqlserver://localhost;user=" + userName + ";password=" + password + ";";

Upvotes: 0

colbyJax
colbyJax

Reputation: 1063

It is common practice to have user/password info contained within the source. If you are worried about people decompiling the code, you need to obfuscate the jar file.

Pro Guard is a good tool for this.

Here is another article from Stack Overflow that covers some of the best tools in detail: Best tool for jar or class obfuscation without need of writing any additional config file

Upvotes: 1

Related Questions