JAVA File(ResetStatus):
package com.djx.reflect;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
public class ResetStatus {
private static String driverClass;
private static String url;
private static String username;
private static String password;
private static Statement stmt = null;
private static Connection conn = null;
private static String sqlUpdate;
public static void init(String[] args) throws ClassNotFoundException,
SQLException, IOException {
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream(
"xmlConversion.properties"));
// InputStream in = new BufferedInputStream(
// new FileInputStream(
// "C:\\xmlConversion.properties"));
props.load(in);
driverClass = props.getProperty("driverClass");
url = props.getProperty("url");
username = props.getProperty("username");
password = props.getProperty("password");
Class.forName(driverClass);
conn = DriverManager.getConnection(url, username, password);
stmt = conn.createStatement();
if (("A").equals(args[0])) {
sqlUpdate = props.getProperty("updateA");
System.out.println("Update this sql:\t" + sqlUpdate);
} else if (("B").equals(args[0])) {
sqlUpdate = props.getProperty("updateB");
System.out.println("Update this sql:\t" + sqlUpdate);
}
stmt.execute(sqlUpdate);
}
/**
* @throws SQLException
*
*/
private static void close() throws SQLException {
// TODO Auto-generated method stub
stmt.close();
conn.close();
}
public static void main(String[] args) throws ClassNotFoundException,
SQLException, IOException {
if (args == null || args.length != 1) {
System.out
.println("Help:\tjava -jar ResetStatus.jar APPLICATION_REFERENCE");
System.out
.println("APPLICATION_REFERENCE:\tA\tB");
System.out
.println("Example:java -jar ResetStatus.jar A");
System.out
.println("Example:java -jar ResetStatus.jar B");
} else {
SimpleDateFormat sdf = new SimpleDateFormat(
"dd-MMM-yyyy hh:mm:ss aaa");
Date start = new Date();
long startTime = start.getTime();
System.out.println("Satrt Time:" + sdf.format(start));
init(args);
Date end = new Date();
System.out.println("End Time:" + sdf.format(end));
long endTime = end.getTime();
System.out.println("Cost Time:" + (endTime - startTime) / 1000
+ "(s) " + (endTime - startTime) / (1000 * 60)
+ "(minutes) " + (endTime - startTime) / (1000 * 60 * 60)
+ "(hours)");
close();
}
}
}
Properties File(xmlConversion.properties):
#Reset the initializing value
#
updateA = update test ATD \
set atd.application_reference = 'A' \
where atd.id = 1 \
and atd.application_reference = 'A@@FINISHED'
updateB = update test ATD \
set atd.application_reference = 'B' \
where atd.id = 1 \
and atd.application_reference = 'B@@FINISHED'
MF文件需要导入多个jar包的时候、太长的时候要换行、不然会报错、换行记得下面两点、缺一不可(MF文件的语法太死板):
Class-Path: . lib/aaa.jar
lib/bbb.jar
lib/ccc.jar
关键点:1)每行开头结尾都要有空格
2)最后一行写完后,要回车两次,而且要确保回车的两行都是顶格!