docbean.java

来自「新闻发布系统」· Java 代码 · 共 64 行

JAVA
64
字号
package oa.bean;

import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;

public class DocBean extends ParentBean{

  public DocBean()throws Exception {
  }

  public int getMaxValue(String table,String value){
       String strSQL="select "+value+" as maxvalue from "+table+" where "+value+"=(select max("+value+") from "+table+")";
       ResultSet rs = db.QuerySQL(strSQL);
       int rValue;
       rValue=0;
		Statement stmt = null;
		try{
       while(rs.next()){
         rValue=Integer.parseInt(rs.getString("maxvalue"));
       }
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
       return rValue;
    }
    public int getConMaxValue(String sql){
      ResultSet rs = db.QuerySQL(sql);
       int rValue = 0;
		Statement stmt = null;
		try{
		   if(rs.next()){
			 rValue=Integer.parseInt(rs.getString(1));
		   }
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
       return rValue;
    }
    public void ExecuteSQL(String sql)
	{
		 db.ExecuteSQL(sql);
    }
    public ResultSet QuerySQL(String sql)
	{
		 ResultSet rs = db.QuerySQL(sql);
		 return rs;
	}

	public void close()
	{
		closeRs();
		closePstm();
	}


}

⌨️ 快捷键说明

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