Can I hide Database connectivity details from hibernate cfg file? - database

Just need to check, If there is the the way to hide Database connectivity details like username or password from hibernate configuration file:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:#localhost:1521:xe"></property>
<property name="username" value="system"></property>
<property name="password" value="tiger"></property>
</bean>

You have 2 options
1) Use JNDI
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">
<jee:jndi-lookup id="dbDataSource" jndi-name="jdbc/DatabaseName" expected-type="javax.sql.DataSource" />
2) Use a property placeholder
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:database.properties</value>
<!-- this example use the system parameter configlocation, add -Dconfiglocation -->
<value>file:${configlocation}/database.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
<property name="url" value="jdbc:oracle:thin:#localhost:1521:xe"></property>
<property name="username" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
The password can be in the file database.properties which is only in the classpath for the running application and not visible to all.

Related

Spring batch, unable to write on oracle database

this is my xml file configuration.
<batch:job id="pdgRecallJob">
<batch:step id="stepTmpRecall">
<batch:tasklet>
<batch:chunk reader="readFileRecall" processor="" writer="tmpRecallWriter" commit-interval="10000">
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="tmpRecall" class="it.mef.pdg.batch.model.TmpRecall" scope="prototype" />
<bean id="readFileRecall" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="strict" value="false" />
<property name="resource" value="classpath:/properties/RECALLPDG_*.txt"/>
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value=";"/>
<property name="names" value="appNomeFile, appCodFisc, appRata, appImporto, appIscrizione, appNumTitolo,
appProgQuota, appAnnoEmissione, appCodEnte, appEsitoMef, appStatoFile, appDpt, appPostazione, appNLotto,
appDLotto, appNomeFileOrigine" />
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="tmpRecall" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="tmpRecallWriter" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
<property name="dataSource" ref="dataSource" />
<property name="sql">
<value>
<![CDATA[
INSERT INTO APP_TMP_RECALL(APP_NOME_FILE,APP_COD_FISC,APP_RATA,APP_IMPORTO,APP_ISCRIZIONE,APP_NUM_TITOLO,APP_PROGR_QUOTA,APP_ANNO_EMISSIONE,APP_COD_ENTE,APP_ESITO_MEF,APP_STATO_FILE,APP_DPT,APP_POSTAZIONE,APP_NLOTTO,APP_DLOTTO,APP_NOME_FILE_ORIGINE)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
]]>
</value>
</property>
<property name="itemPreparedStatementSetter">
<bean class="it.mef.pdg.batch.items.TmpRecallPreparedStatementSetter" />
</property>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.pass}" />
</bean>
Then my itemPreparedStatementSetter Class:
final class TmpRecallPreparedStatementSetter implements ItemPreparedStatementSetter<TmpRecall>{
public void setValues(TmpRecall tmp, PreparedStatement ps) throws SQLException {
ps.setString(1, tmp.getAppNomeFile());
ps.setString(2, tmp.getAppCodFisc());
ps.setInt(3, tmp.getAppRata());
ps.setDouble(4, tmp.getAppImporto());
ps.setString(5, tmp.getAppIscrizione());
ps.setInt(6, tmp.getAppNumTitolo());
ps.setString(7, tmp.getAppProgQuota());
ps.setInt(8, tmp.getAppAnnoEmissione());
ps.setString(9, tmp.getAppCodEnte());
ps.setString(10, tmp.getAppEsitoMef());
ps.setString(11, tmp.getAppStatoFile());
ps.setString(12, tmp.getAppDpt());
ps.setInt(13, tmp.getAppPostazione());
ps.setInt(14, tmp.getAppNLotto());
ps.setDate(15, tmp.getAppDLotto());
ps.setInt(16, tmp.getAppNLotto());
}
}
My batch seems to work then I have final status COMPLETED, but it doesn't write no record inside my table.
I'm using jdk 1.5, ojdbc5-11.2.0.3.jar.
Either is there something I'm missing in my xml conf or any bean is not ok?
I was thinking that might be even a mismatch in Date field in table.
You don't currently have an item processor, which (I think) is needed to pass records from the reader to the writer. Since you are not doing any processing (that is, your reader produces the same type that your writer consumes), I think you could use a PassThroughItemProcessor here.

why CAMEL_MESSAGEPROCESSED created in SQL server db

I want to run Camel built application as stanalone. I am using maven to create standalone jar and execute route.When I run MainApp.java main method from eclipse or run using camel run then code runs as expected. But when I run using java -jar then 3 tables CAMEL_MESSAGEPROCESSED, CAMEL_MESSAGETRACED,hibernate_sequence are created into db. I do not want these tables created. Please help me find what I am doing wrong.
Camel, camel-jpa version 2.19.1
hibernate-entitymanager version 5.2.7.Final
Camel-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:prop="http://camel.apache.org/schema/placeholder"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-4.3.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="properties"
class="org.apache.camel.component.properti
es.PropertiesComponent">
<property name="location" value="classpath:db.properties" />
</bean>
<bean id="bridgePropertyPlaceholder"
class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="location" value="classpath:db.properties" />
</bean>
<camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myBuilder" />
</camelContext>
<bean id="myBuilder"
class="com.aexp.gsnt.insight.updateCentralData.InsightRouterBuilder" />
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="transactionManager" ref="jpaTxManager" />
</bean>
<bean id="jpaTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="persistenceUnit" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
<property name="showSql" value="${showSQL}" />
<property name="generateDdl" value="${generateDdl}" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.format_sql">${formatSQL}</prop>
</props>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
</beans>
Persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="persistenceUnit"
transaction-type="RESOURCE_LOCAL">
</persistence-unit>
</persistence>
MainApp.java
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
private static ClassPathXmlApplicationContext classPathXmlApplicationContext;
/* Invoked from Jar */
public static void main(String args[]) throws Exception {
System.out.println("Started Central Data Extractor");
System.setProperty("jsse.enableSNIExtension", "false");
classPathXmlApplicationContext = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/camel-context.xml");
classPathXmlApplicationContext.start();
}
}

What is the correct way of setting up Basic Authentication for CXF/HTTP in JBoss Fuse?

I have been trying for quite some time now to set up Basic Authentication for all of my exposed web services but without any luck.
I am using JBoss Fuse 6.2.1 with the Karaf container (karaf-2.4.0.redhat-621117) and I currently have three integrations that are consuming from an equal amount of cxfEndpoints.
What I want to achieve is to prompt the users of said services with an auth-dialog when either calling the services or trying to view the WSDL.
Note that I don't want to use ws-security which places the authentication in the Soap-envelope but rather on http-level.
I have been looking at the following documentation entries:
[1]https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2.1/html/Security_Guide/CamelJetty-BasicAuth.html
[2]http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html
[3]http://cxf.apache.org/docs/jetty-configuration.html
But I am confused as to which (if any) of these approaches I'm supposed to use.
In fact, none of them has worked for me so far but that might be down to a user error on my behalf.
Below I will show what I have tried (and subsequently failed) to do:
Using a mix of [1] and [3]
blueprint.xml:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cxf-core="http://cxf.apache.org/blueprint/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xsi:schemaLocation="
http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="loginService" class="org.eclipse.jetty.plus.jaas.JAASLoginService">
<property name="name" value="karaf"/>
<property name="loginModuleName" value="karaf"/>
<property name="roleClassNames">
<list>
<value>org.apache.karaf.jaas.boot.principal.RolePrincipal</value>
</list>
</property>
</bean>
<bean id="identityService" class="org.eclipse.jetty.security.DefaultIdentityService"/>
<bean id="constraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC"/>
<property name="roles" value="Administrator"/>
<property name="authenticate" value="true"/>
</bean>
<bean id="constraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="constraint"/>
<property name="pathSpec" value="/*"/>
</bean>
<bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<property name="authenticator">
<bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
</property>
<property name="constraintMappings">
<list>
<ref bean="constraintMapping"/>
</list>
</property>
<property name="loginService" ref="loginService"/>
<property name="strict" value="false"/>
<property name="identityService" ref="identityService"/>
</bean>
<httpj:engine-factory bus="cxf">
<httpj:engine port="8181">
<httpj:handlers>
<ref component-id="securityHandler" />
</httpj:handlers>
</httpj:engine>
</httpj:engine-factory>
</blueprint>
Using [2]
blueprint.xml:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cxf-core="http://cxf.apache.org/blueprint/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<http-conf:conduit name="http://localhost:8181/.*" xmlns:sec="http://cxf.apache.org/configuration/security">
<http-conf:authorization>
<sec:UserName>test</sec:UserName>
<sec:Password>test</sec:Password>
<sec:AuthorizationType>BASIC</sec:AuthorizationType>
</http-conf:authorization>
</http-conf:conduit>
</blueprint>
The cxfEndpoint used in both cases
<cxf:cxfEndpoint address="${address}" id="myWs" serviceClass="com.company.test.CxfService">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
The optimum would be to be able to leverage the JAAS but I would settle for something simpler to start with.
I should add that I'm not getting any errors with any of these, I'm just not being prompted to provide any credentials either when browsing http://localhost:8181/cxf or when calling the services through SoapUI.
I would greatly appreciate if someone could point me in the right direction.
I managed to find a viable solution so I'll post my findings with the hope that someone else will be helped by this at some point.
blueprint.xml:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cxf-core="http://cxf.apache.org/blueprint/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xsi:schemaLocation="
http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="loginService" class="org.eclipse.jetty.plus.jaas.JAASLoginService">
<property name="name" value="karaf"/>
<property name="loginModuleName" value="karaf"/>
<property name="roleClassNames">
<list>
<value>org.apache.karaf.jaas.boot.principal.RolePrincipal</value>
</list>
</property>
</bean>
<bean id="identityService" class="org.eclipse.jetty.security.DefaultIdentityService"/>
<bean id="constraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC"/>
<property name="roles">
<list>
<value>admin</value>
</list>
</property>
<property name="authenticate" value="true"/>
</bean>
<bean id="constraintMapping" class="org.eclipse.jetty.security.ConstraintMapping">
<property name="constraint" ref="constraint"/>
<property name="pathSpec" value="/*"/>
</bean>
<bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
<property name="authenticator">
<bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
</property>
<property name="constraintMappings">
<list>
<ref component-id="constraintMapping"/>
</list>
</property>
<property name="loginService" ref="loginService"/>
<property name="strict" value="false"/>
<property name="identityService" ref="identityService"/>
</bean>
<httpj:engine-factory bus="cxf">
<httpj:engine port="8083">
<httpj:handlers>
<ref component-id="securityHandler" />
</httpj:handlers>
</httpj:engine>
</httpj:engine-factory>
<cxf:cxfEndpoint address="http://localhost:8083/MyService" id="myWs" serviceClass="com.company.test.CxfService">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
...
</blueprint>
It is also necessary to add the following to the pom.xml:
<Import-Package>
javax.security.auth,
javax.security.auth.callback,
javax.security.auth.login,
javax.security.auth.spi,
org.apache.karaf.jaas.modules,
org.apache.karaf.jaas.boot.principal,
org.eclipse.jetty.server,
org.eclipse.jetty.plus.jaas;version=${jetty-version},
org.eclipse.jetty.security;version=${jetty-version},
*
</Import-Package>
org.eclipse.jetty.server is needed for the httpj:engine-factory to work.
It would seem that you're not able to use the default port (8181) if you want to setup Basic Authentication. This solution instead sets up a custom jetty container on port 8083 (you can use a different port, just make sure that your cxfEndpoints are published on the same one.)

How to use Camel to get message from remote WMQ and place message in ActiveMQ?

I have been looking at these for days and still haven't have mush success.
I have install and run activeMQ on a server. Created a queue called "testUpdate". I also have another queue on another server, let call this "forward" and this is on the IBM MQ (WMQ).
So we have testUpdate on ActiveMQ and forward on WMQ. I want the message on forward queue to be placed into testUpdate queue. Trying to use Camel for this process.
So the setup in ActiveMQ has an XML(activemq.xml) that I can place spring beans and configure to do the routing. In this xml, I added http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd to the xmlns and then added
import resource="camel.xml"
In this new xml, I have the following:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<description>Example Camel Route</description>
<from uri="mqseries:forward"/>
<to uri="activemq:testUpdate"/>
</route>
</camelContext>
<bean id="mqseries" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1"/>
<property name="hostName" value="172.00.12.21/>
<property name="port" value="xyza"/>
<property name="queueManager" value="manager"/>
<property name="channel" value="srvcChannel"/>
</bean>
<!--
Lets configure some Camel endpoints
http://camel.apache.org/components.html
-->
<!-- configure the camel activemq component to use the current broker -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://amq-broker?create=false"/>
<property name="userName" value="${activemq.username}"/>
<property name="password" value="${activemq.password}"/>
</bean>
</property>
</bean>
</beans>
I added the jar file com.ibm.mq.allclient.jar into the lib folder of ActiveMQ. When running the program, I am getting this exception:
java.lang.ClassNotFoundException: javax.jms.JMSRuntimeException
It sounds like I am missing the websphere jar file? Is this correct?
I use both IBM MQ and ActiveMQ on a regular basis. This example below will show you some sample configuration options. Please make sure you configure these to your own use cases.
//ActiveMQ connection factory
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" destroy-method="doStop">
<property name="configuration">
<bean class="org.apache.camel.component.jms.JmsConfiguration">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="acceptMessagesWhileStopping" value="true" />
<property name="acknowledgementModeName" value="CLIENT_ACKNOWLEDGE" />
<property name="cacheLevelName" value="CACHE_CONSUMER" />
<property name="connectionFactory">
<bean class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="1" />
<property name="MaximumActiveSessionPerConnection" value="500" />
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq1.brokerUrl}" />
<property name="userName" value="${activemq1.username}" />
<property name="password" value="${activemq1.password}" />
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
//IBM MQ connection factory
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent" destroy-method="doStop">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="connectionFactory">
<bean class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy">
<constructor-arg>
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1" />
<property name="channel" value="${channel}" />
<property name="hostName" value="${hostname}" />
<property name="port" value="${port}" />
<property name="queueManager" value="${queueManager}" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
You can use jms component to consume the message from IBM MQ and use activemq component to post it to ActiveMQ
have a look at the following links
http://camel.apache.org/jms.html
http://camel.apache.org/activemq.html
Thanks,
Gibu
You can use users camel extra component https://github.com/camel-extra/camel-extra/blob/master/components/camel-wmq/README.md to get messages from wmq without using the JMS wrapping and then send messages to ActiveMQ with custom camel component https://camel.apache.org/components/latest/activemq-component.html. See also a similar topic Apache Camel with IBM MQ.

Spring + Hibernate + Spring

I've a project of Spring and Hibernate, but that use a lot of conections to my database (MYSQL). I know that I should implement a C3P0 to manage Pool conection but i dont know how?. Plase take me a help.
Hibernate's config:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/oasis"/>
<property name="username" value="root"/>
<property name="password" value="mysql"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan">
<list>
<value>com.app.oasis.model.base</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
Where do I have to add the C3P0 config?
Add the C3P0 jar file (download from c3p0 website or use maven) to your classpath and create your dataSource using com.mchange.v2.c3p0.ComboPooledDataSource
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost/oasis"/>
<property name="user" value="root"/>
<property name="password" value="mysql"/>
<!-- Various configuration properties can be set here -->
</bean>

Resources