📄 testautorun.java
字号:
package myseverlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import myseverlet.PickTask;
public class TestAutoRun extends HttpServlet
{
private static final String HttpServletRequest = null;
private HttpServletRequest request;
private PrintWriter out;
private int count;
//当servlet类被加载时,执行本函数
//在本方法中放置代码即可完成自动加载
public void init(ServletConfig config) throws ServletException
{
super.init(config);
//此处放置需要自动执行的代码
System.out.println("I 'm ok now.");
timerUse();
}
public void timerUse()
{
// 一个小时进行一次查询
PickTask ptw = new PickTask();
ptw.start(0, 1800);
// System.out.println("timerUse is in");
// Test test = new Test();
// test.runDb();
// TestOracle testOracle = new TestOracle();
// testOracle.runDb();
// // oracle to mysql
// OracleToMysql oracleToMysql = new OracleToMysql();
// oracleToMysql.transDb();
// //mssql
// TestMssql testMssql = new TestMssql();
// testMssql.runDb();
// Writelog writelog = new Writelog();
// writelog.runWritelog();
// TestRead testRead = new TestRead();
// try {
// testRead.readRun();
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// ReadTxtDataBatch readTxtDataBatch = new ReadTxtDataBatch();
// try {
// readTxtDataBatch.readRun();
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// Sample1 sample1 = new Sample1();
// try {
// sample1.run();
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
/**
* Process the HTTP Get request
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
//以下是标准的GET方法处理,由http的GET方法触发(调用)
this.doPost(request, response);
}
//Process the HTTP Post request
//标准的POST方法处理,由http的POST方法触发(调用)
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html; charset=GB2312");
PrintWriter out = response.getWriter();
this.request = request;
this.out = out;
out.println("<html>");
out.println("<head>");
out.println("</head>");
out.println("<body>");
out.println("this is a test.<br>");
out.println("</body>");
out.println("</html>");
}
/**
* Clean up resources
*/
public void destroy()
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -