How to hide JDBC connection credentials from git?

Started by Alexander Farberalmost 10 years ago2 messagesgeneral
Jump to latest
#1Alexander Farber
alexander.farber@gmail.com

Hello,

I work on several small Java projects (using Maven+NetBeans) and store them
in a public git repository.

I would like to use PostgreSQL JDBC in some of the projects, but don't want
to make the connection credentials of my database public.

Surely there are other developers out there, who have already faced similar
problem.

Please share your solutions.

It is probably possible to put the database name/user/password into a
*.properties file and then ignore it in git repository, but keep it in the
workarea?

Thank you
Alex

#2Szymon Guz
mabewlun@gmail.com
In reply to: Alexander Farber (#1)
Re: How to hide JDBC connection credentials from git?

On 31 May 2016 at 11:32, Alexander Farber <alexander.farber@gmail.com>
wrote:

Hello,

I work on several small Java projects (using Maven+NetBeans) and store
them in a public git repository.

I would like to use PostgreSQL JDBC in some of the projects, but don't
want to make the connection credentials of my database public.

Surely there are other developers out there, who have already faced
similar problem.

Please share your solutions.

It is probably possible to put the database name/user/password into a
*.properties file and then ignore it in git repository, but keep it in the
workarea?

Thank you
Alex

Usually I use either a separate config file, or environment variables
wrapped into a separate runner file. The properties file you mentioned is
quite a good idea.
Just remember to provide a template file, so other programmers could create
their own properties file without debugging the application. And document
how I should make my own properties file, and run the app.

--
regards Szymon Lipiński