Hi everyone...
Will there be a problem (like transactional) if all EJB share one DAO
instance? The DAO doesn't maintain any state which will be concurrently
accessed.
Thanks...
Jerson
-- code --
public class DAOFactory {
private static OracleDAO oracleDAO;
private static SybaseDAO sybaseDAO;
public static DAO getDAO() throws OrderDAOException {
try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("ds");
Connection conn = ds.getConnection();
String DBProductName =
conn.getMetaData().getDatabaseProductName().trim();
conn.close();
if (DBProductName.startsWith("Oracle")) {
return getOracleDAO();
} else if (DBProductName.startsWith("SQL Server")) {
return getSybaseDAO();
} else {
throw new OrderDAOException("db not supported");
}
} catch (NamingException ne) {
throw new OrderDAOException("OrderDAOFactory.getDAO:
NamingException while getting DB connection : \n" + ne.getMessage());
} catch (SQLException se) {
throw new OrderDAOException("OrderDAOFactory.getDAO:
SQLException while getting DB connection : \n" + se.getMessage());
}
}
public OracleDAO getOracleDAO() {
if (oracleDAO == null) {
oracleDAO = new OracleDAO;
}
return oracleDAO;
}
public SybaseDAO getSybaseDAO() {
if (sybaseDAO == null) {
sybaseDAO = new sybaseDAO;
}
return sybaseDAO;
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".