• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it good idea to put secure type constants in the Interface and then Implements class?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am using database connection in my web-application I have declare database constants in an Interface as

public interface MyInterface{
public static final String JDBC_URL="";
public static final String JDBC_DRIVER="";
public static final String JDBC_USER="";
public static final String JDBC_PASS="";
}



and I am using these constants in my class like this

MyClass implements MyInterface


So my Question is it good Idea to declare these constants in an Interface or should I declare these constants Inside specific DAO class as Private variable?

Thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 7974
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't put them in code at all. Move them to a configuration file (or even a key store for your username/password) and write code to load them. Avoid hard-coding data.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!