2

I am using SQLite JDBC driver from xerial project.

Can i secure my sqlite db using username & password with java? If yes, how?

Any help is appreciated.

Thanks in advance.

2

1 Answer 1

1

I do not know, is this answer necessary for you now? But hope this answer can help other people, who have faced kind of similar problems.

  • First of all, The base SQLite engine doesn't have any password/encryption options. So you can not set a username and password.
  • As base SQLite does not include an encryption option. That is available as a paid option (SEE) from the suppliers of SQLite, or there are other 3rd party options available.
  • For JDBC especially, you can follow this github repository. Here you find the way around to secure your SQLite DB. In their Readme file, you will find this code-block, how they create their DB Connection string. But before this, you have to configure encryption mode.
//Using the SQLiteMC default parameters
Connection connection = DriverManager.getConnection("jdbc:sqlite:file:file.db", new SQLiteMCConfig().withKey("Key").toProperties());
Connection connection = new SQLiteMCConfig().withKey("Key").createConnection("jdbc:sqlite:file:file.db");

//Using Chacha20
Connection connection = DriverManager.getConnection("jdbc:sqlite:file:file.db", SQLiteMCChacha20Config.getDefault().withKey("Key").toProperties());
Connection connection = SQLiteMCChacha20Config.getDefault().withKey("Key").createConnection("jdbc:sqlite:file:file.db");
  • As you use JDBC, that means your application is java based, in that case, H2 DB will well suit your application. It has strong security features.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.