Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

database & beans & jsp

  Asked By: Harley    Date: Feb 18    Category: Java    Views: 1068

I was wondering where do i put my sql statements in the beans... with set or get
methodes? <br>where do i execute them , that my question...



5 Answers Found

Answer #1    Answered By: Lela Lynch     Answered On: Feb 18

It depends upon how you are using the
beans. I've used several different architectures, but I've
never used the set  method to put  the sql  into a
bean. One architecture I used (when I was just learning
JSP's) was to have a method in the bean that connected
to the database  and then made any database calls you
need. It then sets the information in the bean for the
JSP to extract. I would pass the information
required by the SQL statement to the page which had the
bean and a <jsp:setProperty ... tag would set the
required properites. Then I would call a "processInfo"
method where I did my DB work and set the infor needed
by the page in the bean. Ok, all you purists,
I know that totally Violates the MVC architecture,
but I was learning... I realize that the problem with
that approach was the view was tied closely with the
Model... In the long run it is difficult to maintain and
next to impossible to change... But for a quick page,
it worked and got all those "scriptlets" out of the
JSP... Now I use a multi-tiered approach. My JSP's only talk
to a "mediator" which could even be used in a Swing
App... The mediator talks to the domain classes and the
domain classes map to the data... I don't know
exactly what super_pi_girl is wanting to do, but the
quick approach I outlined above is just that a "quick
and DIRTY" way to do it. Pi? Are you doing
this project by yourself, or do you have a mentor?
What I would suggest is that you get the Wrox Press
book Professional JSP's 2nd edition
_2/002-5232411-8070453 (or maybe that's the book you said was clear as
mud...) or Jason Hunter's Java Servlet Programming
1_20/002-5232411-8070453 Both those books talk about some good
AND have good examples to follow. Jason Hunter's book
goes into the details on the HTTP protocol, a little
on architecture and covers JSP's and JDBC.... AND
it's cheaper... Good Luck... I hope this
helps and isn't too confusing

Answer #2    Answered By: Sherri Parker     Answered On: Feb 18

But I kinda figure it out
now... JAVA is such a difficult language to learn, esp.
cos of the books that I needed to get for my class...
It goes from beginner's level of JAVA to the next
book which is the advanced - intermidiar level of JAVA
with a lot of codes... and with very lil' explanation
unfortunately! <br>JAVA does have more standard classes and
stuff to make things easier, but it doesn't really help
when u have NO IDEA how it is implemeted or what it
does... <br>ah well... I better get a move on with my
project... or I'll never finish it in time!

Answer #3    Answered By: Julio Morgan     Answered On: Feb 18

I find the Java syntax itself to be fairly easy
to learn and understand, but it is true that there
are a huge number of classes in the Java API. The
best thing is to always have a copy of the JavaDoc for
the Java API on hand - preferably a local copy since
you will look at it a

Answer #4    Answered By: Opal Alexander     Answered On: Feb 18

The cool thing about PJ is that she wants to know "why" and isn't looking for a
cookbook solution...

Answer #5    Answered By: Lily Brown     Answered On: Feb 18

The cool thing about Java
is sometimes you don't need to know how something is
implemented, rather you only need to know its interface. Not
really related, but an important concept of Java,

Didn't find what you were looking for? Find more on database & beans & jsp Or get search suggestion and latest updates.