• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Data Source problems

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

I have some problems with data source.
In that code:



PostgreSQL ignores username (and only username), in spite that it is set in property file:



It tries to connect via default systems username. Any ideas?
 
author & internet detective
Posts: 41502
881
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Denis,
Welcome to CodeRanch!

Let's first try to isolate it to a database vs Spring issue. Can see whether ${userName} is injected properly in XML? One way to do that is to create a "DenisTest" object and inject it there.
 
Denis Viktorov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for answer, Jeanne.

I found the problem. My config doesn't inject property when it names 'username'.
I changed name of property to 'pgUsername' and now it works perfectly.

And now I have another question: can somebody explain me why property with name 'username' don't work in my situation?

(sorry for bad English)
 
Denis Viktorov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, i understand the problem.

Spring 3.1 by default loads not only my properties, but also environment vars/props.

In my situations Spring loads windows environment variables and among them was 'username' variable, which overrides my 'username' property.


 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Denis Viktorov wrote:Okay, i understand the problem.

Spring 3.1 by default loads not only my properties, but also environment vars/props.

In my situations Spring loads windows environment variables and among them was 'username' variable, which overrides my 'username' property.




Yeah that is a funny gotcha that sometimes happens. The properties loader for context, was PropertyPlaceholderConfig. It will by default first look in the .properties file, then go to System.getProperty(), then look at OS environment variables, and use the first one it finds. That is by default. You can change that, you can flip the order, or you can tell it to just use the .properties file and look no further. Those are properties of the class that you can set in your configuration.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic