I'm using spring mvc hibernate for a project.
Now i'm stuck on my mapping.
The normal url is:
localhost:8080/Carre2/......
Somepages have some parameters like
localhost:8080/Carre2/addproduct/edit/1
When i want to go to antoher page he request this:
localhost:8080/Carre2/addproduct/edit/home
I have no idea how to fix this mapping problem.
Someone can help?
Some code:
public class AddproductController {
private ProductService productService;
#Autowired(required = true)
#Qualifier(value = "productService")
public void setProductService(ProductService ps) {
this.productService = ps;
}
#RequestMapping(value = "/addproduct", method = RequestMethod.GET)
public String listProduct(Model model) {
model.addAttribute("product", new Product());
model.addAttribute("listProduct", this.productService.listProduct());
return "addproduct";
}
//For add and update person both
#RequestMapping(value = "/addproduct/add", method = RequestMethod.POST)
public String addProduct(#ModelAttribute("product") Product p) {
if (p.getId() == 0) {
//new person, add it
this.productService.addProduct(p);
} else {
//existing person, call update
this.productService.updateProduct(p);
}
return "redirect:/addproduct";
}
#RequestMapping("addproduct/update/{id}")
public String updateProduct(#PathVariable("id") int id, Model model) {
model.addAttribute("product", this.productService.getProductById(id));
model.addAttribute("listProduct", this.productService.listProduct());
return "productlist";
}
#RequestMapping("addproduct/edit/{id}")
public String editProduct(#PathVariable("id") int id, Model model) {
model.addAttribute("product", this.productService.getProductById(id));
model.addAttribute("listProduct", this.productService.listProduct());
return "addproduct";
}
Here my servlet-context.xml
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<resources mapping="/resources/**" location="/resources/carre/" cache-period="31556926"/>
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url"
value="jdbc:mysql://localhost:3306/carre" />
<beans:property name="username" value="root" />
<beans:property name="password" value="...." />
</beans:bean>
<!-- Hibernate 4 SessionFactory Bean definition -->
<beans:bean id="hibernate4AnnotatedSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.carre.model.Person</beans:value>
<beans:value>com.carre.model.Product</beans:value>
<beans:value>com.carre.model.Categorie</beans:value>
<beans:value>com.carre.model.Catalogus</beans:value>
<beans:value>com.carre.model.Voorstelling</beans:value>
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="catalogusDAO" class="com.carre.dao.CatalogusDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="CatalogusService" class="com.carre.service.CatalogusServiceImpl">
<beans:property name="catalogusDAO" ref="catalogusDAO"></beans:property>
</beans:bean>
<beans:bean id="personDAO" class="com.carre.dao.PersonDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="personService" class="com.carre.service.PersonServiceImpl">
<beans:property name="personDAO" ref="personDAO"></beans:property>
</beans:bean>
<beans:bean id="productDAO" class="com.carre.dao.ProductDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="productService" class="com.carre.service.ProductServiceImpl">
<beans:property name="productDAO" ref="productDAO"></beans:property>
</beans:bean>
<beans:bean id="categorieDAO" class="com.carre.dao.CategorieDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="CategorieService" class="com.carre.service.CategorieServiceImpl">
<beans:property name="categorieDAO" ref="categorieDAO"></beans:property>
</beans:bean>
<beans:bean id="voorstellingDAO" class="com.carre.dao.VoorstellingDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="VoorstellingService" class="com.carre.service.VoorstellingServiceImpl">
<beans:property name="voorstellingDAO" ref="voorstellingDAO"></beans:property>
</beans:bean>
<context:component-scan base-package="com.carre.controller" />
<tx:annotation-driven transaction-manager="transactionManager"/>
<beans:bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
Here is how i want to get to the url.
c:url value='addproduct/edit/${product.id}'
I would recommend to use c:url like as below to fix it:
c:url value="${pageContext.request.contextPath}/addproduct/edit/${product.id}"
Basically try to take ${pageContext.request.contextPath} for each c:url
It will converted into "localhost:8080/Carre2"
You just need to access it as follows,
c:url value='/addproduct/edit/${product.id}'
This will make the url to start from your context path.
Or better way could be to store the context path globally and use it in each url. You can refer to context path as follows,
c:url value="${pageContext.request.contextPath}/addproduct/edit/${product.id}"
In my web application I am using Spring Batch Framework and mysql database. In DAO class I am closing all the connection but still I am getting "Too many Connections" Exception.Plz help how to resolve this.
This is my Spring Batch configuration files:
EramBatchJob.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="location">
<beans:value>eramBatchApp.properties</beans:value>
</beans:property>
</beans:bean>
<beans:import resource="EramGBT-JOBREPOSITORY.xml"/>
<!-- Headers -->
<beans:bean id="accountHeader" class="com.order.batch.AccountHeader" scope="step">
<beans:property name="seperator" value="#{jobParameters['Delimiter']}">
</beans:property>
</beans:bean>
<beans:bean id="customerHeader" class="com.order.batch.CustomerHeader" scope="step">
<beans:property name="seperator" value="#{jobParameters['Delimiter']}"></beans:property>
</beans:bean>
<beans:bean id="finstatHeader" class="com.order.batch.FinStatHeader" scope="step">
<beans:property name="seperator" value="#{jobParameters['Delimiter']}"></beans:property>
</beans:bean>
<!-- Headers -->
<!-- Asynchronous Executor -->
<beans:bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" scope="step">
<!-- <beans:property name="concurrencyLimit" value="5"/> -->
<beans:property name="concurrencyLimit" value="#{jobParameters['concurrencyLimit']}"/>
</beans:bean>
<!-- Reader -->
<beans:bean id="accountInfoFileReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<beans:property name="resource" value="file:#{jobParameters['resource']}" />
<beans:property name="lineMapper">
<beans:bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<beans:property name="lineTokenizer">
<beans:bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<!-- <beans:property name="delimiter" value=" "/> -->
<!-- <beans:property name="columns" value="1-30,31-120,121-190,191-260,261-310,311-360,361-370,371-380,381-382,420-423,400-419,385-393,424-451" /> Correct -->
<!-- <beans:property name="columns" value="1-30,31-120,121-190,191-260,261-310,311-360,361-370,371-380,381-382,371-380,400-419,385-393,420-451" /> -->
<beans:property name="columns" value="#{jobParameters['InputDeLimiter']}" />
<beans:property name="names" value="accountNumber,businessName,addr1,addr2,city,state,zip,phone,countryCode,phoneCode,bizID,duns,dummy" />
</beans:bean>
</beans:property>
<beans:property name="fieldSetMapper">
<beans:bean class="com.order.batch.AccountInfoFiledSetMap" />
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<!-- Processor -->
<beans:bean id="productOrderProccesor" class="com.order.batch.ProductOrderProccesor" scope="step">
<beans:property name="toolKitId" value="#{jobParameters['toolKitId']}"/>
<beans:property name="toolKitPwd" value="#{jobParameters['toolKitPwd']}"/>
</beans:bean>
<!-- Wrtiter -->
<!-- Account File Writer -->
<beans:bean id="accountFileWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
<beans:property name="resource" value="file:#{jobParameters['AccountFilePath']}" />
<!-- <beans:property name="appendAllowed" value="true" />-->
<!--<beans:property name="shouldDeleteIfExists" value="true"/> -->
<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<beans:property name="delimiter" value="#{jobParameters['Delimiter']}"/>
<!-- <beans:property name="columns" value="1-30,31-120,121-190,191-260,261-310,311-360,361-370,371-380,381-382,371-380,400-419,385-393,420-452" /> -->
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<beans:property name="names" value="sacct_Nbr_Cust,scountryCode_Cust,sCrcy_Cd,sDuns_Nbr,sEnq_Duns,sPrim_Name,sAddr_Line,sPost_Town,sPrim_Geo_Area,sPost_Cd,sCntry_Cd,sTlcm_Nbr,sCurr_Cntl_Yr,sTotl_Emp,sPrim_Sic,sLoc_Stat,sLgl_Form,sAddr_Tenr_Type_Cd,sCeo_Nme,sPayd_Scr,sPays_3_Mo_Ago,sPayd_Norm,sAvg_High_Cr,sHigh_Cr,sTot_Pmt,sFinl_Embt_Ind,sOut_Bus_In,sCrim_Ind,sHist_Ind,sImpt_Ind,sExpt_Ind,sDnb_Ratg,sRat_Cd,sAaa_Rat,sBus_Stru,sHq_Duns,sHq_Nme,sHq_Cntry_Cd,sPnt_Nme,sPnt_Duns,sPnt_Ctry_Cd,sDom_Ult_Pnt_Nme,sDom_Ult_Pnt_Duns,sDom_Ult_Ctry_Cd,sGbl_Ult_Pnt_Nme,sGbl_Ult_Pnt_Duns,sGbl_Ult_Ctry_Cd,sDelq_Scr_Entr_Natl_Pctl,sDelq_Scr_Entr_Inds_Pctl,sDelq_Scr_Entr_Inds_Defu_Indn,sFail_Scr_Entr_Natl_Pctl,sFail_Scr_Entr_Defu_Indn,sFail_Scr_Entr_Inds_Pctl,sFail_Scr_Entr_Inds_Defu_Indn,sCurr_Rato,sQk_Rato,sClm_Ind,sSuit_Jdgt_Ind,sTrdg_Styl,sTrdg_Styl1,sTrdg_Styl2,sTrdg_Styl3,sTrdg_Styl4,sPrim_Sic,sPrim_Sic_Type_Cd,sLcl_Atv_Cd,sLcl_Actv_Cd_Type,sStrt_Yr,sBus_Regn_Nbr,sMax_Cr,sIncn_Yr,sEu_Admin_App,sEu_Burgalary_Ind,sEu_Bus_Cease_Ind,sEu_Bus_Windup_Ind,sFire_Ind,sEu_Insol_Stmt,sEu_Liqd_It,sEu_Meet_Crdtr,sEu_Min_Dat_Ind,sEu_Misc_Ovrd,sEu_Neg_Inf_Ind,sFail_Scr_Entr_Scr_Cmty_Cd,sFail_Scr_Entr_Scr_Cmty_Cd1,sFail_Scr_Entr_Scr_Cmty_Cd2,sFail_Scr_Entr_Scr_Cmty_Cd3,sFail_Scr_Entr_Scr_Cmty_Cd4,sFail_Scr_Entr_Scr_Cmty_Cd5,sFail_Scr_Entr_Scr_Cmty_Cd6,sFail_Scr_Entr_Scr_Cmty_Cd7,sFail_Scr_Entr_Scr_Cmty_Cd8,sFail_Scr_Entr_Scr_Cmty_Cd9,sFail_Scr_Entr_Scr_Cmty_Cd10,sFail_Scr_Entr_Scr_Cmty_Cd11,sFail_Scr_Entr_Scr_Cmty_Cd12,sFail_Scr_Entr_Scr_Cmty_Cd13,sFail_Scr_Entr_Scr_Cmty_Cd14,sFail_Scr_Entr_Scr_Cmty_Cd15,sFail_Scr_Entr_Scr_Cmty_Cd16,sFail_Scr_Entr_Scr_Cmty_Cd17,sFail_Scr_Entr_Scr_Cmty_Cd18,sFail_Scr_Entr_Scr_Cmty_Cd19,sFail_Scr_Entr_Scr_Cmty_Cd20,sFail_Scr_Entr_Scr_Cmty_Cd21,sFail_Scr_Entr_Scr_Cmty_Cd22,sFail_Scr_Entr_Scr_Cmty_Cd23,sFail_Scr_Entr_Scr_Cmty_Cd24,sFail_Scr_Entr_Scr_Cmty_Cd25,sFail_Scr_Entr_Scr_Cmty_Cd26,sFail_Scr_Entr_Scr_Cmty_Cd27,sFail_Scr_Entr_Scr_Cmty_Cd28,sFail_Scr_Entr_Scr_Cmty_Cd29,sFail_Scr_Entr_Scr_Ovrd_Cd,sFail_Scr_Entr_Scr_Ovrd_Cd1,sFail_Scr_Entr_Scr_Ovrd_Cd2,sFail_Scr_Entr_Scr_Ovrd_Cd3,sFail_Scr_Entr_Scr_Ovrd_Cd4,sDelq_Scr_Entr_Scr_Cmty_Cd,sDelq_Scr_Entr_Scr_Cmty_Cd1,sDelq_Scr_Entr_Scr_Cmty_Cd2,sDelq_Scr_Entr_Scr_Cmty_Cd3,sDelq_Scr_Entr_Scr_Cmty_Cd4,sDelq_Scr_Entr_Scr_Cmty_Cd5,sDelq_Scr_Entr_Scr_Cmty_Cd6,sDelq_Scr_Entr_Scr_Cmty_Cd7,sDelq_Scr_Entr_Scr_Cmty_Cd8,sDelq_Scr_Entr_Scr_Cmty_Cd9,sDelq_Scr_Entr_Scr_Cmty_Cd10,sDelq_Scr_Entr_Scr_Cmty_Cd11,sDelq_Scr_Entr_Scr_Cmty_Cd12,sDelq_Scr_Entr_Scr_Cmty_Cd13,sDelq_Scr_Entr_Scr_Cmty_Cd14,sDelq_Scr_Scr_Ovrd_Cd,sDelq_Scr_Scr_Ovrd_Cd1,sDelq_Scr_Scr_Ovrd_Cd2,sDelq_Scr_Scr_Ovrd_Cd3,sDelq_Scr_Scr_Ovrd_Cd4,sDast_Ref_Dt,sRate_Id,sRpt_Net_Wrth,sRpt_Net_Sls,sRpt_Net_Income,sCustomer_Bs_Name,dummydelimiter"/>
</beans:bean>
</beans:property>
</beans:bean>
</beans:property>
<beans:property name="headerCallback" ref="accountHeader"></beans:property>
</beans:bean>
<!-- Customer File Writer -->
<beans:bean id="customerFileWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
<beans:property name="resource" value="file:#{jobParameters['CustomerFilePath']}" />
<!-- <beans:property name="appendAllowed" value="true" /> -->
<!--<beans:property name="shouldDeleteIfExists" value="true"/> -->
<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<beans:property name="delimiter" value="#{jobParameters['Delimiter']}"/>
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<beans:property name="names" value="sacct_Nbr_Cust,sbusiness_Nme_Cust,saddr1_Cust,saddr2_Cust,scity_Cust,sstate_Cust,szip_Cust,sphoneCode_Cust,sphone_Cust,scountryCode_Cust,sDuns_cust"/>
</beans:bean>
</beans:property>
</beans:bean>
</beans:property>
<beans:property name="headerCallback" ref="customerHeader"></beans:property>
</beans:bean>
<!-- Finance Statement Writer -->
<beans:bean id="financeStatFileWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
<beans:property name="resource" value="file:#{jobParameters['FinStatFilePath']}" />
<!-- <beans:property name="appendAllowed" value="true" /> -->
<!-- <beans:property name="shouldDeleteIfExists" value="true"/> -->
<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<beans:property name="delimiter" value="#{jobParameters['Delimiter']}"/>
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<beans:property name="names" value="sacct_Nbr_Cust,sDnb_Ind,sCash_Liq_Aset,sAct_Rec,sAct_Pay,sStk,sTot_Curr_Aset,sTot_Curr_Liab,sTot_Aset,sTot_Liab,sNet_Wrth,sItng_Aset,sSls,sNet_Incm,sStmt_Dt,sStmt_Type,sRate_Id,sStmt_Crcy_Cd,dummydelimiter"/>
</beans:bean>
</beans:property>
</beans:bean>
</beans:property>
<beans:property name="headerCallback" ref="finstatHeader"></beans:property>
</beans:bean>
<!-- Composite Writer -->
<beans:bean id="compositeWriter" class="org.springframework.batch.item.support.CompositeItemWriter">
<beans:property name="delegates">
<beans:list>
<beans:ref bean="accountFileWriter" />
<beans:ref bean="customerFileWriter" />
<beans:ref bean="financeStatFileWriter" />
</beans:list>
</beans:property>
</beans:bean>
<!-- Writers fro Skip Plocies -->
<beans:bean id="excludeWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<beans:property name="shouldDeleteIfExists" value="true"/>
<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<beans:property name="delimiter" value=","/>
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<beans:property name="names" value="errormessage,accountNumber,businessName,addr1,addr2,city,state,zip,phone,countryCode,phoneCode,bizID,duns"/>
</beans:bean>
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<beans:bean id="writeWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<beans:property name="shouldDeleteIfExists" value="true"/>
<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<beans:property name="delimiter" value=","/>
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<beans:property name="names" value="sAcct_Nbr,sDuns_Nbr,sCustomer_Bs_Name"/>
</beans:bean>
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<!-- Listeners -->
<beans:bean id="eramBatchListener" class="com.order.batch.EramJobListener">
<beans:property name="excludeWriter" ref="excludeWriter" ></beans:property>
<beans:property name="writeWriter" ref="writeWriter" ></beans:property>
</beans:bean>
<!-- Job -->
<job id="EramBatchJob" job-repository="jobRepository" >
<step id="step2">
<tasklet transaction-manager="jobRepository-transactionManager" task-executor="taskExecutor">
<chunk reader="accountInfoFileReader" processor="productOrderProccesor" writer="compositeWriter"
commit-interval="#{jobParameters['CommitInterval']}" skip-limit="10000" retry-limit="1">
<streams>
<stream ref="compositeWriter"/>
<stream ref="accountInfoFileReader"/>
<stream ref="excludeWriter"/>
<stream ref="writeWriter"/>
</streams>
<retryable-exception-classes>
<include class="java.lang.Exception"/>
</retryable-exception-classes>
<skippable-exception-classes>
<include class="org.springframework.batch.item.file.FlatFileParseException"/>
<include class="org.springframework.batch.item.file.transform.IncorrectLineLengthException"/>
<include class="org.springframework.batch.core.step.skip.NonSkippableReadException"/>
<include class="java.io.IOException"/>
<include class="org.springframework.beans.NotReadablePropertyException"/>
<include class="org.springframework.batch.item.ItemStreamException"/>
<include class="com.order.exception.InvalidDunsOrCountryCodeException"/>
</skippable-exception-classes>
<listeners>
<listener ref="eramBatchListener" />
</listeners>
</chunk>
</tasklet>
<listeners>
<listener ref="eramBatchListener"/>
</listeners>
</step>
<listeners>
<listener ref="eramBatchListener"/>
</listeners>
</job>
</beans:beans>
EramGBT-JOBREPOSITORY.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="jobRepository-dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${EramBatch.App.DataBase.DriverClass}" />
<property name="url" value="${EramBatch.App.DataBase.DataBaseURL}" />
<property name="username" value="${EramBatch.App.DataBase.UserName}" /> <!-- your user id. e.g. root-->
<property name="password" value="${EramBatch.App.DataBase.Password}" /> <!-- your password-->
<property name="maxIdle" value="10"/>
<property name="maxActive" value="100"/>
<property name="maxWait" value="10000"/>
<property name="validationQuery" value="select 1"/>
<property name="testOnBorrow" value="false"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="1200000"/>
<property name="minEvictableIdleTimeMillis" value="1800000"/>
<property name="numTestsPerEvictionRun" value="5"/>
<property name="defaultAutoCommit" value="false"/>
</bean>
<bean id="jobRepository-transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager" lazy-init="true">
<property name="dataSource" ref="jobRepository-dataSource" />
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="jobRepository-dataSource" />
<property name="transactionManager" ref="jobRepository-transactionManager"/>
<property name="isolationLevelForCreate" value="ISOLATION_READ_UNCOMMITTED" />
<property name="databaseType" value="mysql" />
<property name="tablePrefix" value="batch_"/>
</bean>
<bean id="asyncTaskExecutor"
class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
<property name="taskExecutor">
<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
</property>
</bean>
<bean id="jobExplorer"
class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"
p:dataSource-ref="jobRepository-dataSource" p:tablePrefix="batch_" />
<bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry"/>
<bean id="jobOperator" class="org.springframework.batch.core.launch.support.SimpleJobOperator">
<property name="jobExplorer" ref="jobExplorer"/>
<property name="jobRepository" ref="jobRepository"/>
<property name="jobRegistry" ref="jobRegistry" />
<property name="jobLauncher" ref="jobLauncher" />
</bean>
</beans>
This looks like a MySQL error. Try increasing max_connections in /etc/my.cnf.
Also you may look into your app's multiprocessing and threading model. Exhaustion of MySQL connections could indicate a problem where the application is spawning new threads/processes all the time.