Executing Java business processes from the project framework with a JDBC database through shell scripting

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.