📄 commonfuncs.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 + -