I. Overview
If you need to use a scheduled task to complete some business in your project, there are generally two approaches: timed tasks depend on the project, scheduled tasks are started with batch processing (Windows execution) or shell scripts (Linux), and are not dependent on the project.
Personally, the timing task does not depend on the project way more excellent! Independent execution, without affecting the performance of the application.
two. Use JDBC to connect to the database to write business
You cannot use advanced methods such as Hibernate, or advanced tools used by the corporate framework. Because the shell script does not depend on the project, it executes independently.
Use JDBC to write simple additions and deletions to check the business demo, specific reference: http://blog.csdn.net/yanzi1225627/article/details/26950615
Finally, the class that completes the business is exported through eclipse as a jar for the shell invocation.
three. Batch processing, shell scripting
BAT file:
. \jdk1.6.0\bin\java -xms512m-xmx512m-xx:newratio=3-classpath.;. /lib/mysql-connector-java-5.1.29.jar;. /lib/match.jar Com.test.web.Match
Shell script:
/usr/java/jdk1.6.0_32/bin/java-xms512m-xmx512m-xx:newratio=3-classpath./match.jar:./ Mysql-connector-java-5.1.29.jar Com.test.web.Match
Where the bat file differs from the shell script in that the JDK is located on a different path
. \jdk1.6.0\bin specifying the JDK path
-xms512m-xmx512m-xx:newratio=3 Configuring memory to run the current script
-classpath.;. /lib/mysql-connector-java-5.1.29.jar;. /lib/match.jar Com.test.web.Match Run the jar that the current script needs to use, and the last one to write for itself and export the generated jar. The script executes to the main method of the Match.class
four. Eclipse Export jar Process
Compiling code
Navigate to the Java file you want to export
Right---export--Select the export type as JRE file--Choose the path to save the jar--Pick the Java file where the main method resides--finish
Detailed instructions can be consulted: http://www.cnblogs.com/lionden/archive/2013/03/10/2952604.html
Executing Java business processes from the project framework with a JDBC database through shell scripting