0

I am developing a desktop application. Multiple users shall be using it to insert, delete and select data from database. As users shall be using it so they would not have to login to database.

I know how to use JDBC (for Java Applications), I need suggestions that I don't want to hard code the credentials of database like host address, username, password ... etc. So if change of credential is needed I can change it without changing the code. Also, I cannot just put database credentials in a text file and read every time when the application need to interact with database.

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69

1 Answers1

-1

You can create a ApplicationConstants file which will store the host address, username and password.

If you need to change it you'll have to change it only in one location.

But this will require you to compile the code everytime you make changes.

The alternative is to encrypt the values and store the encrypted values in a text file.

You can use the javax.crypto for encryption/decryption. You can find an example on the following link :

Simple java AES encrypt/decrypt example

Community
  • 1
  • 1
Joyson
  • 3,025
  • 1
  • 20
  • 34
  • Thanks for your response. 2nd option of encryption sounds OK for me. I am developing in Java, can you please guide me that is there any java library or anything from where I can take start for encryption. – Waleed Khan Feb 12 '16 at 06:13
  • You can use javax.crypto for the encryption part. I have updated the answer with a link to an example. Hope it helps. – Joyson Feb 12 '16 at 07:32