aspose file tools*
The moose likes JDBC and the fly likes Properties file for DB connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Properties file for DB connection" Watch "Properties file for DB connection" New topic
Author

Properties file for DB connection

Mahesh Lohi
Ranch Hand

Joined: Jun 22, 2009
Posts: 150
Hi all, I would like to use properties file to create connection to my mysql DB

My properties file



My Class file



Please let me know what the mistake is. I am getting an error like java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)

Thank you in advance
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

''@'localhost' (using password: YES)


You can see it is not getting the username and password

Have the url only separately.

And then add two more properties as,



It might work.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

This has nothing to do with Struts; moving.
Meena Rajani
Greenhorn

Joined: Sep 03, 2014
Posts: 1
you have to change

Connection con =DriverManager.getConnection(url, username, password);


and pass following properties in hello.properties file to the class

driver=org.postgresql.Driver
connectionurl = jdbc:postgresql://localhost:5432/test
username=xxxxxx
password=xxxxx
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Properties file for DB connection