Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting properties from xml beans into java
    primarykey
    data
    text
    <p>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:</p> <pre><code>&lt;bean id="ObjectMapperFactory" scope="singleton" class="someClass"/&gt; &lt;bean id="UgcDataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt; &lt;property name="driverClassName"&gt;&lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;&lt;/property&gt; &lt;property name="username"&gt;&lt;someUser&lt;/value&gt;&lt;/property&gt; &lt;property name="password"&gt;&lt;somePassword&lt;/value&gt;&lt;/property&gt; &lt;property name="url"&gt;&lt;value&gt;jdbc:mysql://localhost:3306/dbName?autoReconnect=true&lt;/value&gt;&lt;/property&gt; &lt;property name="defaultAutoCommit"&gt;&lt;value&gt;false&lt;/value&gt;&lt;/property&gt; &lt;property name="maxActive"&gt;&lt;value&gt;20&lt;/value&gt;&lt;/property&gt; &lt;property name="maxIdle"&gt;&lt;value&gt;3&lt;/value&gt;&lt;/property&gt; &lt;/bean&gt; </code></pre> <p>And after reading it I want these variables to be stored in strings as such:</p> <pre><code>String url = "jdbc:mysql://localhost:3306/dbName" String username = "someUser" String password = "somePassword" </code></pre> <p>So what I'm looking for is a way to extract those 3 values, any suggestions? Much appreciated! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload