ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Folashade Adeyosoye <sharda...@gmail.com>
Subject Re: iBatis Dao Setup
Date Tue, 26 Apr 2005 13:59:12 GMT
Thanks for the advise, my plan is to actually have 2 implementaions of
the code, one would be whatever i have now, unchanged in terms of the
how it gets it data and the other, the iBatis route. And my thinking
is DAO would basically be the factory that would point to whatever
implementation i want.


SERVICE 
       DAO
              MYSQL, sql embedded in code (just to keep around for
emergency deployment)
              iBatis (using sqlmap, sql seperate from code)

My gaol is to basically keep what i have and add the iBatis
implemetation to it, also using iBatis DAO framework (i took my DAO
framwork out)




On 4/26/05, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> I think you would be wise to simply use an existing connection pool in
> place of yours. There should be no difference in functionality. I
> don't want to be rude or snobbish. But, swapping out your connection
> manager for another solution will most likely be one of the simpler
> things you will do in your migration. I believe you will be
> reinventing the wheel if you keep your connection manager. If you
> still want to proceed, the best thing to do is to expose your
> connection manager as a datasource and write a DataSourceFactory
> implementation for it. Then you can conifgure it as a JDBC
> transactionManager with your custom DataSource.
> 
> Brandon
> 
> On 4/26/05, Folashade Adeyosoye <shardayyy@gmail.com> wrote:
> > I will eventually, I am ding the migration gradually, one at a time...
> >
> >
> > -----Original Message-----
> > From: Brandon Goodin [mailto:brandon.goodin@gmail.com]
> > Sent: Tuesday, April 26, 2005 2:16 AM
> > To: Folashade Adeyosoye
> > Subject: Re: iBatis Dao Setup
> >
> > Is there a reason why you don't migrate your connection manager over
> > to another connection pool implementation like DBCP or
> > SimpleDataSource?
> >
> > On 4/25/05, Folashade Adeyosoye <shardayyy@gmail.com> wrote:
> > > An addition to that, this was an application that was working, in terms of
> > > DB connections, persistence, etc, now my goal is to migrate it to a
> > > DAO/SQLMap solution.
> > >
> > > So I am looking of having 2 implementations, 1 JDBC (what I had before)
> > and
> > > the other iBatis SQLMap
> > >
> > > -----Original Message-----
> > > From: Brandon Goodin [mailto:brandon.goodin@gmail.com]
> > > Sent: Monday, April 25, 2005 11:08 PM
> > > To: ibatis-user-java@incubator.apache.org
> > > Subject: Re: iBatis Dao Setup
> > >
> > > " I have my own connectionManager class"
> > > I'm not sure what you mean by this. Please expound on this.
> > >
> > > Brandon
> > >
> > > On 4/25/05, Folashade Adeyosoye <shardayyy@naijatek.com> wrote:
> > > >
> > > >
> > > >
> > > > Hi all let me see if I can explain my problem and how I have things
> > setup.
> > >
> > > >
> > > >
> > > >
> > > > First, my problem is having difficulty converting one of my working and
> > > > deployed applications to using iBatis Dao. I basically yanged out my Dao
> > > > factory and try to replace it with iBatis version in hopes to use
> > SQLMAP.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Application starts up and calls the MyExtendedActionServlet.java to load
> > > my
> > > > cache object (drop downs)
> > > > MyExtendedActionServlet.java calls MyServiceImpl.java (Service Layer)
> > > which
> > > > in turns calls the MysqlSelectionObjectDAO.java
> > > > MysqlSelectionObjectDAO.java makes the jdbc calls to the DB to pull
> > stuff.
> > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Where it fails.
> > > >
> > > > ============================
> > > >
> > > > It fails right here in the dao.xml file, see dao.xml below.
> > > >
> > > >
> > > >
> > > > <snip>
> > > >
> > > >       Reader reader = Resources.getResourceAsReader(resource);
> > > >
> > > > </snip>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Question:
> > > >
> > > > Do I still need to define my transactionManager even thou I have my own
> > > > connectionManager class - See dao.xml below
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Any help will be appreciated.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Package Structure
> > > >
> > > > ============================
> > > >
> > > >
> > > >
> > > > net.package1.package2
> > > >                                |
> > > >                                |_____ domain <package>
> > > >                                                         |
> > > >
> > > > |_____impl <package>
> > > >
> > > >          |
> > > >
> > > >          |_____ MyServiceImpl.java
> > > >                                |
> > > >                                |_____framework <package>
> > > >                                                         |
> > > >
> > > > |_____MyExtendedActionServlet.java
> > > >
> > > >                               |
> > > >                                |_____ persistence <package>
> > > >                                                         |
> > > >
> > > > |_____iface <package>
> > > >                                                         |
> > > >
> > > > |_____mysql  <package>
> > > >
> > > >
> > > >              |
> > > >
> > > >               |_____ MysqlSelectionObjectDAO.java
> > > >                                                         |
> > > >
> > > > |_____sqlmapdao  <package>
> > > >                                                         |
> > > >
> > > > |_____dao.xml
> > > >                                                         |
> > > >
> > > > |_____DaoConfig.java
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > MyExtendedActionServlet.java :
> > > >
> > > > ============================
> > > >
> > > >
> > > >
> > > >      // load the countires
> > > >
> > > >      ArrayList countires = new ArrayList();
> > > >
> > > >      countires = api.loadDropDownMenu(Constants.DROP_MENU_COUNTRY,
> > false);
> > >
> > > >
> > > >
> > > > getServletContext().setAttribute(appProp.getValue("lookup.country"),
> > > > countires);
> > > >
> > > >      logger.debug("COUNTRIES LOADED...");
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > MysqlSelectionObjectDAO.java:
> > > >
> > > > ============================
> > > >
> > > >
> > > >
> > > >             <snip/> - the program is not even getting to this point...
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > dao.xml
> > > >
> > > > ============================
> > > >
> > > >
> > > >
> > > > <daoConfig>
> > > >
> > > >
> > > >
> > > > <properties resource="
> > > > net/package1/package2/properties/database_local.properties"/>
> > > >
> > > >
> > > >
> > > >   <context>
> > > >
> > > >    <transactionManager type="JDBC">
> > > >
> > > >       <property name="DataSource" value="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}"/>
> > > >
> > > >       <property name="JDBC.DefaultAutoCommit" value="true"/>
> > > >
> > > >       <property name="Pool.MaximumActiveConnections" value="10"/>
> > > >
> > > >       <property name="Pool.MaximumIdleConnections" value="5"/>
> > > >
> > > >       <property name="Pool.MaximumCheckoutTime" value="120000"/>
> > > >
> > > >     </transactionManager>
> > > >
> > > >
> > > >
> > > >     <dao interface="
> > > > net.package1.package2.persistence.iface.SelectionObjectDAO"
> > > > implementation="
> > > > net.package1.package2.persistence.mysql.MysqlSelectionObjectDAO"/>
> > > >
> > > >   </context>
> > > >
> > > > </daoConfig>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > DaoConfig.java
> > > >
> > > > ============================
> > > >
> > > >
> > > >
> > > > public class DaoConfig {
> > > >
> > > >
> > > >
> > > >   private static final DaoManager DAO_MANAGER;
> > > >
> > > >
> > > >
> > > >   static {
> > > >
> > > >
> > > >
> > > >     try {
> > > >
> > > >       String resource = "
> > > > net/package1/package2/persistence/dao.xml";
> > > >
> > > >       Reader reader = Resources.getResourceAsReader(resource);
> > > >
> > > >       DAO_MANAGER =
> > > > DaoManagerBuilder.buildDaoManager(reader);
> > > >
> > > >       System.out.println("Finished getting the DAO_MANAGER...");
> > > >
> > > >     } catch (Exception e) {
> > > >
> > > >       throw new RuntimeException("Could not initialize DaoConfig.
> > Cause:
> > > "
> > > > + e);
> > > >
> > > >     }
> > > >
> > > >   }
> > > >
> > > >
> > > >
> > > >   public static DaoManager getDaomanager() {
> > > >
> > > >     return DAO_MANAGER;
> > > >
> > > >   }
> > > >
> > > >
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ---------- ERROR - start ---------------
> > > >
> > > > <snip>
> > > >
> > > > DEBUG[2005-Apr-25 13:17:49] -
> > > > jdbc.SimpleDataSource(SimpleDataSource.java:407) - SimpleDataSource
> > > > forcefully closed/removed all connections.
> > > >
> > > > ApplicationDispatcher[/myContext]: Servlet.service() for
> > > > servlet debugjsp threw exception
> > > >
> > > > java.lang.NoClassDefFoundError
> > > >
> > > >             at net. package1.
> > > > package2.domain.impl.MyServiceImpl.<init>(MyServiceImpl.java:34)
> > > >
> > > >             at net. package1.
> > > >
> > >
> > package2.framework.taglib.BuildBirthdayListTag.<init>(BuildBirthdayListTag.j
> > > ava:73)
> > > >
> > > > </snip>
> > > >
> > > > ---------- ERROR - start ---------------
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>

Mime
View raw message