Java Reference
In-Depth Information
</dependency>
Because you added the MySQL driver to the POM file, let's configure the connection to the database
next. As covered in Chapter 2, you configure the database connection both for the JobRepository and the
application's database in the statement/src/main/resources/batch.properties file. Listing 10-3 shows
the contents of this file configured for the statement job.
Listing 10-3. batch.properties
# Values to connect to my local
batch.jdbc.driver=com.mysql.jdbc.Driver
batch.jdbc.url=jdbc:mysql://localhost:3306/statement
# use this one for a separate server process so you can inspect the results
# (or add it to system properties with -D to override at run time).
# batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples
batch.jdbc.user=root
batch.jdbc.password=password
batch.schema=statement
The values in the batch.properties file are those required in launch-context.xml :
batch.jdbc.driver : The fully qualified class name of the JDBC driver for the
database you're using. Here, you use MySQL's driver: com.mysql.jdbc.Driver.
batch.jdbc.url : The URL to the database you're connecting to for your
JobRepository. For the example application, you use one database schema for all
tables.
batch.jdbc.user : The username for the database you're connecting to.
batch.jdbc.password : The password for the database.
batch.schema : In MySQL's case, the database you're using.
The last piece of the project setup is to update the launch-context.xml file to prune the beans that
you don't need for this job and update the XSDs to use Spring 3 instead of Spring 2.5 (which they come
configured to use). Listing 10-4 shows the updated statement/src/main/resources/launch-context.xml
file.
Listing 10-4. launch-context.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-3.0.xsd">
<bean id="jobExplorer"
class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"
p:dataSource-ref="dataSource" />
 
Search WWH ::




Custom Search