This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to set Integer value from property file to Spring configuration <property> tag

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can anybody help me out how could I get the integer value from property file and set in the spring configuration xml file .

I have one property file and the values on this property file are:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/myDb
jdbc.username=root
jdbc.password=password
jdbc.maxActive=50
jdbc.defaultAutoCommit=true


When I'm trying to get the jdbc.maxActive=50 value in my property file the application throwing exception .

In my xml file I am taking the value like this :

<property name="maxActive" value="#{new Integer('${jdbc.maxActive}')}" />



Thanks in advance ,
Sb



 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt if this is getting resolved to the String '50' as mentioned in the configuration - '${jdbc.maxActive}'

In any case I would do this parsing to Integer in the setter method of my bean.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:I doubt if this is getting resolved to the String '50' as mentioned in the configuration - '${jdbc.maxActive}'

In any case I would do this parsing to Integer in the setter method of my bean.



Mohamed , can you explain this a little more.

Sb
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need no parsing. Spring will parse for you. Just do this

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jayesh,
I have already tried that you are suggesting and am getting :



I like to add one strange thing here ,while am adding the auto commit property of type Boolean like this


Application is working with no compilation / runtime error .

I have tried by using the parseInt property of Integer in the spring El



Here am getting the exception :



Satya
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jayesh,
You are correct .I was getting the wrong property file and spring was throwing that exception.
Problem solved !!!.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!