Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properties file for DB connection

 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
''@'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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with Struts; moving.
 
Meena Rajani
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic