• Post Reply Bookmark Topic Watch Topic
  • New Topic

Proper way to connect DB  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using

connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test1", "user", "");

There is amore elegant way?

I mean instead of this

jdbc:postgresql://localhost:5432/test1", "user", ""

using for example an external file to pass the values localhost:5432/test1, user ,etc?

Thanks
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can define your own local file to connect to the database so that the paths are not hard-coded into an application. There are also many frameworks that allow database parameters be defined in XML, although you don't need to introduce an entire framework if creating your own properties file or XML file will suffice.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!