锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
Field Name | 聽 | Allowed Values | 聽 | Allowed Special Characters |
---|---|---|---|---|
Seconds
|
聽 |
0-59
|
聽 |
, - * /
|
Minutes
|
聽 |
0-59
|
聽 |
, - * /
|
Hours
|
聽 |
0-23
|
聽 |
, - * /
|
Day-of-month
|
聽 |
1-31
|
聽 |
, - * ? / L W C
|
Month
|
聽 |
1-12 or JAN-DEC
|
聽 |
, - * /
|
Day-of-Week
|
聽 |
1-7 or SUN-SAT
|
聽 |
, - * ? / L C #
|
Year (Optional)
|
聽 |
empty, 1970-2099
|
聽 |
, - * /
|
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".
The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". You can also specify '/' after the '*' character - in this case '*' is equivalent to having '0' before the '/'.
The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.
The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".
The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.
The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".
The legal characters and the names of months and days of the week are not case sensitive.
Here are some full examples:
Expression | 聽 | Meaning |
---|---|---|
"0 0 12 * * ?"
|
聽 |
Fire at 12pm (noon) every day
|
"0 15 10 ? * *"
|
聽 |
Fire at 10:15am every day
|
"0 15 10 * * ?"
|
聽 |
Fire at 10:15am every day
|
"0 15 10 * * ? *"
|
聽 |
Fire at 10:15am every day
|
"0 15 10 * * ? 2005"
|
聽 |
Fire at 10:15am every day during the year 2005
|
"0 * 14 * * ?"
|
聽 |
Fire every minute starting at 2pm and ending at 2:59pm, every day
|
"0 0/5 14 * * ?"
|
聽 |
Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
|
"0 0/5 14,18 * * ?"
|
聽 |
Fire
every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5
minutes starting at 6pm and ending at 6:55pm, every day
|
"0 0-5 14 * * ?"
|
聽 |
Fire every minute starting at 2pm and ending at 2:05pm, every day
|
"0 10,44 14 ? 3 WED"
|
聽 |
Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
|
"0 15 10 ? * MON-FRI"
|
聽 |
Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
|
"0 15 10 15 * ?"
|
聽 |
Fire at 10:15am on the 15th day of every month
|
"0 15 10 L * ?"
|
聽 |
Fire at 10:15am on the last day of every month
|
"0 15 10 ? * 6L"
|
聽 |
Fire at 10:15am on the last Friday of every month
|
"0 15 10 ? * 6L"
|
聽 |
Fire at 10:15am on the last Friday of every month
|
"0 15 10 ? * 6L 2002-2005"
|
聽 |
Fire at 10:15am on every last friday of every month during the years 2002, 2003, 2004 and 2005
|
"0 15 10 ? * 6#3"
|
聽 |
Fire at 10:15am on the third Friday of every month
|
Pay attention to the effects of '?' and '*' in the day-of-week and day-of-month fields!
NOTES:
緗戝潃錛?a src="http://antelope.tigris.org/">http://antelope.tigris.org/
鎴戠敤鍒拌繃涓涓帶鍒舵椂闂寸殑
2銆?font size="4">ant-contrib
緗戝潃錛?a src="ant-contrib.sourceforge.net">ant-contrib.sourceforge.net
鎴戠敤鍒拌繃<if><else><then>絳夐昏緫鏍囩銆?br />
涓嬮潰鏄垜鍐欑殑涓涓猘nt鐗囨柇錛岀敤鏉opy涓嶅瓨鍦ㄧ殑鏂囦歡錛屽鏋滃瓨鍦紝鍒欒闂槸鍚﹁鐩栥?br />聽<!--聽 tasks for copy required system files -->
聽<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="../WEB-INF/lib/ant-contrib-1.0b2.jar" />
聽<target name="deploySysFiles">
聽聽<var name="targetFile" unset="true" />
聽聽<property name="targetFile" value="${JavaStatusSchemePath}" />
聽聽<var name="originalFile" unset="true"/>
聽聽<property name="originalFile" value="${JavaStatusSchemePath-Original}"/>
聽聽<antcall target="deploySysFile" />
聽</target>
聽<target name="deploySysFile">
聽聽<echo>check file : ${targetFile} exist or not</echo>
聽聽<available file="${targetFile}" property="targetFileExisting" />
聽聽<if>
聽聽聽<not>
聽聽聽聽<isset property="targetFileExisting" />
聽聽聽</not>
聽聽聽<then>
聽聽聽聽<antcall target="copyTargetFile" />
聽聽聽</then>
聽聽聽<elseif>
聽聽聽聽<isset property="targetFileExisting" />
聽聽聽聽<then>
聽聽聽聽聽<antcall target="overrideTargetFile" />
聽聽聽聽</then>
聽聽聽</elseif>
聽聽</if>
聽聽<echo>deploy system files over</echo>
聽</target>
聽<target name="overrideTargetFile">
聽聽<limit seconds="${timeoutSecond}">
聽聽聽<input validargs="y,n" addproperty="answer" defaultvalue="n" message="file '${targetFile}' already existed,do you want to override?" />
聽聽</limit>
聽聽<condition property="override">
聽聽聽<equals arg1="y" arg2="${answer}" />
聽聽</condition>
聽聽<if>
聽聽聽<isset property="override" />
聽聽聽<then>
聽聽聽聽<echo>override the file...</echo>
聽聽聽聽<copy tofile="${targetFile}" file="${originalFile}" overwrite="true" encoding="ms932" />
聽聽聽</then>
聽聽</if>
聽</target>
聽<target name="copyTargetFile">
聽聽<echo>file ${targetFile} dose not existed,deploying this file</echo>
聽聽<copy file="${originalFile}" tofile="${targetFile}" encoding="ms932" />
聽</target>
聽<!-- end copy system files. -->
import com.sshtools.net.*;
import com.sshtools.sftp.*;
/**
聽* This example demonstrates the connection process connecting to an SSH2 server
聽* and usage of the SFTP client.
聽*/
public class MySftpConnect {
聽public static void main(String[] args) {
聽聽MySftpConnect c = new MySftpConnect();
聽聽c.createSftpClient("192.168.0.108", "szb", "szbpatternx86", 22);錛嶏紞鍙傛暟渚濇涓轟富鏈哄悕錛岀敤鎴峰悕錛屽瘑鐮侊紝绔彛鍙楓?br />聽}
聽public void createSftpClient(String hostname, String username,
聽聽聽String password, int port) {
聽聽try {
聽聽聽System.out.println("Connecting to " + hostname);
聽聽聽// Create an SshConnector instance
聽聽聽SshConnector con = SshConnector.getInstance();
聽聽聽// Connect to the host
聽聽聽SocketTransport t = new SocketTransport(hostname, port);
聽聽聽t.setTcpNoDelay(true);
聽聽聽SshClient ssh = con.connect(t, username);
聽聽聽Ssh2Client ssh2 = (Ssh2Client) ssh;
聽聽聽// Authenticate the user using password authentication
聽聽聽com.maverick.ssh.PasswordAuthentication pwd = new com.maverick.ssh.PasswordAuthentication();
聽聽聽do {
聽聽聽聽pwd.setPassword(password);
聽聽聽} while (ssh2.authenticate(pwd) != SshAuthentication.COMPLETE
聽聽聽聽聽&& ssh.isConnected());
聽聽聽// Start a session and do basic IO
聽聽聽if (ssh.isAuthenticated()) {
聽聽聽聽SftpClient sftp = new SftpClient(ssh2);
聽聽聽聽// test create file.
聽聽聽聽this.createTestFile(sftp);
聽聽聽}
聽聽} catch (Throwable th) {
聽聽聽th.printStackTrace();
聽聽}
聽}
//嫻嬭瘯IO鎿嶄綔
聽public void createTestFile(SftpClient sftp) throws Exception {
聽聽File textFile = new File(System.getProperty("user.home"), "shining.txt");
聽聽FileOutputStream tout = new FileOutputStream(textFile);
聽聽// Create a file with \r\n as EOL
聽聽for (int i = 0; i < 100; i++) {
聽聽聽tout.write("All work and no play makes Jack a dull boy涓枃\r\n"
聽聽聽聽聽.getBytes());
聽聽}
聽聽tout.close();
聽聽// Perform some text mode operations鎸囧畾鏂囦歡瀛樺偍涓簍xt綾誨瀷
聽聽sftp.setTransferMode(SftpClient.MODE_TEXT);
聽聽// Tell the client which EOL the remote client is using - note
聽聽// that this will be ignored with version 4 of the protocol
聽聽sftp.setRemoteEOL(SftpClient.EOL_LF);
聽聽//灝嗘枃浠朵笂浼犲埌鏈嶅姟鍣?br />聽聽sftp.put(textFile.getAbsolutePath());
聽}
}
鍐欑殑涓嶅お璇︾粏錛岃鍙傝冿細http://3sp.com/kb/idx/0/014/article/Getting_started_with_J2SSH_Maverick.html
2. PostgreSQL(http://www.de.postgresql.org)pgjdbc2.jar
Class.forName( "org.postgresql.Driver" );
cn = DriverManager.getConnection( "jdbc:postgresql://MyDbComputerNameOrIP/myDatabaseName", sUsr, sPwd );
3. Oracle(http://www.oracle.com/ip/deploy/database/oracle9i/)classes12.zip
Class.forName( "oracle.jdbc.driver.OracleDriver" );
cn = DriverManager.getConnection( "jdbc:oracle:thin:@MyDbComputerNameOrIP:1521:ORCL", sUsr, sPwd );
4. Sybase(http://jtds.sourceforge.net)jconn2.jar
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
cn = DriverManager.getConnection( "jdbc:sybase:Tds:MyDbComputerNameOrIP:2638", sUsr, sPwd );
//(Default-Username/Password: "dba"/"sql")
5. Microsoft SQLServer(http://jtds.sourceforge.net)
Class.forName( "net.sourceforge.jtds.jdbc.Driver" );
cn = DriverManager.getConnection( "jdbc:jtds:sqlserver://MyDbComputerNameOrIP:1433/master", sUsr, sPwd );
6. Microsoft SQLServer(http://www.microsoft.com)
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
cn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://MyDbComputerNameOrIP:1433;databaseName=master", sUsr, sPwd );
7. ODBC
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection cn = DriverManager.getConnection( "jdbc:odbc:" + sDsn, sUsr, sPwd );
8.DB2(鏂版坊鍔?
Class.forName("com.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://192.9.200.108:6789/SAMPLE"
cn = DriverManager.getConnection( url, sUsr, sPwd );
9.Microsoft SQL Server series (6.5, 7.x and 2000) and Sybase 10
JDBC Name: jTDS
URL: http://jtds.sourceforge.net/
Version: 0.5.1
Download URL: http://sourceforge.net/project/showfiles.php?group_id=33291
璇硶:
Class.forName("net.sourceforge.jtds.jdbc.Driver ");
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");
or
Connection con = DriverManager.getConnection("jdbc:jtds:sybase://host:port/database","user","password");
10.Postgresql
JDBC Name: PostgreSQL JDBC
URL: http://jdbc.postgresql.org/
Version: 7.3.3 build 110
Download URL: http://jdbc.postgresql.org/download.html
璇硶:
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
11.IBM AS400涓繪満鍦ㄧ敤鐨凧DBC璇硶
鏈夎V4R4浠ヤ笂鐗堟湰鐨凜lient Access Express
鍙互鍦–:\Program Files\IBM\Client Access\jt400\lib
鎵懼埌 driver 妗f jt400.zip錛屽茍鏇存敼鎵╁睍鍚嶆垚涓?jt400.jar
璇硶:
java.sql.DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
Class.forName("com.ibm.as400.access.AS400JDBCConnection");
con = DriverManager.getConnection("jdbc:as400://IP","user","password");
12.informix
Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword";
Lib錛歫dbcdrv.zip
Class.forName( "com.sybase.jdbc.SybDriver" )
url="jdbc:sybase:Tds:127.0.0.1:2638/asademo";
SybConnection connection= (SybConnection)DriverManager.getConnection(url,"dba","sql");
13.SAP DB
Class.forName ("com.sap.dbtech.jdbc.DriverSapDB");
java.sql.Connection connection = java.sql.DriverManager.getConnection ( "jdbc:sapdb://" + host + "/" + database_name,user_name, password)
14.InterBase
String url = "jdbc:interbase://localhost/e:/testbed/database/employee.gdb";
Class.forName("interbase.interclient.Driver");
//Driver d = new interbase.interclient.Driver (); /* this will also work if you do not want the line above */
Connection conn = DriverManager.getConnection( url, "sysdba", "masterkey" );
15.HSqlDB
url: http://hsqldb.sourceforge.net/
driver: org.hsqldb.jdbcDriver
榪炴帴鏂瑰紡鏈?縐嶏紝鍒嗗埆涓猴細
con-str錛堝唴瀛橈級: jdbc:hsqldb.
con-str錛堟湰鍦幫級: jdbc:hsqldb:/path/to/the/db/dir
con-str錛坔ttp錛? jdbc:hsqldb:http://dbsrv
con-str錛坔sql錛? jdbc:hsqldb:hsql://dbsrv