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

📄 docbean.java

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -