⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 个人办公平台,用JAVA开发的TOMCAT的服务器
💻 JAVA
字号:
/*
 * Created on 2006-9-30
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package com.skyhawk.hellen;

import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.skyhawk.db.ConnectionFactory;
import com.skyhawk.db.DatabaseUtils;

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class Test extends HttpServlet{
	//Thread thread1,thread2;
	

	public void doPost(HttpServletRequest request,HttpServletResponse response){
		//thread1=new Thread(this);
		//thread2=new Thread(this);
		try {
			request.setCharacterEncoding("GBK");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String user=request.getParameter("user");
		
		String empid=request.getParameter("pw");
		System.out.println(user);
		System.out.println(empid);
		
		Thread1 thread1=new Thread1();
		
		//Thread2 thread2=new Thread2();
		
		thread1.run(request,response);
		//thread2.run(empid);
		Thread3 thread3=new Thread3(); 
		thread3.run();
		//thread1.start();
		//thread2.start();
	/*	if(Thread.currentThread()==thread1){
					Servlet6 servlet=new Servlet6();
					servlet.doPost(request,response);
				}
				if(Thread.currentThread()==thread2){
					for(int i=0;i<5;i++){
						System.out.println("kaakkakakk");
						try {
							sleep(1000);
						} catch (InterruptedException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
			
					}
				}*/
	}

	
}
class Thread1 extends Thread{
	public void run(HttpServletRequest request,HttpServletResponse response){
		
		Servlet6 servlet=new Servlet6();
		servlet.doPost(request,response);
	}
}
/*
class Thread2 extends Thread{
	
	Connection con=null;
									Statement stm=null;
									Statement stm1=null;
									ResultSet rs=null;
					
									ResultSet rs1=null;
					
				
	public void run(String t){
		ConnectionFactory conn=new ConnectionFactory();
								con=conn.getConnection();
								try {
									stm=con.createStatement();
									stm1=con.createStatement();
								} catch (SQLException e1) {
									// TODO Auto-generated catch block
									e1.printStackTrace();
								}
	
	//for (int i=0;;i++){
		
					try {
						rs=stm.executeQuery("select * from o_mesrelation where empid='"+t+"'and read='0'");
					} catch (SQLException e2) {
						// TODO Auto-generated catch block
						e2.printStackTrace();
					}
							try {
									if(rs.next()){
								Tishi ti=new Tishi();
									}else {
										System.out.println("noooo");
									}
							} catch (SQLException e3) {
								// TODO Auto-generated catch block
								e3.printStackTrace();
							}
							//try {
							//	sleep(10000);
							//} catch (InterruptedException e4) {
								// TODO Auto-generated catch block
							//	e4.printStackTrace();
							//}
//	}
	}
}
*/
class Thread3 extends Thread{
	Connection con=null;
										Statement stm=null;
										Statement stm1=null;
										Statement stm2=null;
										ResultSet rs=null;
										ResultSet rs1=null;
	public void run(){
		ConnectionFactory conn=new ConnectionFactory();
										con=ConnectionFactory.getConnection();
		try {
			stm=con.createStatement();
			stm1=con.createStatement();
			stm2=con.createStatement();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		for(int i=0;i<5;i++){
		
		try {
			rs=stm.executeQuery("select tittle from o_message");
		} catch (SQLException e1) {
			e1.printStackTrace();
		}
		try {
			while(rs.next()){
				String tittle=rs.getString("tittle");
				System.out.println(tittle);
				rs1=stm1.executeQuery("select tittle from o_mesrelation where tittle='"+tittle+"'");
				if(!rs1.next()){
					stm2.executeUpdate("delete from o_message where tittle='"+tittle+"'");
				}
				
			}
		} catch (SQLException e2) {
			e2.printStackTrace();
		}
		
		}
		try {
			sleep(1000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		
		
		
	}
}
			
		
	
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -