<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Free practice test , mock test, driving test, interview questions &#187; spring</title>
	<atom:link href="http://www.skill-guru.com/blog/tag/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.skill-guru.com/blog</link>
	<description>Find free mock and practice test, create and sell tests</description>
	<lastBuildDate>Mon, 16 Jan 2012 16:53:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New practice test on Spring Certification</title>
		<link>http://www.skill-guru.com/blog/2011/07/24/new-practice-test-on-spring-certification/</link>
		<comments>http://www.skill-guru.com/blog/2011/07/24/new-practice-test-on-spring-certification/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 21:27:00 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=4098</guid>
		<description><![CDATA[After huge success of last two Spring mock tests from ikoko, Jacek has added another test for our readers .
Spring 3.x certification mock test
Questions very similar to originals with almost the same difficulty level. Majority questions are from most important sections at exam: container, testing, AOP, transactions. Only few from other sections like MVC, REST, [...]]]></description>
			<content:encoded><![CDATA[<p>After huge success of last two Spring mock tests from ikoko, Jacek has added another test for our readers .</p>
<p><a href="http://www.skill-guru.com/test/177/spring-3.x-certification-mock-test">Spring 3.x certification mock test</a></p>
<p>Questions very similar to originals with almost the same difficulty level. Majority questions are from most important sections at exam: container, testing, AOP, transactions. Only few from other sections like MVC, REST, JMX, JMS.</p>
<p>This is a 30 question practice test. 5 questions are free for you to try.</p>
<p>It is very reasonably priced at $1.99.</p>
<p>If you buy all there tests, you would save on paypal fees.</p>
<p>I am sure you would like the test. Jacek is looking for feedback and inputs to make the test better.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/07/24/new-practice-test-on-spring-certification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading properties file in Spring</title>
		<link>http://www.skill-guru.com/blog/2011/06/05/reading-properties-file-in-spring/</link>
		<comments>http://www.skill-guru.com/blog/2011/06/05/reading-properties-file-in-spring/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 03:19:49 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3973</guid>
		<description><![CDATA[There are multiple ways to read properties file in Spring
Let us say you have database user name , password etc configured in jdbc.properties and would like to inject the values at run time.
Here is what will go in applicationContext.xml
&#60;bean id=&#8221;dataSource&#8221; destroy-method=&#8221;close&#8221;&#62;
&#60;property name=&#8221;driverClass&#8221; value=&#8221;${jdbc.driverClass}&#8221;/&#62;
&#60;property name=&#8221;jdbcUrl&#8221; value=&#8221;${jdbc.url}&#8221;/&#62;
&#60;property name=&#8221;user&#8221; value=&#8221;${jdbc.user}&#8221;/&#62;
&#60;property name=&#8221;password&#8221; value=&#8221;${jdbc.password}&#8221;/&#62;
&#60;property name=&#8221;minPoolSize&#8221; value=&#8221;${jdbc.minPoolSize}&#8221;/&#62;
&#60;property name=&#8221;maxPoolSize&#8221; value=&#8221;${jdbc.maxPoolSize}&#8221;/&#62;
&#60;/bean&#62;
and this will [...]]]></description>
			<content:encoded><![CDATA[<p>There are multiple ways to read properties file in Spring</p>
<p>Let us say you have database user name , password etc configured in jdbc.properties and would like to inject the values at run time.</p>
<p>Here is what will go in applicationContext.xml</p>
<p>&lt;bean id=&#8221;dataSource&#8221; destroy-method=&#8221;close&#8221;&gt;<br />
&lt;property name=&#8221;driverClass&#8221; value=&#8221;${jdbc.driverClass}&#8221;/&gt;<br />
&lt;property name=&#8221;jdbcUrl&#8221; value=&#8221;${jdbc.url}&#8221;/&gt;<br />
&lt;property name=&#8221;user&#8221; value=&#8221;${jdbc.user}&#8221;/&gt;<br />
&lt;property name=&#8221;password&#8221; value=&#8221;${jdbc.password}&#8221;/&gt;<br />
&lt;property name=&#8221;minPoolSize&#8221; value=&#8221;${jdbc.minPoolSize}&#8221;/&gt;<br />
&lt;property name=&#8221;maxPoolSize&#8221; value=&#8221;${jdbc.maxPoolSize}&#8221;/&gt;<br />
&lt;/bean&gt;</p>
<p>and this will be your properties file</p>
<p>jdbc.driverClass=oracle.jdbc.driver.OracleDriver<br />
jdbc.url=jdbc:oracle:thin:@abc.com:1521:ORAC<br />
jdbc.user=hello<br />
jdbc.password=hello<br />
jdbc.minPoolSize=1<br />
jdbc.maxPoolSize=10</p>
<p>At run time, the properties file value will be injected  into the applicationContext.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/06/05/reading-properties-file-in-spring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How FlushMode.Never affects the performance ?</title>
		<link>http://www.skill-guru.com/blog/2011/05/20/how-flushmode-never-affects-the-performance/</link>
		<comments>http://www.skill-guru.com/blog/2011/05/20/how-flushmode-never-affects-the-performance/#comments</comments>
		<pubDate>Fri, 20 May 2011 17:03:26 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3184</guid>
		<description><![CDATA[In hibernate if you set this in you code
session.setFlushMode(FlushMode.NEVER)
What does it signify ?
It means that the Hibernate session not to flush any state changes to database unless flush()  is explicitly called by the application.
When setting the FlushMode.NEVER , will it improve the performance and reduce the run time  ?
It would not affect if you [...]]]></description>
			<content:encoded><![CDATA[<p>In hibernate if you set this in you code</p>
<p>session.setFlushMode(<strong>FlushMode.NEVER</strong>)</p>
<p>What does it signify ?</p>
<p>It means that the Hibernate session not to flush any state changes to database unless flush()  is explicitly called by the application.</p>
<p>When setting the FlushMode.NEVER , will it improve the performance and reduce the run time  ?</p>
<p>It would not affect if you are running a single update or a series of small updates. It really affects you when you are doing batch processing. The reason for this is the way hibernate implements dirty checking. Once you load an object in memory and do not evict it, the hibernate session keeps track of it in case if it was changed. So, any time you perform a query, the session iterates over all objects in the session checking dirtiness and flushes any dirty objects to the database. It does this to ensure that all state changes that might affect the query are present in the database before issuing the query to it. That&#8217;s fine when you have only a few objects in session, but when you have thousands and are performing thousands of queries, it becomes a real drain on performance.</p>
<p>Tim fennel has made this interesting observation about the FlushMode.NEVER in his blog <a href="http://jroller.com/tfenne/entry/hibernate_understand_flushmode_never">here</a>.</p>
<p>Spring provides a similar way to annotate methods <a href="http://www.skill-guru.com/blog/2010/12/19/transactionalreadonlytrue-in-spring/"><strong>@Transactional(readOnly=true) in Spring</strong></a> which internally has the same affect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/05/20/how-flushmode-never-affects-the-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring certifications tests at Skill-guru</title>
		<link>http://www.skill-guru.com/blog/2011/05/02/spring-certifications-tests-at-skill-guru/</link>
		<comments>http://www.skill-guru.com/blog/2011/05/02/spring-certifications-tests-at-skill-guru/#comments</comments>
		<pubDate>Mon, 02 May 2011 18:03:09 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Mock  Exam / Certifications]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring 3.0]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=4024</guid>
		<description><![CDATA[For users  who have been taking the Spring certification practice tests 1 and  Spring certification practice tests 2 at skill-guru  have raise the concern that
We have contacted the creator of these tests Ikoko , and he has clarified thatthe Spring documentation for the exam syllabus has changed  (improved) since he had created the exam [...]]]></description>
			<content:encoded><![CDATA[<p>For users  who have been taking the <a href="http://www.skill-guru.com/test/81/core-spring-3.0-certification-mock">Spring certification practice tests 1</a> and <a href="http://www.skill-guru.com/test/86/core-spring-3.0-certification-mock-test-2"> Spring certification practice tests 2</a> at skill-guru  have raise the concern that</p>
<p>We have contacted the creator of these tests <a href="http://www.skill-guru.com/guru/ikoko">Ikoko</a> , and he has clarified thatthe Spring documentation for the exam syllabus has changed  (improved) since he had created the exam so the  tests now appear to be different to the syllabus</p>
<p>The  historical documentation and support for the certification has been poor  from Spring and might even be incorrect.</p>
<p>he also pointed out that <a href="http://www.skill-guru.com">Skill-guru</a> test-takers basing their  opinions on the Spring documentation and not actually doing the Spring  exam are therefore possibly misled by the official documentation</p>
<p>From Ikoko&#8217;s email</p>
<blockquote><p>I  sat both the 2.5 exam and 3.0 exam so have experienced both exams  first-hand and have been keen to keep my exams accurate based on real  exam-experience and not any vague syllabus published by Spring</p>
<p>Having  said all, this at a higher topic level I only noticed the category of  SpEL (Spring expression language) being a category in my tests that was  not in the offical syllabus. I had 1 SpEL question in test 1, and 2  questions in test 2. I have now removed all three questions.</p></blockquote>
<p>Hope  this clarifies the doubt of our readers and thanks to MaggieL and Shane Mannion for pointing this out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/05/02/spring-certifications-tests-at-skill-guru/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring JdbcTemplate batch Update-Insert example</title>
		<link>http://www.skill-guru.com/blog/2011/04/12/spring-jdbctemplate-batch-update-insert-example/</link>
		<comments>http://www.skill-guru.com/blog/2011/04/12/spring-jdbctemplate-batch-update-insert-example/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 20:32:26 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3988</guid>
		<description><![CDATA[This post explain how to use Spring JDBCTemplate to do batch insert and update.
If you are using SimpleJDBCtemplate then the Spirng docs are good place to find a good explanation for it Simple JDBC Template 
If you are using JDBCtemplate , here is the example to use prepared statements and do batch updates
public boolean createGroceyList(List&#60;Grocery&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>This post explain how to use Spring JDBCTemplate to do batch insert and update.</p>
<p>If you are using <strong>SimpleJDBCtemplate </strong>then the Spirng docs are good place to find a good explanation for it <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/jdbc.html#jdbc-SimpleJdbcTemplate">Simple JDBC Template </a></p>
<p>If you are using <strong>JDBCtemplate </strong>, here is the example to use prepared statements and do batch updates</p>
<blockquote><p>public boolean createGroceyList(List&lt;Grocery&gt; groceryList){</p>
<p>final List&lt;Grocery&gt; aGroceryList =  groceryList</p>
<p>int result[] = this.jdbcTemplate.batchUpdate(</p>
<p>&#8220;the query goes here &#8220;,new BatchPreparedStatementSetter() {</p>
<p>public void setValues(PreparedStatement ps, int i) throws SQLException {<br />
ps.setLong(1, &#8220;param 1 goes here &#8220;);<br />
ps.setString(2, &#8220;param 2 goes here &#8220;);</p>
<p>ps.setString(3, &#8220;param 3 goes here &#8220;);<br />
}</p>
<p>public int getBatchSize() {<br />
return aGroceryList.size();<br />
}<br />
});</p>
<p>return (aGroceryList.size() == result.length ? true : false);<br />
}</p></blockquote>
<p>The query would be something similar to</p>
<p>INSERT INTO GROCERY(ID, NAME, QUANTITY) VALUES(?,?,?)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/04/12/spring-jdbctemplate-batch-update-insert-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using @BeforeClass in Spring integration Tests</title>
		<link>http://www.skill-guru.com/blog/2011/01/02/using-beforeclass-in-spring-integration-tests/</link>
		<comments>http://www.skill-guru.com/blog/2011/01/02/using-beforeclass-in-spring-integration-tests/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 14:27:33 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3192</guid>
		<description><![CDATA[If you are doing integration testing with your spring environment, you would like to see an end to end test running rather than just simple Junit tests. Unit testing are important but there are occasions in which we really the tire to hit the road and what is really happening with the system
During test, if [...]]]></description>
			<content:encoded><![CDATA[<p>If you are doing integration testing with your spring environment, you would like to see an end to end test running rather than just simple Junit tests. Unit testing are important but there are occasions in which we really the tire to hit the road and what is really happening with the system</p>
<p>During test, if you may want to set up up test data or some fields like connection pool only once. If you are using simple JUnit tests , then an easy way would be to annotate your methods with @BeforeClass and @AfterClass.  Here is an <a href="http://www.skill-guru.com/blog/2010/12/14/beforeclass-and-afterclass-in-junit/">example of @BeforeClass and @AfterClass</a></p>
<p><strong>How do you achieve the functionality of @BeforeClass in Spring ?</strong></p>
<p>Now let us say you want to run Spring integration tests and your class is</p>
<blockquote><p>public class MySpringIntegrationTest extends AbstractDependencyInjectionSpringContextTests {</p>
<p>private static int ID = 1111;</p>
<p>@Autowired<br />
private MyBean myBean;</p>
<p>@BeforeClass<br />
public static void before() {</p>
<p>// all the set up code will come here. for eg connecting to database<br />
}</p>
<p>}</p></blockquote>
<p>If you run this class,  @BeforeClass will never run.</p>
<p>Reason is that spring&#8217;s test classes are base<code>d on Junit 3.x framework. </code>@BeforeClass has been introduced with JUnit4. Since your class extends AbstractDependencyInjectionSpringContextTests, Junit 4 functions are never invoked.</p>
<p>You will not see compile time errors because Junit 4 would be in your IDE or project classpath.</p>
<h3>How to run Spring tests cases with Junit4 ?<span id="more-3192"></span></h3>
<p>Here is what I did</p>
<blockquote><p>@RunWith(BlockJUnit4ClassRunner.class)<br />
public class MySpringIntegrationTest extends AbstractDependencyInjectionSpringContextTests {</p>
<p>private static int ID = 1111;</p>
<p>@Autowired<br />
private MyBean myBean;</p>
<p>protected String[] getConfigLocations()<br />
{<br />
return new String[]{&#8220;classpath:applicationContext-*.xml&#8221;};<br />
}</p>
<p>@BeforeClass<br />
public static void before() {</p>
<p>// all the set up code will come here. for eg connecting to database<br />
}</p>
<p>@Before<br />
final public void callSetup() throws Exception {<br />
super.setUp();<br />
}</p>
<p>@After<br />
public void callTearDown() throws Exception {<br />
super.tearDown();<br />
}</p>
<p>@Test<br />
public void testMethod1_happy() throws Exception{<br />
}</p>
<p>}</p></blockquote>
<p>You can use <code>@RunWith((TestClassRunner.class) but it has been depreciated. So you better off </code><code>with @RunWith(BlockJUnit4ClassRunner.class)</code></p>
<p>What you have done by annotating your class with <code>@RunWith(BlockJUnit4ClassRunner.class) is that you have forced Spring to run with JUnit4 and asked it to ignore JUnit3.</code></p>
<p>But once you do this, your annotated <strong>myBean</strong> would be null. Spring would not injected it for you.</p>
<p>Why ?</p>
<p>JUnit 4 only cares about annotations and won’t run the old setUp and tearDown methods defined by the Spring classes. To get around this, add methods with <code>Before</code> and <code>After</code> annotations to call setUp and tearDown. <!-- Generator: GNU source-highlight 2.3 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --></p>
<blockquote><p>
<pre><pre>&lt;tt&gt;@Before final public void callSetup() throws Exception {
&nbsp;&nbsp;super.setUp();
}

@After public void callTearDown() throws Exception {
&nbsp;&nbsp;super.tearDown();
}

&lt;/tt&gt;</pre></pre>
</p></blockquote>
<p><tt>Now your test class with run with Junit4 and base class features are also available.</tt></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<h2>@BeforeClass and @AfterClass in Junit</h2>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/01/02/using-beforeclass-in-spring-integration-tests/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Expose data in a JSON format through a Spring service</title>
		<link>http://www.skill-guru.com/blog/2011/01/02/expose-data-in-a-json-format-through-a-spring-service/</link>
		<comments>http://www.skill-guru.com/blog/2011/01/02/expose-data-in-a-json-format-through-a-spring-service/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 14:27:16 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=2891</guid>
		<description><![CDATA[In our last post , we had talked about Create your first REST service  using JERSEY.
There are situations in which you would like your Spring services as web services. In this link below there is a code example of both REST and SOAP access the same backbone. Here is the link
]]></description>
			<content:encoded><![CDATA[<p>In our last post , we had talked about <a href="http://www.skill-guru.com/blog/2010/12/29/creating-your-firs-rest-service-with-jersey/">Create your first REST service  using JERSEY</a>.</p>
<p>There are situations in which you would like your Spring services as web services. In this link below there is a code example of both REST and SOAP access the same backbone. Here is the <a href="http://raulraja.com/2009/06/25/spring-exposing-a-bean-as-rest-xml-json-and-soap-webservice/">link</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2011/01/02/expose-data-in-a-json-format-through-a-spring-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using connection pool with MYSQL in Spring</title>
		<link>http://www.skill-guru.com/blog/2010/12/23/using-connection-pool-with-mysql-in-spring/</link>
		<comments>http://www.skill-guru.com/blog/2010/12/23/using-connection-pool-with-mysql-in-spring/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 19:42:00 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[hssql]]></category>
		<category><![CDATA[myssql]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3204</guid>
		<description><![CDATA[In this post , I will talk about how to set up connection pool through Spring&#8217;s applicationContext.xml for mysql and hssql.
We were using in memory database  HSSQL db in our application for doing testing and we discovered that we required more than one connection. So basically we need to set up a connection pool.
The old [...]]]></description>
			<content:encoded><![CDATA[<p>In this post , I will talk about how to set up connection pool through Spring&#8217;s applicationContext.xml for mysql and hssql.</p>
<p>We were using in memory database  HSSQL db in our application for doing testing and we discovered that we required more than one connection. So basically we need to set up a connection pool.</p>
<p>The old definition looked like</p>
<blockquote><p>&lt;bean id=&#8221;dataSource&#8221; class=&#8221;org.springframework.jdbc.datasource.DriverManagerDataSource&#8221; &gt;<br />
&lt;property name=&#8221;driverClassName&#8221; value=&#8221;org.hsqldb.jdbcDriver&#8221;/&gt;<br />
&lt;property name=&#8221;url&#8221; value=&#8221;jdbc:hsqldb:file:testdb;shutdown=true&#8221;/&gt;<br />
&lt;property name=&#8221;username&#8221;  value=&#8221;sa&#8221;/&gt;<br />
&lt;property name=&#8221;password&#8221; value=&#8221;"/&gt;<br />
&lt;/bean&gt;</p></blockquote>
<p>Before talking about how we set up a connection, let us talk about some basic concept. All databases support connection pooling , even in memory database like hssql. For setting up a connection pool through Spring&#8217;s application Context,  you should be using the class which <strong>support</strong> the pooling</p>
<p>Notice here that we are using <strong>class=&#8221;org.springframework.jdbc.datasource.DriverManagerDataSource&#8221;</strong>.</p>
<p>This class does not support connection pool .</p>
<p>So if you try to add properties such as <strong>minPoolSize</strong> and <strong>maxPoolSize</strong> , spring will throw exception similar to</p>
<p><em>Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#8216;dataSource&#8217; defined in file </em></p>
<p><span id="more-3204"></span></p>
<p>To avoid the exceptions, you should be using <strong>class=&#8221;com.mchange.v2.c3p0.ComboPooledDataSource</strong></p>
<p>This class support connection pooling and setting up of other properties  such as idleConnectionTestPeriod etc.</p>
<p>Your bean definition will look like<strong><br />
</strong></p>
<blockquote><p>&lt;bean id=&#8221;dataSource&#8221; destroy-method=&#8221;close&#8221;&gt;<br />
&lt;property name=&#8221;driverClass&#8221; value=&#8221;org.hsqldb.jdbcDriver&#8221;/&gt;<br />
&lt;property name=&#8221;jdbcUrl&#8221; value=&#8221;jdbc:hsqldb:file:testdb;shutdown=true&#8221;/&gt;<br />
&lt;property name=&#8221;user&#8221; value=&#8221;sa&#8221;/&gt;<br />
&lt;property name=&#8221;password&#8221; value=&#8221;"/&gt;<br />
&lt;property name=&#8221;minPoolSize&#8221; value=&#8221;1&#8243;/&gt;<br />
&lt;property name=&#8221;maxPoolSize&#8221; value=&#8221;4&#8243;/&gt;<br />
&lt;/bean&gt;</p></blockquote>
<p>This pool size can be used with any database including myssql. For mysql , the driver would change and the defintion would look something like</p>
<h3>MySQl connection Pool in spring applicationContext.xml</h3>
<blockquote><p>&lt;bean id=&#8221;dataSource1&#8243; destroy-method=&#8221;close&#8221;&gt;<br />
&lt;property name=&#8221;driverClass&#8221; value=&#8221;${db.driverClass}&#8221;/&gt;<br />
&lt;property name=&#8221;jdbcUrl&#8221; value=&#8221;${db.wordpress_db_url}&#8221;/&gt;<br />
&lt;property name=&#8221;user&#8221; value=&#8221;${db.wp.username}&#8221;/&gt;<br />
&lt;property name=&#8221;password&#8221; value=&#8221;${db.wp.password}&#8221;/&gt;<br />
&lt;property name=&#8221;minPoolSize&#8221; value=&#8221;1&#8243;/&gt;<br />
&lt;property name=&#8221;maxPoolSize&#8221; value=&#8221;4&#8243;/&gt;<br />
&lt;property name=&#8221;breakAfterAcquireFailure&#8221; value=&#8221;false&#8221;/&gt;<br />
&lt;property name=&#8221;acquireRetryAttempts&#8221; value=&#8221;3&#8243;/&gt;<br />
&lt;property name=&#8221;idleConnectionTestPeriod&#8221; value=&#8221;300&#8243;&gt;<br />
&lt;property name=&#8221;testConnectionOnCheckout&#8221; value=&#8221;true&#8221;/&gt;<br />
&lt;/bean&gt;</p></blockquote>
<p>The value for db.driverClass can be set up in an external properties file or defined here in xml file itself as we had done above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2010/12/23/using-connection-pool-with-mysql-in-spring/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>@Transactional(readOnly=true) in Spring</title>
		<link>http://www.skill-guru.com/blog/2010/12/19/transactionalreadonlytrue-in-spring/</link>
		<comments>http://www.skill-guru.com/blog/2010/12/19/transactionalreadonlytrue-in-spring/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 03:26:25 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[Spring Transactions]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3017</guid>
		<description><![CDATA[@Transactional(readOnly=true) in Spring 
What does this mean ?
When a Multi Version Concurrency Control database (Oracle, Postgresql, MySQL + InnoDb) is used, a read only transaction can be translated to the non standard isolation level: READ_ONLY.
The READ_ONLY isolation level provides the same protection as the SERIALIZED isolation level (no dirty reads, no unrepeatable reads, no phantom [...]]]></description>
			<content:encoded><![CDATA[<p><strong>@Transactional(readOnly=true) in Spring </strong></p>
<p>What does this mean ?</p>
<p>When a Multi Version Concurrency Control database (Oracle, Postgresql, MySQL + InnoDb) is used, a read only transaction can be translated to the non standard isolation level: READ_ONLY.</p>
<p>The READ_ONLY isolation level provides the same protection as the SERIALIZED isolation level (no dirty reads, no unrepeatable reads, no phantom reads) but doesn&#8217;t allow any updates. It also doesn&#8217;t cause any lock contention because no locking is required (the database is able to revert back to previous versions of the records ignoring all new changes).</p>
<p>Ms Sql 2005 also has a similar isolation level: SNAPSHOT.</p>
<p>If you specify readOnly as true, the flush mode will be set as <strong>FlushMode.NEVER</strong> in the current Hibernate Session preventing the session from committing the transaction.<span id="more-3017"></span></p>
<p>Furthermore, <strong>setReadOnly(true)</strong> will be called on the JDBC Connection, which is also a hint to the underlying database. If your database supports it (most likely it does), this has basically the same effect as FlushMode.NEVER, but it&#8217;s stronger since you cannot even flush manually.</p>
<p>Now let&#8217;s see how transaction propagation works.</p>
<p>If you don&#8217;t explicitly set readOnly to true, you will have read/write transactions. Depending on the transaction attributes (like REQUIRES_NEW), sometimes your transaction is suspended at some point, a new one is started and eventually committed, and after that the first transaction is resumed.</p>
<p>If a method in a <strong>read/write</strong> transaction calls a method that requires a <strong>readOnly</strong> transaction, the first one should be suspended, because otherwise a flush/commit would happen at the end of the second method.</p>
<p>Conversely, if you call a method from within a <strong>readOnly</strong> transaction that requires <strong>read/write</strong>, again, the first one will be suspended, since it cannot be flushed/committed, and the second method needs that.</p>
<p>In the <strong>readOnly-to-readOnly</strong>, and the <strong>read/write-to-read/write</strong> cases the outer transaction doesn&#8217;t need to be suspended (unless you specify propagation otherwise, obviously).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2010/12/19/transactionalreadonlytrue-in-spring/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Configuring datasource in applicationContext.xml through JNDI</title>
		<link>http://www.skill-guru.com/blog/2010/12/15/configuring-datasource-in-applicationcontext-xml-through-jndi/</link>
		<comments>http://www.skill-guru.com/blog/2010/12/15/configuring-datasource-in-applicationcontext-xml-through-jndi/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 04:00:36 +0000</pubDate>
		<dc:creator>Vinay</dc:creator>
				<category><![CDATA[Programming / tutorials]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.skill-guru.com/blog/?p=3025</guid>
		<description><![CDATA[You can configure JNDI instead of datasource in spring applicationcontext.xml using &#8220;org.springframework.jndi.JndiObjectFactoryBean&#8221;.
For Example:
&#60;bean id=&#8221;dataSource&#8221; class=&#8221;org.springframework.jndi.JndiObjectFactoryBean&#8221;&#62;
&#60;property name=&#8221;jndiName&#8221;&#62; &#60;
value&#62;java:comp/env/jdbc/appfuse&#60;/value&#62;
&#60;/property&#62;
&#60;/bean&#62;
]]></description>
			<content:encoded><![CDATA[<p>You can configure JNDI instead of datasource in spring applicationcontext.xml using &#8220;org.springframework.jndi.JndiObjectFactoryBean&#8221;.</p>
<p>For Example:</p>
<p>&lt;bean id=&#8221;dataSource&#8221; class=&#8221;org.springframework.jndi.JndiObjectFactoryBean&#8221;&gt;</p>
<p>&lt;property name=&#8221;jndiName&#8221;&gt; &lt;</p>
<p>value&gt;java:comp/env/jdbc/appfuse&lt;/value&gt;</p>
<p>&lt;/property&gt;</p>
<p>&lt;/bean&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.skill-guru.com/blog/2010/12/15/configuring-datasource-in-applicationcontext-xml-through-jndi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

