Friday, February 27, 2009

Database Connection Pooling in Hibernate

I was looking for a way to control connection pooling in Hibernate inside a Spring environment. God bless Apache foundation for their amazing code helps, as I found the answers in DBCP. Which-ever hibernate session factory you use, use the following data source bean in your configuration xml to control connection pooling:

<bean id="internalDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://"/>
<property name="username" value="root"/>
<property name="password" value="abc123"/>
<property name="maxIdle" value="5"/>
<property name="maxActive" value="25"/>
<property name="minIdle" value="5"/>
<property name="initialSize" value="5"/>

For all options and details, refer the API for BasicDataSource. And, if you are a maven user, don't forget to include the dependency:



Wednesday, February 25, 2009

Which IDE?

IDEs can be critical to productivity. As a developer, which is the one that I prefer?

There are three IDEs that I have used for development:  Idea, Eclipse and NetBeans.

Idea costs money, but it is worth it. Developing enterprise applications with it is easier than with other IDEs. Nevertheless it is not cheap and other IDEs are fast catching up with it.

Eclipse is too much customizable for its own good, making the "setting up of eclipse" so as it works with a plethora of commonly used enterprise technologies almost an art. Hence the learning curve can be sharp. If you are in a hurry to get the project running and don't have much experience with Eclipse , I would not recommend Eclipse. Eclipse is a good (and free) IDE and can be a developer's joy. Nevertheless it can be a pain for somebody new to it and not willing to spend so much effort customizing it.

I would have completely ruled out NetBeans before its version 6. In the past I saw it as a good Java GUI builder and thats it. But the recent release is impressive. It takes into account a lot of problems that are commonly faced using disparate technologies in enterprise development. It is configurable but comes with a lot of intelligent defaults that can get you up-to-speed pretty quickly. Still not as good as Idea, but is a good contender if you are not willing to spend.