Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:40:01+00:00 2026-06-10T11:40:01+00:00

Hello guys I’m quite new at Web Development and I’m stuck on a problem

  • 0

Hello guys I’m quite new at Web Development and I’m stuck on a problem here. I want my java program to connect to a database using Jdbs connector but instead of hard coding the database variables I want my program to read an xml file where the values are stored in beans. The lines I want to be read are stored in applicationContext.xml file as follows:

<bean id="ObjectMapperFactory" scope="singleton" class="someClass"/>
<bean id="UgcDataSource" class="org.apache.commons.dbcp.BasicDataSource">
 <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
 <property name="username"><someUser</value></property>
 <property name="password"><somePassword</value></property>
 <property name="url"><value>jdbc:mysql://localhost:3306/dbName?autoReconnect=true</value></property>
 <property name="defaultAutoCommit"><value>false</value></property>
 <property name="maxActive"><value>20</value></property>
 <property name="maxIdle"><value>3</value></property>
</bean>

And after reading it I want these variables to be stored in strings as such:

String url = "jdbc:mysql://localhost:3306/dbName"
String username = "someUser"
String password = "somePassword"

So what I’m looking for is a way to extract those 3 values, any suggestions? Much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:40:03+00:00Added an answer on June 10, 2026 at 11:40 am

    With Spring you can use the @Value Annotation like so

    @Value("#{UgcDataSource.url}")
    private String url;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys im having little problem here, Firstly i want to parse string which
* Hello Guys..! * Normally a java program needs main() function to execute the
Hello guys I have a problem with my application involving Lucene java library and
Hello guys I am stuck at a point and i want ur help.First of
Hello guys maybe you maybe can help . here is my problem For example
Hello guys I am new to Spring MVC and i want to create a
Hello Guys! I want to access some web page through python script. The url
Hello guys I'm stuck with this weird problem , asp:HyperLink control is not being
Hello Guys! I started learning python GUI development. Let's say I have this script:
Hello guys! Here: #include <stdio.h> char* getStr( char *c ){ scanf( %s , c

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.