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

📄 commonfuncs.java

📁 本人课程设计时做的一个用struts框架实现的基于cmmi2的项目管理系统的原型。还有部分功能尚未实现
💻 JAVA
字号:
package com.cmmi2pms.common;

/**
 * @author lxj
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;


import com.cmmi2pms.common.comdb.*;
import org.apache.log4j.Logger;

import com.cmmi2pms.sa.project.Project;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



public class CommonFuncs {
	
	private static Logger logger = Logger.getLogger ("CommonFuncs") ;
	     
     static public int getCurrentID(String IDName,String tableName)
     {
		int theID = 0;
		try{
			//PooledConnectionMgr.getInstance().initialize(30,"192.168.15.150",3306,"CMMI2PM");
			//Get an instance reference to the DbFacade object
			SqlDB dbf = null;
			dbf = new SqlDB();
			
			ResultSet rs = null;
			String sql;
			sql = "select Max(" + IDName + ") as ID from " + tableName;
			rs=dbf.executeQuery(sql);
			
			if (rs.next())
			{
				theID = rs.getInt("ID") + 1;
				
			}else
			{
				theID = 0;
			}
		    
		}
		catch (Exception e)   	
		{
			theID = -1;
			logger.error("Exception in getCurrentID:" + e.getMessage());
		}
		finally
		{
			logger.error("return ID:" + theID);
			return theID;
		}
     }
     
     public static String getProjectID(HttpServletRequest request)
     {
     	Project theProject = new Project();
    	HttpSession session = request.getSession();
    	
		if (session.getAttribute(com.cmmi2pms.common.Constants.PROJECT_KEY)!=null)
			theProject = (Project) session.getAttribute(com.cmmi2pms.common.Constants.PROJECT_KEY);	
			
	    return theProject.getProjectID();

     }
}

⌨️ 快捷键说明

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