log.java

来自「《移动Agent技术》一书的所有章节源代码。」· Java 代码 · 共 1,143 行 · 第 1/3 页

JAVA
1,143
字号
	public int Change17(String Unit){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		//System.out.println("record is: "+record);
		PreparedStatement pstm;
		try{
		

			
	
		//	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record);
			pstm=con.prepareStatement("Update MonitoredValueInfo set Change="+0+"where MonitoredValueID="+7+"and UnitName="+"'"+Unit+"'");
			i=pstm.executeUpdate();  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			}
		}
		
      return i;     	
	}	
	
	
		public int Change2(){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		//System.out.println("record is: "+record);
		PreparedStatement pstm;
		try{
		

			
	
		//	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record);
			pstm=con.prepareStatement("Update AgentSetupValueInfo set Change="+0+"where ValueID="+1);
			i=pstm.executeUpdate();  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			}
		}
		
      return i;     	
	}
	//
		public int Change3(){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		//System.out.println("record is: "+record);
		PreparedStatement pstm;
		try{
		

			
	
		//	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record);
			pstm=con.prepareStatement("Update AgentSetupValueInfo set Change="+0+"where ValueID="+2);
			i=pstm.executeUpdate();  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			}
		}
		
      return i;     	
	}
	//
	public int Update(int record){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		System.out.println("record is: "+record);
		PreparedStatement pstm;
		ResultSet rsrs=null;
		//
		tableSql ttt;
		ttt=new tableSql();
		ttt.tableInit("cqjk");
		String insert="";
		int MonitoredValueID=0,MonitoredValue=0;
		try{
		
	//	pstm=con.prepareStatement("Update AgentStatusInfo set AgentWorkStatus="+"'"+running+"'");	
			
	
		//	pstm=con.prepareStatement("Update AgentStatusInfo set HostName="+"'"+address+"'"+","+"AgentName="+"'"+classname+"'"+","+"AgentWorkStatus="+"'"+running+"'"+","+"AgentConnectionStatus="+"'"+ok+"'"+","+"WritingTime="+"'"+logtime+"'");
		//
		     rsrs=ttt.recordSql("select * from MonitoredValueInfo where MonitoredValueID="+1);
				if (!rsrs.next())
				{
				insert=insert+1+","+record;
				System.out.println("the insert :"+insert);
				ttt.recordInsert("insert into MonitoredValueInfo(MonitoredValueID,MonitoredValue) values("+insert+")"); 
				}
				else 
				{
			   	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record+"where MonitoredValueID="+1);
			   i=pstm.executeUpdate();  
				}
			rsrs.close();
			ttt.closeConnect();
					
		//
		  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			                }
	                       	}
		
      return i;     	
	}
	//
		public int Update1(int record){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		System.out.println("record is: "+record);
		PreparedStatement pstm;
		ResultSet rsrs=null;
		//
		tableSql ttt;
		ttt=new tableSql();
		ttt.tableInit("cqjk");
		String insert="";
		int MonitoredValueID=0,MonitoredValue=0;
		try{
		
	//	pstm=con.prepareStatement("Update AgentStatusInfo set AgentWorkStatus="+"'"+running+"'");	
			
	
		//	pstm=con.prepareStatement("Update AgentStatusInfo set HostName="+"'"+address+"'"+","+"AgentName="+"'"+classname+"'"+","+"AgentWorkStatus="+"'"+running+"'"+","+"AgentConnectionStatus="+"'"+ok+"'"+","+"WritingTime="+"'"+logtime+"'");
		//
		     rsrs=ttt.recordSql("select * from MonitoredValueInfo where MonitoredValueID="+2);
				if (!rsrs.next())
				{
				insert=insert+2+","+record;
				System.out.println("the insert :"+insert);
				ttt.recordInsert("insert into MonitoredValueInfo(MonitoredValueID,MonitoredValue) values("+insert+")"); 
				}
				else 
				{
			   	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record+"where MonitoredValueID="+2);
			   i=pstm.executeUpdate();  
				}
			rsrs.close();
			ttt.closeConnect();
					
		//
		  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			                }
	                       	}
		
      return i;     	
	}
	//
	public int Update13(int record){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		System.out.println("record is: "+record);
		PreparedStatement pstm;
		ResultSet rsrs=null;
		//
		tableSql ttt;
		ttt=new tableSql();
		ttt.tableInit("cqjk");
		String insert="";
		int MonitoredValueID=0,MonitoredValue=0;
		try{
		
	//	pstm=con.prepareStatement("Update AgentStatusInfo set AgentWorkStatus="+"'"+running+"'");	
			
	
		//	pstm=con.prepareStatement("Update AgentStatusInfo set HostName="+"'"+address+"'"+","+"AgentName="+"'"+classname+"'"+","+"AgentWorkStatus="+"'"+running+"'"+","+"AgentConnectionStatus="+"'"+ok+"'"+","+"WritingTime="+"'"+logtime+"'");
		//
		     rsrs=ttt.recordSql("select * from MonitoredValueInfo where MonitoredValueID="+3);
				if (!rsrs.next())
				{
				insert=insert+3+","+record;
				System.out.println("the insert :"+insert);
				ttt.recordInsert("insert into MonitoredValueInfo(MonitoredValueID,MonitoredValue) values("+insert+")"); 
				}
				else 
				{
			   	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record+"where MonitoredValueID="+3);
			   i=pstm.executeUpdate();  
				}
			rsrs.close();
			ttt.closeConnect();
					
		//
		  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			                }
	                       	}
		
      return i;     	
	}
	public int Update14(int record){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		System.out.println("record is: "+record);
		PreparedStatement pstm;
		ResultSet rsrs=null;
		//
		tableSql ttt;
		ttt=new tableSql();
		ttt.tableInit("cqjk");
		String insert="";
		int MonitoredValueID=0,MonitoredValue=0;
		try{
		
	//	pstm=con.prepareStatement("Update AgentStatusInfo set AgentWorkStatus="+"'"+running+"'");	
			
	
		//	pstm=con.prepareStatement("Update AgentStatusInfo set HostName="+"'"+address+"'"+","+"AgentName="+"'"+classname+"'"+","+"AgentWorkStatus="+"'"+running+"'"+","+"AgentConnectionStatus="+"'"+ok+"'"+","+"WritingTime="+"'"+logtime+"'");
		//
		     rsrs=ttt.recordSql("select * from MonitoredValueInfo where MonitoredValueID="+4);
				if (!rsrs.next())
				{
				insert=insert+4+","+record;
				System.out.println("the insert :"+insert);
				ttt.recordInsert("insert into MonitoredValueInfo(MonitoredValueID,MonitoredValue) values("+insert+")"); 
				}
				else 
				{
			   	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record+"where MonitoredValueID="+4);
			   i=pstm.executeUpdate();  
				}
			rsrs.close();
			ttt.closeConnect();
					
		//
		  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			                }
	                       	}
		
      return i;     	
	}
	public int Update15(int record){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		System.out.println("record is: "+record);
		PreparedStatement pstm;
		ResultSet rsrs=null;
		//
		tableSql ttt;
		ttt=new tableSql();
		ttt.tableInit("cqjk");
		String insert="";
		int MonitoredValueID=0,MonitoredValue=0;
		try{
		
	//	pstm=con.prepareStatement("Update AgentStatusInfo set AgentWorkStatus="+"'"+running+"'");	
			
	
		//	pstm=con.prepareStatement("Update AgentStatusInfo set HostName="+"'"+address+"'"+","+"AgentName="+"'"+classname+"'"+","+"AgentWorkStatus="+"'"+running+"'"+","+"AgentConnectionStatus="+"'"+ok+"'"+","+"WritingTime="+"'"+logtime+"'");
		//
		     rsrs=ttt.recordSql("select * from MonitoredValueInfo where MonitoredValueID="+5);
				if (!rsrs.next())
				{
				insert=insert+5+","+record;
				System.out.println("the insert :"+insert);
				ttt.recordInsert("insert into MonitoredValueInfo(MonitoredValueID,MonitoredValue) values("+insert+")"); 
				}
				else 
				{
			   	pstm=con.prepareStatement("Update MonitoredValueInfo set MonitoredValue="+record+"where MonitoredValueID="+5);
			   i=pstm.executeUpdate();  
				}
			rsrs.close();
			ttt.closeConnect();
					
		//
		  
      		
      }                   
		catch(SQLException ex){
			System.out.println("\n***SQLException caught ***\n");
			while (ex != null){
				System.out.println("SQLState:"+ex.getSQLState());
				System.out.println("Message:"+ex.getMessage());	
				System.out.println("Vendor:"+ex.getErrorCode());
				ex=ex.getNextException();
				System.out.println("");
			                }
	                       	}
		
      return i;     	
	}
	
	//
	public int Update16(String record){
		int i=0;
		//Date ndate = new Date();
		//String logtime=ndate.toString();
		System.out.println("record is: "+record);
		PreparedStatement pstm;
		ResultSet rsrs=null;
		//
		tableSql ttt;
		ttt=new tableSql();
		ttt.tableInit("cqjk");
		String insert="";
		int MonitoredValueID=0,MonitoredValue=0;
		try{
		
	//	pstm=con.prepareStatement("Update AgentStatusInfo set AgentWorkStatus="+"'"+running+"'");	
			
	
		//	pstm=con.prepareStatement("Update AgentStatusInfo set HostName="+"'"+address+"'"+","+"AgentName="+"'"+classname+"'"+","+"AgentWorkStatus="+"'"+running+"'"+","+"AgentConnectionStatus="+"'"+ok+"'"+","+"WritingTime="+"'"+logtime+"'");
		//
		     rsrs=ttt.recordSql("select * from MonitoredValueInfo where MonitoredValueID="+6);
				if (!rsrs.next())
				{
				insert=insert+6+","+"'"+record+"'";
				System.out.println("the insert :"+insert);
				ttt.recordInsert("insert into MonitoredValueInfo(MonitoredValueID,MonitoredValue) values("+insert+")"); 

⌨️ 快捷键说明

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