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 Salim Madjd <sa...@yahoo.com> on 2005/08/17 19:34:48 UTC

where can I find a simple implementation example

Hi,
I have read a lot of documentations and I still can not put the whole thing together, yet. 
I just want to see a simple implementation using servlet or jsp directly without involving strut or spring. I like to see a simple jsp page displaying a select statement and the jsp page displaying foo bar or something.
What are the best practices for using IBATIS with tomcat? What are the best practices for reading the sqlconfig.xml file. Should I open the config.xml file in a listener  and open/close  sessions in a filter? 
Should I be worried about threads?
 
Thanks in advance for any help,
 
Salim


Re: where can I find a simple implementation example

Posted by Larry Meadors <la...@gmail.com>.
Having done a lot of JDBC coding myself, I do not think that is a
great idea - I'd suggest spending the time to understand iBATIS first.

It may take you a day or two to get rolling with it, but once you are
using it, you will cut out a TON of coding that would be required with
JDBC.

Larry


On 8/18/05, Salim Madjd <sa...@yahoo.com> wrote:
>  
> Thanks, Larry! 
> I guess I'll take a look at spring. I am beginning to think it might be
> faster to just go directly with JDBC and refactor later as I become more
> comfortable with Spring and ibatis. 
>

Re: where can I find a simple implementation example

Posted by Salim Madjd <sa...@yahoo.com>.
Thanks, Larry!
I guess I'll take a look at spring. I am beginning to think it might be faster to just go directly with JDBC and refactor later as I become more comfortable with Spring and ibatis.
 
Thanks again,
 
Salim

Larry Meadors <la...@gmail.com> wrote:
Oops, i only replied to salim...

---------- Forwarded message ----------
From: Larry Meadors 
Date: Aug 17, 2005 4:35 PM
Subject: Re: where can I find a simple implementation example
To: Salim Madjd 


On 8/17/05, Salim Madjd wrote:
> > How should I deal with the thread?
>
> I do not understand the question. Can you clarify it please?
>
> Is ibatis thread safe or should I get a threadlocal?
>

iBATIS is totally thread-safe.

Larry


Fwd: where can I find a simple implementation example

Posted by Larry Meadors <la...@gmail.com>.
Oops, i only replied to salim...

---------- Forwarded message ----------
From: Larry Meadors <la...@gmail.com>
Date: Aug 17, 2005 4:35 PM
Subject: Re: where can I find a simple implementation example
To: Salim Madjd <sa...@yahoo.com>


On 8/17/05, Salim Madjd <sa...@yahoo.com> wrote:
> > How should I deal with the thread?
>
> I do not understand the question. Can you clarify it please?
>
> Is ibatis thread safe or should I get a threadlocal?
>

iBATIS is totally thread-safe.

Larry

Re: where can I find a simple implementation example

Posted by Larry Meadors <la...@gmail.com>.
On 8/17/05, Salim Madjd <sa...@yahoo.com> wrote:
> Thanks, Larry. 
>   
> Yes, I have gone this far and have all the config and maps setup based on
> the documentations. 
>   
> Your example is great for stand-alone application. But I am looking for web
> application (tomcat 5.x and above or any servlet 2.3 container) and some
> best practices. 

Hmmm, best practices for web development are to use struts, spring, or JSF. :-)

> 
> For example, where should I put this: 
>   
>         resource = "blah/SqlMapConfig.xml";
>         reader = Resources.getResourceAsReader (resource);
>         sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(reader); 
>   
> Should I place it in a listener and load it once at the start of context.
>   

My suggestion (if you are not wanting to use Spring) is to create a
class that has a static reference to a sql map in it that contains the
code above. Not sexy, but it works.

> How should I deal with the thread? 

I do not understand the question. Can you clarify it please?

> Is it best to write a simple filter to handle the resource management? 

No, no, no, please: no. 

I have seen that done with hibernate, and IMO, it is one of the worst
patterns of anything data-related I can imagine. As un-sexy as the
static idea above was, this is worse. Using your web layer to
initialize your data layer is just a really, really bad idea. Nancy
Reagan was right: "Just say 'no'."

Larry

Re: where can I find a simple implementation example

Posted by Salim Madjd <sa...@yahoo.com>.
Thanks, Larry.
 
Yes, I have gone this far and have all the config and maps setup based on the documentations.
 
Your example is great for stand-alone application. But I am looking for web application (tomcat 5.x and above or any servlet 2.3 container) and some best practices.

For example, where should I put this:
 
        resource = "blah/SqlMapConfig.xml";
        reader = Resources.getResourceAsReader (resource);
        sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
 
 
Should I place it in a listener and load it once at the start of context. How should I deal with the thread? 
Is it best to write a simple filter to handle the resource management?
 
Thanks,

Salim
 


Larry Meadors <la...@gmail.com> wrote:
This is as simle as it can possibly get:

http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg01759.html

Larry


On 8/17/05, Prashanth Sukumaran 
wrote:
> IBatis PetStore.
> 
> http://ibatis.apache.org/petstore.html
> 
> --- Salim Madjd wrote:
> 
> > Hi,
> > I have read a lot of documentations and I still can not put the whole thing together, yet.
> > I just want to see a simple implementation using servlet or jsp directly without involving strut
> > or spring. I like to see a simple jsp page displaying a select statement and the jsp page
> > displaying foo bar or something.
> > What are the best practices for using IBATIS with tomcat? What are the best practices for
> > reading the sqlconfig.xml file. Should I open the config.xml file in a listener and open/close
> > sessions in a filter?
> > Should I be worried about threads?
> >
> > Thanks in advance for any help,
> >
> > Salim
> >
> >
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: where can I find a simple implementation example

Posted by Larry Meadors <la...@gmail.com>.
This is as simle as it can possibly get:

http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg01759.html

Larry


On 8/17/05, Prashanth Sukumaran <pr...@yahoo.com> wrote:
> IBatis PetStore.
> 
> http://ibatis.apache.org/petstore.html
> 
> --- Salim Madjd <sa...@yahoo.com> wrote:
> 
> > Hi,
> > I have read a lot of documentations and I still can not put the whole thing together, yet.
> > I just want to see a simple implementation using servlet or jsp directly without involving strut
> > or spring. I like to see a simple jsp page displaying a select statement and the jsp page
> > displaying foo bar or something.
> > What are the best practices for using IBATIS with tomcat? What are the best practices for
> > reading the sqlconfig.xml file. Should I open the config.xml file in a listener  and open/close
> > sessions in a filter?
> > Should I be worried about threads?
> >
> > Thanks in advance for any help,
> >
> > Salim
> >
> >
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: where can I find a simple implementation example

Posted by Prashanth Sukumaran <pr...@yahoo.com>.
Hi

I found that very good blog just explaining only IBatis with a simple example.

http://www.j2eegeek.com/blog/2005/01/31/ibatis-where-have-you-been-all-my-life/

Rgds
Prashanth

--- Salim Madjd <sa...@yahoo.com> wrote:

> Hi,
> I have read a lot of documentations and I still can not put the whole thing together, yet. 
> I just want to see a simple implementation using servlet or jsp directly without involving strut
> or spring. I like to see a simple jsp page displaying a select statement and the jsp page
> displaying foo bar or something.
> What are the best practices for using IBATIS with tomcat? What are the best practices for
> reading the sqlconfig.xml file. Should I open the config.xml file in a listener  and open/close 
> sessions in a filter? 
> Should I be worried about threads?
>  
> Thanks in advance for any help,
>  
> Salim
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: where can I find a simple implementation example

Posted by Salim Madjd <sa...@yahoo.com>.
Prashanth,
Thanks for your email. 
I had already looked at the petstore. And as I said in my email I am looking for a simple example that does NOT include strut or spring. 
 
I was hoping to find a simple example without the involvement of strut and spring. Using petstore as an example it forces any new person to learn spring and strut before getting their hands on IBATIS. 
 
Thanks,
 
Salim
 
PS. If anyone else has a simple example that they know of or can share, I would greatly appreciate it.

Prashanth Sukumaran <pr...@yahoo.com> wrote:
IBatis PetStore.

http://ibatis.apache.org/petstore.html

--- Salim Madjd wrote:

> Hi,
> I have read a lot of documentations and I still can not put the whole thing together, yet. 
> I just want to see a simple implementation using servlet or jsp directly without involving strut
> or spring. I like to see a simple jsp page displaying a select statement and the jsp page
> displaying foo bar or something.
> What are the best practices for using IBATIS with tomcat? What are the best practices for
> reading the sqlconfig.xml file. Should I open the config.xml file in a listener and open/close 
> sessions in a filter? 
> Should I be worried about threads?
> 
> Thanks in advance for any help,
> 
> Salim
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: where can I find a simple implementation example

Posted by Prashanth Sukumaran <pr...@yahoo.com>.
IBatis PetStore.

http://ibatis.apache.org/petstore.html

--- Salim Madjd <sa...@yahoo.com> wrote:

> Hi,
> I have read a lot of documentations and I still can not put the whole thing together, yet. 
> I just want to see a simple implementation using servlet or jsp directly without involving strut
> or spring. I like to see a simple jsp page displaying a select statement and the jsp page
> displaying foo bar or something.
> What are the best practices for using IBATIS with tomcat? What are the best practices for
> reading the sqlconfig.xml file. Should I open the config.xml file in a listener  and open/close 
> sessions in a filter? 
> Should I be worried about threads?
>  
> Thanks in advance for any help,
>  
> Salim
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com