JAVA_VERSION="1.7.0"
Oracle JDBC Driver
Heap space IBM WEB SPHEREdi seguito tutta la classe CommonDAO
Initial heap size
MB 256Maximum heap size
MB 3072
uso spring parametrizzato così
connessione spring
spring xml
<bean id="applicationContextProvider" class="com.claimplus.common.ApplicationContextProv ider" />
<context:annotation-config/>
<!-- mio DB -->
<!-- il transaction manager usato per le transazioni (db gypsy) -->
<bean id="tjtJTransactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager" >
<property name="dataSource" ref="tjtDataSource" />
</bean>
<bean id="tjtDataSource"
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="jdbc/miodb"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true"/>
<property name="proxyInterface" value="javax.sql.DataSource"/>
</bean>
<bean id="CommonDAO" class="com.claimplus.hibernate.common.dao.CommonDA O" scope="singleton">
<property name="dataSource" ref="tjtDataSource"/>
<property name="transactionManager" ref="tjtJTransactionManager"/>
</bean>
nella mie classi DAO ho il seguente attributo
CommonDAO connOracle =(CommonDAO) ApplicationContextProvider.getBean("CommonDAO") ;
le query le eseguo così nelle classi java
String strsql = " SELECT * from Table ";
daQuery=connOracle.getJt().queryForList(strsql);
/*
* Progetto Claimplus 2015 ,user id :803285 ,team : Data Group srl
* project name: ClaimPlusPersister
*/
package com.claimplus.hibernate.common.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.springframework.jdbc.datasource.DataSourceTran sactionManager;
import com.common.MyJdbcTemplate;
import com.common.Utility;
import com.common.exception.DatabaseException;
import com.common.sigleton.LoginSingleton;
// TODO: Auto-generated Javadoc
/**
* The Class CommonDAO.
*/
public class CommonDAO {
/** The Constant logger. */
private static final Logger logger = Logger.getLogger(CommonDAO.class);
/** The value. */
public String value = null;
/** The default value. */
public String defaultValue = null;
/** The jt. */
private MyJdbcTemplate jt;
/** The transaction manager. */
private DataSourceTransactionManager transactionManager;
/** The aia transaction manager. */
private DataSourceTransactionManager aiaTransactionManager ;
/**
* Gets the aia transaction manager.
*
* @return the aia transaction manager
*/
public DataSourceTransactionManager getAiaTransactionManager() {
return aiaTransactionManager;
}
/**
* Sets the aia transaction manager.
*
* @param aiaTransactionManager the new aia transaction manager
*/
public void setAiaTransactionManager(
DataSourceTransactionManager aiaTransactionManager) {
this.aiaTransactionManager = aiaTransactionManager;
}
/**
* Gets the transaction manager.
*
* @return the transaction manager
*/
public DataSourceTransactionManager getTransactionManager() {
return transactionManager;
}
/**
* Sets the transaction manager.
*
* @param tm the new transaction manager
*/
public void setTransactionManager(DataSourceTransactionManager tm) {
this.transactionManager = tm;
}
/**
* Sets the data source.
*
* @param dataSource the new data source
*/
public void setDataSource(DataSource dataSource) {
//this.dataSource = dataSource;
this.jt= new MyJdbcTemplate(dataSource);
}
/**
* Gets the jt.
*
* @return the jt
*/
public MyJdbcTemplate getJt() {
return jt;
}
/**
* Sets the jt.
*
* @param jt the new jt
*/
public void setJt(MyJdbcTemplate jt) {
this.jt = jt;
}
/**
* Execute update.
*
* @param sql the sql
* @param operation the operation
* @param table the table
* @return the int
*/
public int executeUpdate(String sql, String operation, String table) {
logger.debug("Query " + operation + ": "+sql);
int k = this.getJt().update(sql);
logger.debug(operation + " into " + table + (k>0?"executed":"NOT executed"));
return k;
}
/**
* Execute select.
*
* @param sql the sql
* @param table the table
* @return true, if successful
*/
public boolean executeSelect(String sql, String table) {
logger.debug("Query SELECT: "+sql);
MyJdbcTemplate.Row daQuery = this.getJt().queryForRow(sql);
logger.debug("SELECT " + table + ((daQuery != null)?" successful":" UNsuccessful"));
return (daQuery != null);
}
/**
* Execute query.
*
* @param sql the sql
* @param columName the colum name
* @return the string
* @throws DatabaseException the database exception
*/
public String executeQuery(String sql, String columName) throws DatabaseException {
String str = null;
try{
MyJdbcTemplate.Table daQuery = getJt().queryForTable(sql);
if (daQuery!=null && daQuery.getList().size()>0) {
str = (String)daQuery.getList().get(0).get(columName);
}
} catch(Exception e) {
logger.error("exception in: "+sql, e);
throw new DatabaseException("exception in: "+sql, e);
}
return str;
}
/**
* Gets the column header.
*
* @param index the index
* @param list the list
* @param defaultValue the default value
* @return the column header
*/
/**
* TEMPORANEO NON USARE.
*
* @throws DatabaseException the database exception
* @deprecated
*/
public void commit_() throws DatabaseException{
String sql = "COMMIT;";
MyJdbcTemplate.Table daQuery;
try{
daQuery = getJt().queryForTable(sql);
} catch(Exception e) {
logger.error("exception in: "+sql, e);
throw new DatabaseException("exception in: "+sql, e);
}
}
}


Rispondi quotando