Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do Migrate Java, Spring Project to use JNDI datasources
    primarykey
    data
    text
    <p>I have a Java project that runs from the command line. It is using Spring. At the current time my project is mySQL. Use can see from the config.xml below</p> <pre><code>&lt;bean id="mysqldataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt; &lt;property name="url" value="mysqldataSource.url" /&gt; &lt;property name="username" value="mysqldataSource.username" /&gt; &lt;property name="password" value="mysqldataSource.password" /&gt; &lt;/bean&gt; </code></pre> <p>My firm is asking me to change the project from using MySQL to use a JNDI Data source. </p> <p>Below is my java code with you can see is using jdbcTemplate:</p> <pre><code>public class DisasterReliefMySQLImpl extends JdbcTemplate implements DisasterReliefMySQL { private static Log log = LogFactory.getLog(DisasterReliefMySQLImpl.class .getName()); String querySQL; int counter = 0; public int getCounter() { return counter; } private String getQuerySQL() { return querySQL; } private void setQuerySQL(String querySQL) { this.querySQL = querySQL; } DisasterReliefMySQLImpl(DataSource ds) { super(ds); } DisasterReliefMySQLImpl(DataSource ds, String querySQL) { super(ds); setQuerySQL(querySQL); } public int updateDonation(String id) { Long eTime = System.currentTimeMillis() / 1000; String updateSQL = "update uft_donation set sent_to_mbs=" + eTime.toString() + " where donation_id =" + id; return (int) this.update(updateSQL); } public List&lt;Donation&gt; returnResults() { log.debug("Starting returnResults..."); List&lt;Donation&gt; Donations = new ArrayList&lt;Donation&gt;(); List&lt;Map&lt;String, Object&gt;&gt; rows = this.queryForList(getQuerySQL()); counter = 0; for (Map row : rows) { Donation d = new Donation(); d.setDonationID((Long) row.get("donation_id")); d.setCCTransactionNumber((String) row.get("txn_id")); d.setProgramCode((String) row.get("gl_code")); d.setLastName((String) row.get("billing_last_name")); d.setFirstName((String) row.get("billing_first_name")); d.setAmount((String) row.get("mc_gross")); d.setAddressLine1((String) row.get("billing_street1")); d.setAddressLine2((String) row.get("billing_street2")); d.setCity((String) row.get("billing_city")); d.setState((String) row.get("zone_code")); d.setZipCode((String) row.get("billing_postal_code")); d.setCountry((String) row.get("country_name")); Donations.add(d); counter++; } log.debug(counter + " Donation(s) loaded"); return Donations; } } </code></pre> <p>Can someone please tell me how to change this to use a JNDI datasource. Also do I need a JNDI service somewhere for the database pooling?? We have JBoss AS7 with datasources in it can I use that from outside JBoss??</p> <p>Thanks</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.
 

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