You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Krishna Mohan <km...@yahoo.com> on 2004/12/20 18:24:28 UTC
Sruggling with my application - Please help
Hi,
I am really facing one problem. I would like to know,
whether this problem is because of my wrong use of ibatis sql maps framwork.
I almost completed my webapplication and my server is hanging/ crashing for third user.
It is going to dao method call each time and hanging in the console, which should not happen
I am really in a confusion and I liked using ibatis framework really much.
Can you please provide me the solution.
I am using tomcat 5.0.30 web server, struts framwork and back end as Oracle 9i.
My application should be able to support atleast 30 users.
My backend code is like this.
I have taken code/approach from Struts and ibatis lesson of reumann site.
My architecture from action class.
-->
In my first action class, I am instantiating the dao object, making calls to database
(nearly 6 method calls).
after that it will display the next page.
In this a seperate action class is invoked and I will be instantiating another dao object
and make only 1 method call, which goes to database and returns results.
All these method calls purpose is to get data from databases.
Finally I have to insert values.(I havent completed this - because of crashing things).
These two daos will internally call BASEDAO.java(reumann site).
action class ->
dao object
->
--database ibatis framwork--
----------------
My questions :
1) When I am running the application , server is hanging once I open the third browser.
I am not using any cahing.
I would like to know, beacuse of this reason it is happening like this.
2) My console in the server is some times displaying the system.out.printlns values of action classes,
and some times base dao system.out.printlns.
[ I have given System.out.println statements in getObject and getList methods of BaseDao).
I am sequentially making 6 method calls.
Is this wrong, making 6 times call from a single action class.
Is there any way to bring this application upto 30 users. (scalability).
3) Can I remove,
sqlMap.startTransaction();
and sqlMap.commitTransaction();
in getObject and getList methods of BaseDao).
to increase performnce. Because the purpose is to fetch values from database.
4) is there any reasons of increasing the performance, improving the users.
Many Thanks in advance,
Krishna Mohan.
-------------------
database properties
driver=oracle.jdbc.driver.OracleDriver
url=
username=NEW_dm
password=
---------------------------------------
sql-map-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="conf/database.properties" />
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}"/>
<property name="JDBC.ConnectionURL" value="${url}"/>
<property name="JDBC.Username" value="${username}"/>
<property name="JDBC.Password" value="${password}"/>
</dataSource>
</transactionManager>
<sqlMap resource="sql/UserCheckSQL.xml" />
<sqlMap resource="sql/ConfirmationSQL.xml" />
</sqlMapConfig>
--------------------------------------------
UserCheckSql.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="UserCheckSQL">
<statement id="verifyUsername" parameterClass="java.util.Map" resultClass="java.lang.Integer">
select count(UserId) as value
from MT_Users
where UserId = #hmUsername#
and PASSWORD = #hmPassword#
</statement>
<statement id="getUserempdetails" parameterClass="string" resultClass="com.phs.timesheet.dom.UserEmpinfodom">
SELECT EMPLOYEEID as empid,
EMPLOYEENAME as empname
from MT_Employee
where EmployeeID =(select EmployeeID from MT_Users where UserId = #value# )
</statement>
<statement id="getCurrentDate" resultClass="java.util.Date">
SELECT SYSDATE FROM DUAL
</statement>
<resultMap id="get-Months-list" class="com.phs.timesheet.dom.Monthdom">
<result property="month" column="MONTHDESC"/>
</resultMap>
<statement id="getMonthList" resultMap="get-Months-list">
select MONTHDESC from MT_MONTH
</statement>
<resultMap id="get-Year-list" class="com.phs.timesheet.dom.Yeardom">
<result property="year" column="YEAR"/>
</resultMap>
<statement id="getYearList" resultMap="get-Year-list">
select YEAR from MT_Year
</statement>
<resultMap id="get-week-details" class="com.phs.timesheet.dom.Weekdom">
<result property="weekid" column="weekid"/>
<result property="weekstartdate" column="WEEKSTARTDATE"/>
</resultMap>
<statement id="getWeekStartDates" parameterClass="java.util.Map" resultMap="get-week-details">
select weekid,WEEKSTARTDATE from mt_week
where monthid like #hmMonth# and yearid like #hmYear#
</statement>
</sqlMap>
------------------------------------------------------
ConfirmationSQL.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="ConfirmationSQL">
<resultMap id="get-Activity-list" class="com.phs.timesheet.dom.Activitydom">
<result property="activity" column="ACTIVITY"/>
<result property="isactive" column="ISACTIVE"/>
</resultMap>
<statement id="getActivityList" resultMap="get-Activity-list">
SELECT ACTIVITY, ISACTIVE FROM MT_ACTIVITY WHERE ISACTIVE = 1
</statement>
</sqlMap>
----------------------------------------------------------
BaseDAO.java
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.ibatis.sqlmap.client.SqlMapClient;
public class BaseDAO {
private static Log log = LogFactory.getLog(BaseDAO.class);
private static SqlMapClient sqlMap = null;
static {
try {
String resource = "conf/sql-map-config.xml";
Reader reader = Resources.getResourceAsReader(resource);
//log.debug("reader = "+reader );
//System.out.println("reader = "+reader );
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
//log.debug("sqlMap = "+sqlMap );
//System.out.println("sqlMap = "+sqlMap );
reader.close();
} catch (Exception ex) {
log.error("BaseDAO static block: " + ex);
throw new RuntimeException("Error Initializing BaseDAO :" + ex);
}
}
public List getList(String statementName, Object parameterObject) throws DaoException {
List list = null;
try {
sqlMap.startTransaction();
try
{
list = sqlMap.queryForList(statementName, parameterObject);
}
catch(Exception e1)
{
e1.printStackTrace();
}
sqlMap.commitTransaction();
} catch (SQLException e) {
try {
sqlMap.endTransaction();
} catch (SQLException ex) {
throw new DaoException(ex.fillInStackTrace());
}
throw new DaoException(e.fillInStackTrace());
}
//System.out.println("List values are :"+list);
return list;
}
public Object getObject(String statementName, Object parameterObject) throws DaoException {
Object result = null;
try {
//System.out.println("\n****before executing BASEDAO.getObject()");
sqlMap.startTransaction();
// System.out.println("statementName"+statementName);
// System.out.println("statementName"+parameterObject);
try
{
result = sqlMap.queryForObject(statementName, parameterObject);
}
catch(Exception e1)
{
e1.printStackTrace();
//System.out.println("stopped");
}
sqlMap.commitTransaction();
//System.out.println("\n****After executing BASEDAO.getObject()");
}
catch (SQLException e) {
try {
sqlMap.endTransaction();
} catch (SQLException ex) {
throw new DaoException(ex.fillInStackTrace());
}
throw new DaoException(e.fillInStackTrace());
}
catch (Exception ex)
{
ex.fillInStackTrace();
throw new DaoException(ex.fillInStackTrace());
}
//System.out.println("result");
return result;
}
public int update(String statementName, Object parameterObject) throws DaoException {
int result = 0;
try {
sqlMap.startTransaction();
result = sqlMap.update(statementName, parameterObject);
sqlMap.commitTransaction();
} catch (SQLException e) {
try {
sqlMap.endTransaction();
} catch (SQLException ex) {
throw new DaoException(ex.fillInStackTrace());
}
throw new DaoException(e.fillInStackTrace());
}
return result;
}
}
---------------------------------------------------------------------------
EmployeeDao -
import java.util.Date;
import java.util.List;
public class EmployeeDAO extends BaseDAO {
public Integer verifyUsername(Object parameterObject) throws DaoException {
//System.out.println("Into the method of EmployeeDAO verifyUsername with the value of "+parameterObject);
return (Integer) super.getObject("verifyUsername", parameterObject);
}
public UserEmpinfodom getEmployeesInfo(Object parameterObject) throws DaoException
{
//System.out.println("Into the method of UserDAO getEmployeesInfo with the value of "+parameterObject);
return (UserEmpinfodom) super.getObject("getUserempdetails", parameterObject);
}
public Date getDateDao() throws DaoException
{
//System.out.println("Into the method of EmployeeDAO getEmployeesInfo with the value of ");
return (Date) super.getObject("getCurrentDate", null);
}
public List getMonths() throws DaoException
{
//System.out.println("Into the method of EmployeeDAO getMonths with the value of ");
return super.getList("getMonthList", null);
}
public List getYears() throws DaoException
{
//System.out.println("Into the method of EmployeeDAO getYears with the value of ");
return super.getList("getYearList", null);
}
public List getWeekStartInfo(Object parameterObject) throws DaoException
{
//System.out.println("Into the method of EmployeeDAO getWeekStartInfo with the value of "+parameterObject);
return super.getList("getWeekStartDates", parameterObject);
}
}
import java.util.List;
public class ConfirmationDAO extends BaseDAO {
public List getActivities() throws DaoException
{
//System.out.println("Into the method of ConfirmationDAO getMonths with the value of ");
return super.getList("getActivityList", null);
}
}
---------------------------------
Do you Yahoo!?
Jazz up your holiday email with celebrity designs. Learn more.