Database access

2003-01-02 Thread sreejith
Dear all,

I have done an application using Struts MVC pattern. In that i am 
creating the database connection using the following statements

javax.sql.DataSource dataSource = 
(javax.sql.DataSource)servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
 

Connection connection =dataSource.getConnection();
Statement  st  =  connection.createStatement();

I specified all the data base related details in "struts-config.xml" file. I am using 
the JSQLConnect Type 4 Driver for the database connection. Previously it was working 
perfectly. But in December JSQLConnect has released a new version of JSQLConnect Type4 
Driver. While using the new version of the driver, My application is not working 
perfectly. It is getting database connection only once . The connection pooling is not 
happening.

 Can any body help me to solve this problem.

Waiting for your  valuable suggessions and solutions

Thanks,
Sreejith



Database Access

2001-07-04 Thread Aapo Laakkonen

I'm currently using Struts connection pooling facilities from Action
classes. Now I'm
going to implement data access logic in my data access components, but I'm
not sure
that how can I still use struts based connection pooling. Do I have to
transfer
DataSource object or servlet ocject from Action to data access component,
or can I get that directly from my data access component? I'm not using EJBs
right now, because I'm still learning the basics.

Can someone give me an example how to coordinate moving data from dao to
value objects. Some class examples would be great. Or how in general is the
best way to implement database interactions in struts (not using ejbs)? I
know
that it may depend on what you are doing, but is there some common pattern
that can be used?

-- Aapo Laakkonen, +358 (50) 33 99 682, ProjectCast Ltd, Helsinki, Finland.




Re: Database access

2003-01-04 Thread colin campbell

sreejith,

If it was me and the person from whom I had bought
drivers issued a version which did not support
connection pooling (for whatever reason), then I think
that my first point of contact would be the
originators
of JSQLConnect. I don't know if this is a paid for
product,or whether they have support forums.

But simply and logically I would try them first.From
your code snippet (and whatever you use to monitor
database connections) it worked in the previous
release,so surely the driver should be forward
compatible ...

Try the originators initially, Colin C 


 --- sreejith <[EMAIL PROTECTED]> wrote: >
Dear all,
> 
> I have done an application using
> Struts MVC pattern. In that i am creating the
> database connection using the following statements
> 
> javax.sql.DataSource dataSource =
>
(javax.sql.DataSource)servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
> 
> 
> Connection connection =   
> dataSource.getConnection();
> Statement  st  =  connection.createStatement();
> 
> I specified all the data base related details in
> "struts-config.xml" file. I am using the JSQLConnect
> Type 4 Driver for the database connection.
> Previously it was working perfectly. But in December
> JSQLConnect has released a new version of
> JSQLConnect Type4 Driver. While using the new
> version of the driver, My application is not working
> perfectly. It is getting database connection only
> once . The connection pooling is not happening.
> 
>  Can any body help me to solve this problem.
> 
> Waiting for your  valuable suggessions and solutions
> 
> Thanks,
> Sreejith
>  

=


__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Database access problem

2001-04-26 Thread Scott Fitzgerald



Hi Folks,
 
For those of you with ten 
minutes to spare, please read on.
 
I'm having trouble with my 
database test app. As a background, I'm writing my Action and ActionForm classes 
in Visual Age for Java, then exporting my classes to the WEB-INF\classes 
directory of my application. Within the lib directory I include struts.jar and 
the jdbc thin drivers in .zip format (if these are not needed here please tell 
me). 
 
I have tried to run this 
two ways. The first was using the datasource tag in the struts-config.xml file. 
I included it right after my action-mappings and form-beans tag, all of which 
are included inside the struts-config tags. When I start my Tomcat server, 
I receive an error in the console that says basically that there are illegal 
characters after my action-mapping tag ends (I.e. the datasource tag). The 
console will also give me a class not found 
exception at java.sql.Datasource. After I point my browser at the 
war file I get an error stating that it can't find the ActionMappings or 
ActionFormBeans collection. 
 
The second way I tried to run 
this was by simply establishing a connection to the database manually in my 
Action class and using Class.forName(jdbcUrl). However, this time, when I 
try run the app it will crap out when I try to do the actual query and give me a 
class not found exception at Class.forName(jdbcUrl) at the Tomcat console. The 
browser gives me a null pointer exception. I think I have all the 
required imports within my classes.
 
Using the datasource tag looks 
like it should be very straight forward but I'm having no joy. For anyone who 
has read this far, I apologize for the length of the message. I have included my 
code from the struts-config.xml file and my Action class perform() 
method.
 
    "-//Apache Software Foundation//DTD Struts Configuration 
1.0//EN"   "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">    
     
  
type="dbtest.DatabaseForm"/>    
        
   
 type="dbtest.DatabaseAction"  
 name="databaseForm">  
      
           
 
   
  key="dbtest" 
 autoCommit="false"    
  description="Database 
Test"    
  driverClass="oracle.jdbc.driver.OracleDriver"   
 maxCount="4"   
 minCount="2"   
 password="password" 
url="jdbc:oracle:thin:@servername:1521:" 
user="username"   />   
   

 
public ActionForward 
perform( ActionMapping mapping, ActionForm 
form, HttpServletRequest request, HttpServletResponse 
response) throws javax.servlet.ServletException, java.io.IOException 
{  //String jdbcDriver = 
"oracle.jdbc.driver.OracleDriver"; //String jdbcUrl = 
"jdbc:oracle:thin:@servername:1521:"; java.sql.Connection 
myConnection = null;
 
 DatabaseForm theForm = 
(DatabaseForm) form;  String id = 
theForm.getPackage_id();  String description 
=null; java.sql.ResultSet rs = 
null; try {  javax.sql.DataSource dataSource = 
servlet.findDataSource("dbtest");   myConnection = 
dataSource.getConnection();  System.out.println("You are here 
#1");  //Class.forName(jdbcDriver);  //System.out.println("You 
are here #2");  //myConnection = 
java.sql.DriverManager.getConnection(jdbcUrl);  myConnection = 
dataSource.getConnection();   java.sql.PreparedStatement stmt 
=   myConnection.prepareStatement("Select 
package_description From Packages Where package_id=" + 
id); rs = 
stmt.executeQuery();if 
(rs.next())  {   description = 
rs.getString("Package_Description");  }  else  {   description 
= 
"Empty";  }theForm.setPackage_description(description);  
 
 }
 
 catch 
(java.sql.SQLException 
sqle) {  getServlet().log("Connection.process", 
sqle); } //catch (ClassNotFoundException 
e) //{ //} catch (NullPointerException 
npe) {   } finally {
 
  try  {
 
   myConnection.close();  }  catch 
(java.sql.SQLException 
e)  {   getServlet().log("Connection.close", 
e);  } } //if (description != 
null) //{  return 
mapping.findForward("success"); //} //else //{  //return 
mapping.findForward("fail"); //}
 
}
 
Any help is greatly 
appreciated,
 
Scott 
Fitzgerald


[OT] database access philosophy

2003-02-26 Thread Kirby Vandivort
Hello,

I'm in the process of converting an old webapp over to using struts
and, in the process, I decide to clean up the database access.

Old Way:
I had written a connection pool and instantiated an instance of this
that was passed to all methods that needed the db, and they they had
the sql code embedded in the methods.

New Way that I'm working on:
I've set up a DataSource for my jdbc connection, and I'm partitioning
off all of the database access code into it's own package.  If my
business logic needs database info, it calls a method from the database
access package to get it.  

My problem:

Many methods from the database access return simple data.

However, I currently have it written so that some of the more complex
ones return a ResultSet, which I'm not really happy with.  This exposes
the DB layer to the business logic, but I'm not totally sure what the
best way to avoid this is.  In addition, this doesn't work :( because
the underlying connection gets closed when the database access method
exists, and the ResultSet is no longer valid.

SO,  I am wondering what people do when they need to return all of the
data in a ResultSet to their business layer.  Do you have to go to the
hassle of copying everything to some sort of data structure, or is
there a better, cleaner, faster way to handle this?

(I'm kind of assuming that the ResultSet will be small enough to fit
in memory and there won't be issues with pulling it in in pieces;  how
would that be handled, though?)

Thanks,

-- 

Kirby Vandivort  Theoretical and Computational Biophysics 
Email: [EMAIL PROTECTED]  3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/University of Illinois
Phone: (217) 244-5711405 N. Mathews Ave
Fax  : (217) 244-6078Urbana, IL  61801, USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Bean database access concepts

2002-11-27 Thread Joao Araujo

	
	I am not using EJB but plain beans to access the database.
	I defined everything in such a way to isolate  database access from action 
bean.
	Now, I have some doubts about how to access the database connection.
	Should I pass the connection as a parameter to the beans that accesss the 
datdabase, or
	should I use another method?

	Thanks a lot for your attention,


Joao,
	


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



Database access deployment question

2002-09-19 Thread Kirby Vandivort

Hello,

I have been reading up on accessing databases from within the struts
framework, and I'm not totally sure of the best way to approach the
issue of deployment.

We package up a WAR file for distribution to end users, and I would
like to be able to tell them to drop the WAR file in webapps and be
done with it.  (ie., not have to uncompress it).

However, from what I can tell, setting up "clean" database access
includes doing something like making a data-source entry and placing it
in the web.xml in the WEB-INF directory of the deployed application.

Since the properties for the database (username, password, etc) will be
different for each end user, I can't apriori set values for this.

So, what does everyone out there that has been down this road before do
to solve this problem?  I guess, really, this goes beyond simple
database access.  We also have a few other settings for our application
that need to be set.

CURRENTLY, we aren't using struts (pure servlets) and we have properties
files that contain this information.  But, we are currently requiring
the user to unpack the WAR file and I would love to get away from this.

Thanks for your help!

-- 

Kirby Vandivort  Theoretical Biophysics Group
Email: [EMAIL PROTECTED]  3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/University of Illinois
Phone: (217) 244-5711405 N. Mathews Ave
Fax  : (217) 244-6078Urbana, IL  61801, USA

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Database Access Problem.Need Help?

2002-02-28 Thread Anant Sagar

Hello ,

I am new to Struts and facing problem regarding the Database access .I m getting 
DataSource as null even though , i ve done changes in Data Source Configuratio .
I m using Tomcat 3.2.1 .

This is what I have done in struts-config.xml file 
---
 

  
  
  
  
  
  

  
---
And my web.xml has context 
-

  org.apache.struts.action.DATA_SOURCE
  org.apache.struts.util.GenericDataSource
  
-
My Action class reads as below to get the connection
--
javax.sql.DataSource dataSource  =
servlet.findDataSource("org.apache.struts.action.DATA_SOURCE");
java.sql.Connection myConnection =dataSource.getConnection();
java.sql.Statement st  =  myConnection.createStatement();
int x   =  st.executeUpdate( " Some _ Query ");

--

I m getting dataSource as null.

What do you have to say bout this ?  Is there anything wrong. Please let me know .
Thanks in advance.

- Sager



Database access via OO

2000-11-09 Thread Pramod



Hi all,
 
Does any one know about any good Java OO 
implmentations using which direct database access from the middle layer can be 
avoided to the maximum ?  
 
A vague explanation will be like - Middle layer 
coders will not be accessing database directly,  what they do is, create 
objects and establish relations between them (may be, using some 
other relating objects/structures). Later after establishing all required 
relations, they will call a "read"/"fetch" method of some high level 
relation object which will automatically (internally) construct the 
query/queries needed according to the previously set relations, and returns the 
objects. Sorry if its stupid/confusing. Even I dont have a clear 
idea on that. If u get what i mean, please help
 
thanks,
 
Pramod


Re: Database access problem

2001-04-26 Thread TODD HARNEY

Do the files in the lib directory have to be a JAR file and not ZIP? Just wondering. 
Try renaming the ZIP to a JAR extension.

Todd

>>> [EMAIL PROTECTED] 4/26/01 2:34 >>>
Hi Folks,

For those of you with ten minutes to spare, please read on.

I'm having trouble with my database test app. As a background, I'm writing
my Action and ActionForm classes in Visual Age for Java, then exporting my
classes to the WEB-INF\classes directory of my application. Within the lib
directory I include struts.jar and the jdbc thin drivers in .zip format (if
these are not needed here please tell me).

I have tried to run this two ways. The first was using the datasource tag in
the struts-config.xml file. I included it right after my action-mappings and
form-beans tag, all of which are included inside the struts-config tags.
When I start my Tomcat server, I receive an error in the console that says
basically that there are illegal characters after my action-mapping tag ends
(I.e. the datasource tag). The console will also give me a class not found
exception at java.sql.Datasource. After I point my browser at the war file I
get an error stating that it can't find the ActionMappings or
ActionFormBeans collection.

The second way I tried to run this was by simply establishing a connection
to the database manually in my Action class and using
Class.forName(jdbcUrl). However, this time, when I try run the app it will
crap out when I try to do the actual query and give me a class not found
exception at Class.forName(jdbcUrl) at the Tomcat console. The browser gives
me a null pointer exception. I think I have all the required imports within
my classes.

Using the datasource tag looks like it should be very straight forward but
I'm having no joy. For anyone who has read this far, I apologize for the
length of the message. I have included my code from the struts-config.xml
file and my Action class perform() method.


http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";>


   
  



  

  
   

   
 
 
   
   




public ActionForward perform(
 ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
 throws javax.servlet.ServletException, java.io.IOException {

 //String jdbcDriver = "oracle.jdbc.driver.OracleDriver";
 //String jdbcUrl = "jdbc:oracle:thin:@servername:1521:";
 java.sql.Connection myConnection = null;

 DatabaseForm theForm = (DatabaseForm) form;

 String id = theForm.getPackage_id();

 String description =null;
 java.sql.ResultSet rs = null;
 try
 {
  javax.sql.DataSource dataSource = servlet.findDataSource("dbtest");
   myConnection = dataSource.getConnection();
  System.out.println("You are here #1");
  //Class.forName(jdbcDriver);
  //System.out.println("You are here #2");
  //myConnection = java.sql.DriverManager.getConnection(jdbcUrl);
  myConnection = dataSource.getConnection();
   java.sql.PreparedStatement stmt =
   myConnection.prepareStatement(
"Select package_description From Packages Where package_id=" + id);

   rs = stmt.executeQuery();

  if (rs.next())
  {
   description = rs.getString("Package_Description");
  }
  else
  {
   description = "Empty";
  }

  theForm.setPackage_description(description);


 }

 catch (java.sql.SQLException sqle)
 {
  getServlet().log("Connection.process", sqle);
 }
 //catch (ClassNotFoundException e)
 //{
 //}
 catch (NullPointerException npe)
 {

 }
 finally
 {

  try
  {

   myConnection.close();
  }
  catch (java.sql.SQLException e)
  {
   getServlet().log("Connection.close", e);
  }
 }
 //if (description != null)
 //{
  return mapping.findForward("success");
 //}
 //else
 //{
  //return mapping.findForward("fail");
 //}

}

Any help is greatly appreciated,

Scott Fitzgerald



RE: Database access problem

2001-04-26 Thread Robert Taylor




  The second way I tried to run 
  this was by simply establishing a connection to the database manually in my 
  Action class and using Class.forName(jdbcUrl). However, this time, when I 
  try run the app it will crap out when I try to do the actual query and give me 
  a class not found exception at Class.forName(jdbcUrl) at the Tomcat console. 
  The browser gives me a null pointer exception. I think 
  I have all the required imports within my 
  classes.
   
   
  It is my understanding that it should 
  be Class.forName(driverName). This is how the class loader makes the 
  driver available to your app and is also the reason why you are getting 
  a  ClassNotFoundException.
   
   
  HTH, 
   
  Robert
   


RE: Database access problem

2001-04-26 Thread Scott Fitzgerald



Actually, it is 
jdbcDriver that I use in the call to Class.forName() not jdbcUrl. Sorry for the 
misprint.
 
Scott 
Fitzgerald


RE: Database access problem

2001-04-26 Thread struts

sorry, i didn't read the full details of your problem
earlier. however, for the below, just for kicks, try calling
newInstance() as in:

Class.forName(...).newInstance()

I've noticed some drivers require an actual instance somewhere to be
created just once.

jae

Scott Fitzgerald writes:
 > Actually, it is jdbcDriver that I use in the call to Class.forName() not
 > jdbcUrl. Sorry for the misprint.



RE: Database access problem

2001-04-27 Thread Scott Fitzgerald




Thanks 
for tip. It got me past that line but now it stops at the next line: 

myConnection = java.sql.DriverManager.getConnection(jdbcUrl); 

and 
gives me an error... Exception in: R( /warfile + /dbtest.do + null) - 
java.lang.NullPointerException.
Any 
more helpful hints?
Thanks,
Scott 
Fitzgerald
 
sorry, i didn't read the full details 
of your problem
earlier. however, for the below, just 
for kicks, try calling
newInstance() as in:
Class.forName(...).newInstance()
I've noticed some drivers require an 
actual instance somewhere to be
created just once.
jae

Scott 
Fitzgerald, B.A., A.I.T.Application DeveloperColabNet
Collaborative 
Network Technologies, Inc. 55 Bond Street, Suite 
202, St. 
John's NF A1C 5V3 Tel: (709) 754-7482 
Fax: 754-7406  Website: http://www.colabnet.com
 


RE: Database access problem

2001-04-27 Thread struts

your jdbc driver is probably not recognizing the jdbcUrl you're
passing in. the url string is basically dependent on the driver and
can be almost any format it wants. you'll want to verify the url
string as one the driver recognizes.

also, the DriverManager has a method call for returning a list of all
registered drivers. you may also want to verify the driver you want is
there.

jae

Scott Fitzgerald writes:
 > Thanks for tip. It got me past that line but now it stops at the next line:
 > 
 > myConnection = java.sql.DriverManager.getConnection(jdbcUrl);
 > 
 > and gives me an error... Exception in: R( /warfile + /dbtest.do + null) -
 > java.lang.NullPointerException.
 > 
 > Any more helpful hints?
 > 
 > Thanks,
 > 
 > Scott Fitzgerald
 > 



RE: Database access problem

2001-05-09 Thread Marouane Louah



hello
 
I' ve 
the same pb and i would like to know if you've find the solution 

Thankx
 

  -Message d'origine-De : Robert Taylor 
  [mailto:[EMAIL PROTECTED]]Envoyé : jeudi 26 avril 2001 
  20:52À : [EMAIL PROTECTED]Objet : 
  RE: Database access problem
  
The second way I tried to 
run this was by simply establishing a connection to the database manually in 
my Action class and using Class.forName(jdbcUrl). However, this time, 
when I try run the app it will crap out when I try to do the actual query 
and give me a class not found exception at Class.forName(jdbcUrl) at the 
Tomcat console. The browser gives me a null pointer exception. I think 
I have all the required imports within my 
classes.
 
 
It is my understanding that it should 
be Class.forName(driverName). This is how the class loader makes the 
driver available to your app and is also the reason why you are getting 
a  ClassNotFoundException.
 
 
HTH, 
 
Robert
 


Database access design question

2002-06-10 Thread rainer juenger

Hi,

I am using the Struts Database pooling.
My database connection is realised after the sample in the Struts User's
Guide.
http://jakarta.apache.org/struts/userGuide/building_model.html#databases
But I think the sample is very contradicting.
In chapter 2.5 Business Logic Beans is said:
"For maximum code re-use, business logic beans should be designed and
implemented so that they do not know they are being executed in a web
application environment. If you find yourself having to import a
javax.servlet.* class in your bean, you are tying this business logic to the
web application environment. "

but chapter 2.6 is Accessing the Database in the sample via a ActionServlet:
public ActionForward
   perform(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response)
{
 javax.sql.DataSource dataSource;
 java.sql.Connection myConnection;

 try {
   dataSource = servlet.findDataSource(null);
   myConnection = dataSource.getConnection();

Now I am pretty confused since I want to implement the Database Access in a
buiseness logic bean.


Thanks for your help!

Rainer


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Database access using JSTL sql

2003-02-25 Thread Paul Pattison
Hi all,

I'm trying return an xml page based on a simple sql query.  I thought that this would 
be easily done using the JSTL sql tags. How do I access the Struts datasource from the 
jsp?  What should the value of my 'dataSource' element in the 'sql:query' tag be?  I 
haven't been able to get it work and I couldn't find any clues in the archive.

Secondly, is this method looked down upon because I'm accessing the database from my 
jsp?  I have written Actions that access the database, but how can I pass the result 
object to the jsp so that I can easily output it using the 'c.out' tags from JSTL?

Thanks,

Paul


Here is my datasource as defined in struts-config.xml:


  
  
  
  
  
  
  
  



Here is my test.jsp:

<%@ page contentType="text/xml" %>
<%@ page import="java.util.*" %>
<%@ taglib uri="/tags/jstl-c" prefix="c" %>
<%@ taglib uri="/tags/jstl-sql" prefix="sql" %>


  SELECT task_id,task_def_id,approve_date
FROM tasks




  

  
  

  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] database access philosophy

2003-02-26 Thread Jarnot Voytek Contr AU HQ/SC
The two typical solutions are disconnected RowSets and copying the ResultSet
into a collection of value objects.  Pros and cons abound for either method
- one pollutes your code with sql packages and one involves copying a lot of
data...

--
Voytek Jarnot
Quidquid latine dictum sit, altum viditur.


> -Original Message-
> From: Kirby Vandivort [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 26, 2003 11:59 AM
> To: [EMAIL PROTECTED]
> Subject: [OT] database access philosophy
> 
> 
> Hello,
> 
> I'm in the process of converting an old webapp over to using struts
> and, in the process, I decide to clean up the database access.
> 
> Old Way:
> I had written a connection pool and instantiated an instance of this
> that was passed to all methods that needed the db, and they they had
> the sql code embedded in the methods.
> 
> New Way that I'm working on:
> I've set up a DataSource for my jdbc connection, and I'm partitioning
> off all of the database access code into it's own package.  If my
> business logic needs database info, it calls a method from 
> the database
> access package to get it.  
> 
> My problem:
> 
> Many methods from the database access return simple data.
> 
> However, I currently have it written so that some of the more complex
> ones return a ResultSet, which I'm not really happy with.  
> This exposes
> the DB layer to the business logic, but I'm not totally sure what the
> best way to avoid this is.  In addition, this doesn't work :( because
> the underlying connection gets closed when the database access method
> exists, and the ResultSet is no longer valid.
> 
> SO,  I am wondering what people do when they need to return all of the
> data in a ResultSet to their business layer.  Do you have to go to the
> hassle of copying everything to some sort of data structure, or is
> there a better, cleaner, faster way to handle this?
> 
> (I'm kind of assuming that the ResultSet will be small enough to fit
> in memory and there won't be issues with pulling it in in pieces;  how
> would that be handled, though?)
> 
> Thanks,
> 
> -- 
> 
> Kirby Vandivort  Theoretical and 
> Computational Biophysics 
> Email: [EMAIL PROTECTED]  3051 Beckman Institute
> http://www.ks.uiuc.edu/~kvandivo/University of Illinois
> Phone: (217) 244-5711405 N. Mathews Ave
> Fax  : (217) 244-6078Urbana, IL  61801, USA
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [OT] database access philosophy

2003-02-26 Thread Andy Kriger
Check out this article
http://www.javaworld.com/javaworld/jw-05-2002/jw-0524-sql.html

A nice to way to keep the ResultSet in yr db classes and allow your other
classes to remain ignorant of db access.

-Original Message-
From: Kirby Vandivort [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 12:59
To: [EMAIL PROTECTED]
Subject: [OT] database access philosophy


Hello,

I'm in the process of converting an old webapp over to using struts
and, in the process, I decide to clean up the database access.

Old Way:
I had written a connection pool and instantiated an instance of this
that was passed to all methods that needed the db, and they they had
the sql code embedded in the methods.

New Way that I'm working on:
I've set up a DataSource for my jdbc connection, and I'm partitioning
off all of the database access code into it's own package.  If my
business logic needs database info, it calls a method from the database
access package to get it.

My problem:

Many methods from the database access return simple data.

However, I currently have it written so that some of the more complex
ones return a ResultSet, which I'm not really happy with.  This exposes
the DB layer to the business logic, but I'm not totally sure what the
best way to avoid this is.  In addition, this doesn't work :( because
the underlying connection gets closed when the database access method
exists, and the ResultSet is no longer valid.

SO,  I am wondering what people do when they need to return all of the
data in a ResultSet to their business layer.  Do you have to go to the
hassle of copying everything to some sort of data structure, or is
there a better, cleaner, faster way to handle this?

(I'm kind of assuming that the ResultSet will be small enough to fit
in memory and there won't be issues with pulling it in in pieces;  how
would that be handled, though?)

Thanks,

--

Kirby Vandivort  Theoretical and Computational
Biophysics
Email: [EMAIL PROTECTED]  3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/University of Illinois
Phone: (217) 244-5711405 N. Mathews Ave
Fax  : (217) 244-6078Urbana, IL  61801, USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] database access philosophy

2003-02-26 Thread David Graham
I usually copy each row into a domain layer object like "Person" or 
"Account".  That's probably too slow for a batch type application but it 
works fine for web applications.  Alternatively you can use a RowSet which 
is disconnected from the database.

David



From: Kirby Vandivort <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [OT] database access philosophy
Date: Wed, 26 Feb 2003 11:59:23 -0600
Hello,

I'm in the process of converting an old webapp over to using struts
and, in the process, I decide to clean up the database access.
Old Way:
I had written a connection pool and instantiated an instance of this
that was passed to all methods that needed the db, and they they had
the sql code embedded in the methods.
New Way that I'm working on:
I've set up a DataSource for my jdbc connection, and I'm partitioning
off all of the database access code into it's own package.  If my
business logic needs database info, it calls a method from the database
access package to get it.
My problem:

Many methods from the database access return simple data.

However, I currently have it written so that some of the more complex
ones return a ResultSet, which I'm not really happy with.  This exposes
the DB layer to the business logic, but I'm not totally sure what the
best way to avoid this is.  In addition, this doesn't work :( because
the underlying connection gets closed when the database access method
exists, and the ResultSet is no longer valid.
SO,  I am wondering what people do when they need to return all of the
data in a ResultSet to their business layer.  Do you have to go to the
hassle of copying everything to some sort of data structure, or is
there a better, cleaner, faster way to handle this?
(I'm kind of assuming that the ResultSet will be small enough to fit
in memory and there won't be issues with pulling it in in pieces;  how
would that be handled, though?)
Thanks,

--

Kirby Vandivort  Theoretical and Computational 
Biophysics
Email: [EMAIL PROTECTED]  3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/University of Illinois
Phone: (217) 244-5711405 N. Mathews Ave
Fax  : (217) 244-6078Urbana, IL  61801, USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: [OT] database access philosophy

2003-02-26 Thread Wendy Smoak
Kirby wrote:
> SO,  I am wondering what people do when they need to return all of the
> data in a ResultSet to their business layer.  Do you have to go to the
> hassle of copying everything to some sort of data structure, or is
> there a better, cleaner, faster way to handle this?

Does this look useful?  

"Implementation of DynaClass for DynaBeans that wrap the java.sql.Row
objects of a java.sql.ResultSet"

http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils
/ResultSetDynaClass.html

I haven't gotten to use it yet since my database doesn't speak JDBC, but it
looks interesting!

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management


RE: [OT] database access philosophy

2003-02-26 Thread Mitchell Morris
If you've decided on copying data instead of passing around ResultSets and
you want to keep your own DB mapping layer, then maybe some beans and
commons-beanutils will satisfy your immediate needs. There are plenty of
property copier/converter things there, all with the Apache seal of approval
on 'em.

If you're willing to get rid of your own DB mapping layer, then there's lots
of ways to deal with that too, as a quick google on "java persistence
framework" will show (45,600 hits just now). I used to use a hand-rolled
persistence layer modeled on Martin Fowler's "Enterprise Application"
patterns (UnitOfWork, AbstractMapper, et al). It wound up looking a great
deal like Jaxor (jaxor.sourceforge.net). I discovered Hibernate
(hibernate.sourceforge.net) and threw away my own mapping code with great
delight although I haven't completely given up on J2EE CMP-2.x yet.

For a quick view of how many frameworks you have to choose from, try
http://www.uq.net.au/~zzabergl/simpleorm/ORMTools.html and there's a Wiki
page without explicit reviews at
http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison

how-did-we-get-too-much-info-before-the-internet-ly y'rs,
+Mitchell

[snip]
> SO,  I am wondering what people do when they need to return all of the
> data in a ResultSet to their business layer.  Do you have to go to the
> hassle of copying everything to some sort of data structure, or is
> there a better, cleaner, faster way to handle this?
>
> (I'm kind of assuming that the ResultSet will be small enough to fit
> in memory and there won't be issues with pulling it in in pieces;  how
> would that be handled, though?)



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] database access philosophy

2003-02-26 Thread Kirby Vandivort
I've been looking into ResultSetDynaClass as well as something that
Ted posted a while back:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg14919.html

where he makes a collection out of a result set.


My problem, though, is that some code that we've got that accesses result
sets uses the column name, and some uses the id.  I'm not sure that
either method works with both names and id's.  That's a relatively minor
thing, though, because I guess the code can be converted to either
entirely names or entirely id's.  

At any rate, it looks like the ResultSetDynaClass code given in the
API example converts to an ArrayList, which is going to be ID based.

The example that Ted gave seems to use the ResultSet metadata to
probably return the collection via the name, although I haven't yet
totally figured his code out.  There seems to be some missing methods
that I haven't yet tracked down.

The JavaWorld example that was mentioned in another reply sounds like
it would work _except_ I don't want to have to make a bean for every
piece of data that can be sent back from the database.  I'm looking
for a way to "somewhat" dynamically create the necessary data structure
and send it back.

Kirby


On Wed, Feb 26, 2003 at 11:12:01AM -0700, Wendy Smoak wrote:
> Kirby wrote:
> > SO,  I am wondering what people do when they need to return all of the
> > data in a ResultSet to their business layer.  Do you have to go to the
> > hassle of copying everything to some sort of data structure, or is
> > there a better, cleaner, faster way to handle this?
> 
> Does this look useful?  
> 
> "Implementation of DynaClass for DynaBeans that wrap the java.sql.Row
> objects of a java.sql.ResultSet"
> 
> http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils
> /ResultSetDynaClass.html
> 
> I haven't gotten to use it yet since my database doesn't speak JDBC, but it
> looks interesting!
> 
> -- 
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University PA Information Resources Management

-- 

Kirby Vandivort  Theoretical and Computational Biophysics 
Email: [EMAIL PROTECTED]  3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/University of Illinois
Phone: (217) 244-5711405 N. Mathews Ave
Fax  : (217) 244-6078Urbana, IL  61801, USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Bean database access concepts

2002-11-27 Thread David Graham
Have a factory class create your access beans.  Before it returns a bean set 
the bean's dataSource property.  You will configure the factory's DataSource 
with the one created by Struts when you app starts up.  Make sense?

David






From: Joao Araujo <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Bean database access concepts
Date: Wed, 27 Nov 2002 11:37:10 -0500



	I am not using EJB but plain beans to access the database.
	I defined everything in such a way to isolate  database access from action 
bean.
	Now, I have some doubts about how to access the database connection.
	Should I pass the connection as a parameter to the beans that accesss the 
datdabase, or
	should I use another method?

	Thanks a lot for your attention,


Joao,



--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>


_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



Re: Bean database access concepts

2002-11-27 Thread Eddie Bush
JNDI is a pretty good way to get connections.  You'll probably want to 
provide alternate signatures of your methods for allowing a connection 
to be passed to a "save" method though - so you can involve multiple 
beans in a single transaction.

Joao Araujo wrote:

I am not using EJB but plain beans to access the database.
I defined everything in such a way to isolate  database access 
from action bean.
Now, I have some doubts about how to access the database connection.
Should I pass the connection as a parameter to the beans that 
accesss the datdabase, or
should I use another method?

Thanks a lot for your attention,

Joao, 

--
Eddie Bush




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Bean database access concepts

2002-11-27 Thread Joao Araujo


Have a factory class create your access beans.  Before it returns a bean 
set the bean's dataSource property.  You will configure the factory's 
DataSource with the one created by Struts when you app starts up.  Make sense?

Thanks.

Joao,


David







From: Joao Araujo <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Bean database access concepts
Date: Wed, 27 Nov 2002 11:37:10 -0500



I am not using EJB but plain beans to access the database.
I defined everything in such a way to isolate  database access 
from action bean.
Now, I have some doubts about how to access the database connection.
Should I pass the connection as a parameter to the beans that 
accesss the datdabase, or
should I use another method?

Thanks a lot for your attention,


Joao,



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Bean database access concepts

2002-11-27 Thread V. Cekvenich
Bean does not access the db!

DAO access the db. (DAO can be implemented several ways)
Bean has a DAO helper.

DAO can get JNDI pool from container or make its own pool, based on 
properties.

Also, you should be able to unit test you beans for CRUD.

I wonder where the sample code that does this would be? I know, if I go 
to struts resources page and look for a DB sample, that would do it.

.V


Joao Araujo wrote:


I am not using EJB but plain beans to access the database.
I defined everything in such a way to isolate  database access 
from action bean.
Now, I have some doubts about how to access the database connection.
Should I pass the connection as a parameter to the beans that 
accesss the datdabase, or
should I use another method?

Thanks a lot for your attention,

Joao, 







--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Bean database access concepts

2002-11-27 Thread David Graham
Your DAO objects can be beans.

David







From: "V. Cekvenich" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Bean database access concepts
Date: Wed, 27 Nov 2002 12:25:06 -0500

Bean does not access the db!

DAO access the db. (DAO can be implemented several ways)
Bean has a DAO helper.

DAO can get JNDI pool from container or make its own pool, based on 
properties.

Also, you should be able to unit test you beans for CRUD.

I wonder where the sample code that does this would be? I know, if I go to 
struts resources page and look for a DB sample, that would do it.

.V


Joao Araujo wrote:


I am not using EJB but plain beans to access the database.
I defined everything in such a way to isolate  database access from 
action bean.
Now, I have some doubts about how to access the database connection.
Should I pass the connection as a parameter to the beans that 
accesss the datdabase, or
should I use another method?

Thanks a lot for your attention,

Joao,







--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>


_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



Re: Bean database access concepts

2002-11-27 Thread V. Cekvenich
Yes of course. But then if you want to change your persistence 
implementation it is more difficult.

.V

David Graham wrote:
Your DAO objects can be beans.

David







From: "V. Cekvenich" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Bean database access concepts
Date: Wed, 27 Nov 2002 12:25:06 -0500

Bean does not access the db!

DAO access the db. (DAO can be implemented several ways)
Bean has a DAO helper.

DAO can get JNDI pool from container or make its own pool, based on 
properties.

Also, you should be able to unit test you beans for CRUD.

I wonder where the sample code that does this would be? I know, if I 
go to struts resources page and look for a DB sample, that would do it.

.V


Joao Araujo wrote:


I am not using EJB but plain beans to access the database.
I defined everything in such a way to isolate  database access 
from action bean.
Now, I have some doubts about how to access the database 
connection.
Should I pass the connection as a parameter to the beans that 
accesss the datdabase, or
should I use another method?

Thanks a lot for your attention,

Joao,








--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>



_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Bean database access concepts

2002-11-27 Thread David Graham
No it's not.  One of your implementations could be JavaBeans using JDBC 
calls and another implementation could be EJBs.  The factory switches them 
seemlessly when needed.

David






From: "V. Cekvenich" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Bean database access concepts
Date: Wed, 27 Nov 2002 15:12:09 -0500

Yes of course. But then if you want to change your persistence 
implementation it is more difficult.

.V

David Graham wrote:
Your DAO objects can be beans.

David







From: "V. Cekvenich" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Bean database access concepts
Date: Wed, 27 Nov 2002 12:25:06 -0500

Bean does not access the db!

DAO access the db. (DAO can be implemented several ways)
Bean has a DAO helper.

DAO can get JNDI pool from container or make its own pool, based on 
properties.

Also, you should be able to unit test you beans for CRUD.

I wonder where the sample code that does this would be? I know, if I go 
to struts resources page and look for a DB sample, that would do it.

.V


Joao Araujo wrote:


I am not using EJB but plain beans to access the database.
I defined everything in such a way to isolate  database access 
from action bean.
Now, I have some doubts about how to access the database 
connection.
Should I pass the connection as a parameter to the beans that 
accesss the datdabase, or
should I use another method?

Thanks a lot for your attention,

Joao,








--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>



_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>


_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



Re: Database access deployment question

2002-09-19 Thread Eddie Bush

So far as your DB access goes, you could do away with using the 
data-source inside struts and declare one in JNDI using whichever 
container you're using.  Addressing your property file concerns:  I 
don't see a good way around this.  If you standardized on a name, you 
could simply have them ensure that the properties file is in the 
classpath and then just load it by name -- and let the classloader 
figure out where it's at.  Someone else probably has a far better idea 
on that though ...

Kirby Vandivort wrote:

>Hello,
>
>I have been reading up on accessing databases from within the struts
>framework, and I'm not totally sure of the best way to approach the
>issue of deployment.
>
>We package up a WAR file for distribution to end users, and I would
>like to be able to tell them to drop the WAR file in webapps and be
>done with it.  (ie., not have to uncompress it).
>
>However, from what I can tell, setting up "clean" database access
>includes doing something like making a data-source entry and placing it
>in the web.xml in the WEB-INF directory of the deployed application.
>
>Since the properties for the database (username, password, etc) will be
>different for each end user, I can't apriori set values for this.
>
>So, what does everyone out there that has been down this road before do
>to solve this problem?  I guess, really, this goes beyond simple
>database access.  We also have a few other settings for our application
>that need to be set.
>
>CURRENTLY, we aren't using struts (pure servlets) and we have properties
>files that contain this information.  But, we are currently requiring
>the user to unpack the WAR file and I would love to get away from this.
>
>Thanks for your help!
>

-- 
Eddie Bush




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access deployment question

2002-09-19 Thread Danny Mui

The container usually sets up a datasource for you in JNDI, for tomcat 
you modify server.xml and in resin you modify resin.conf so that's 
outside your web application.  In your web.xml file you just define the 
 to expose to your application and all you have make 
sure is that the JNDI names match in the container definition :).

So all you need to access a DB connection is fetch it from JNDI.  For 
your other settings? You go in and modify the exploded web application 
since the container does that anyway :).

danny

Kirby Vandivort wrote:

>Hello,
>
>I have been reading up on accessing databases from within the struts
>framework, and I'm not totally sure of the best way to approach the
>issue of deployment.
>
>We package up a WAR file for distribution to end users, and I would
>like to be able to tell them to drop the WAR file in webapps and be
>done with it.  (ie., not have to uncompress it).
>
>However, from what I can tell, setting up "clean" database access
>includes doing something like making a data-source entry and placing it
>in the web.xml in the WEB-INF directory of the deployed application.
>
>Since the properties for the database (username, password, etc) will be
>different for each end user, I can't apriori set values for this.
>
>So, what does everyone out there that has been down this road before do
>to solve this problem?  I guess, really, this goes beyond simple
>database access.  We also have a few other settings for our application
>that need to be set.
>
>CURRENTLY, we aren't using struts (pure servlets) and we have properties
>files that contain this information.  But, we are currently requiring
>the user to unpack the WAR file and I would love to get away from this.
>
>Thanks for your help!
>
>  
>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access deployment question

2002-09-19 Thread Craig R. McClanahan

If you're running on a container that supports it (which means any J2EE
container plus Tomcat 4), using JNDI resources is the right way to deal
with this.  Essentially, you declare a "resource reference" to a data
source in your web.xml file, and then configure the database access
details in your server's configuration file.

The configuration process is container-specific -- here's the docs on
using Tomcat (which also includes programming examples for accessing the
data source):

  http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html

Craig


On Thu, 19 Sep 2002, Kirby Vandivort wrote:

> Date: Thu, 19 Sep 2002 09:37:10 -0500
> From: Kirby Vandivort <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Database access deployment question
>
> Hello,
>
> I have been reading up on accessing databases from within the struts
> framework, and I'm not totally sure of the best way to approach the
> issue of deployment.
>
> We package up a WAR file for distribution to end users, and I would
> like to be able to tell them to drop the WAR file in webapps and be
> done with it.  (ie., not have to uncompress it).
>
> However, from what I can tell, setting up "clean" database access
> includes doing something like making a data-source entry and placing it
> in the web.xml in the WEB-INF directory of the deployed application.
>
> Since the properties for the database (username, password, etc) will be
> different for each end user, I can't apriori set values for this.
>
> So, what does everyone out there that has been down this road before do
> to solve this problem?  I guess, really, this goes beyond simple
> database access.  We also have a few other settings for our application
> that need to be set.
>
> CURRENTLY, we aren't using struts (pure servlets) and we have properties
> files that contain this information.  But, we are currently requiring
> the user to unpack the WAR file and I would love to get away from this.
>
> Thanks for your help!
>
> --
>
> Kirby Vandivort  Theoretical Biophysics Group
> Email: [EMAIL PROTECTED]  3051 Beckman Institute
> http://www.ks.uiuc.edu/~kvandivo/University of Illinois
> Phone: (217) 244-5711405 N. Mathews Ave
> Fax  : (217) 244-6078Urbana, IL  61801, USA
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access deployment question

2002-09-19 Thread Kirby Vandivort

The Craig has spoken.  Thus shall it be.

On Thu, Sep 19, 2002 at 09:31:07AM -0700, Craig R. McClanahan wrote:
> If you're running on a container that supports it (which means any J2EE
> container plus Tomcat 4), using JNDI resources is the right way to deal
> with this.  Essentially, you declare a "resource reference" to a data
> source in your web.xml file, and then configure the database access
> details in your server's configuration file.
> 
> The configuration process is container-specific -- here's the docs on
> using Tomcat (which also includes programming examples for accessing the
> data source):
> 
>   http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html
> 
> Craig
> 
> 
> On Thu, 19 Sep 2002, Kirby Vandivort wrote:
> 
> > Date: Thu, 19 Sep 2002 09:37:10 -0500
> > From: Kirby Vandivort <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Database access deployment question
> >
> > Hello,
> >
> > I have been reading up on accessing databases from within the struts
> > framework, and I'm not totally sure of the best way to approach the
> > issue of deployment.
> >
> > We package up a WAR file for distribution to end users, and I would
> > like to be able to tell them to drop the WAR file in webapps and be
> > done with it.  (ie., not have to uncompress it).
> >
> > However, from what I can tell, setting up "clean" database access
> > includes doing something like making a data-source entry and placing it
> > in the web.xml in the WEB-INF directory of the deployed application.
> >
> > Since the properties for the database (username, password, etc) will be
> > different for each end user, I can't apriori set values for this.
> >
> > So, what does everyone out there that has been down this road before do
> > to solve this problem?  I guess, really, this goes beyond simple
> > database access.  We also have a few other settings for our application
> > that need to be set.
> >
> > CURRENTLY, we aren't using struts (pure servlets) and we have properties
> > files that contain this information.  But, we are currently requiring
> > the user to unpack the WAR file and I would love to get away from this.
> >
> > Thanks for your help!
> >
> > --
> >
> > Kirby Vandivort  Theoretical Biophysics Group
> > Email: [EMAIL PROTECTED]  3051 Beckman Institute
> > http://www.ks.uiuc.edu/~kvandivo/University of Illinois
> > Phone: (217) 244-5711405 N. Mathews Ave
> > Fax  : (217) 244-6078Urbana, IL  61801, USA
> >
> > --
> > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> >
> >
> 

-- 

Kirby Vandivort  Theoretical Biophysics Group
Email: [EMAIL PROTECTED]  3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/University of Illinois
Phone: (217) 244-5711405 N. Mathews Ave
Fax  : (217) 244-6078Urbana, IL  61801, USA

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Best Approach for Database Access?

2002-02-12 Thread Paul Idusogie

Could you kindly provide guidance on the best approach to implement database access.?
I have encountered various schools of thought in my reading, that suggest extracting 
the business logic and database code from the jsp into a jsp bean or ejb or servlet.

Thanks,

Paul Idusogie 
Technical Architect 
Consulting Services
Stellent Inc.
 Golden Triangle Drive
Eden Prairie, MN 55104
Desk: 952.656.2755
Fax: 952.903.2115
Email: [EMAIL PROTECTED]
website: http://www.stellent.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database Access Problem.Need Help?

2002-02-28 Thread Kanoza, Douglas (NCI)

I've been using the DataSource for a while without any problems, but I never
explicitly specified the key or type properties in the data-source tag, or
the context-param in web.xml.  I just copied it right from the example app
and put in my settings, but I'm using Tomcat 3.2.4 and 4.0.1.  Also, I'm not
using findDataSource to get the source in my Action classes.  I use:

DataSource lSource = (DataSource)servlet.getServletContext()
.getAttribute(Action.DATA_SOURCE_KEY);

Hope that helps.

-Original Message-
From: Anant Sagar [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 28, 2002 5:16 AM
To: 'Struts Users Mailing List'
Subject: Database Access Problem.Need Help?

Hello ,

I am new to Struts and facing problem regarding the Database access .I m
getting DataSource as null even though , i ve done changes in Data Source
Configuratio .
I m using Tomcat 3.2.1 .

This is what I have done in struts-config.xml file 
---
 

  
  
  
  
  
  

  
---
And my web.xml has context 
-

  org.apache.struts.action.DATA_SOURCE
  org.apache.struts.util.GenericDataSource
  
-
My Action class reads as below to get the connection
--
javax.sql.DataSource dataSource  =
servlet.findDataSource("org.apache.struts.action.DATA_SOURCE");
java.sql.Connection myConnection =dataSource.getConnection();
java.sql.Statement st  =  myConnection.createStatement();
int x   =  st.executeUpdate( " Some _ Query ");

--

I m getting dataSource as null.

What do you have to say bout this ?  Is there anything wrong. Please let me
know .
Thanks in advance.

- Sager

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database Access Problem.Need Help?

2002-03-01 Thread Anant Sagar

Thanks Kanoza ,

I have tried and its working that way as well. In fact after posting my
query i tried to solve the problem .The problem was due to the Driver which
I was using , I changed the driver and it started working with the the
existing code.

But i m surprised why the Exception was not shown on the console rather I
was getting NullPointerException.

Rgds.
- Anant Sagar

- Original Message -
From: "Kanoza, Douglas (NCI)" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, February 28, 2002 7:44 PM
Subject: RE: Database Access Problem.Need Help?


> I've been using the DataSource for a while without any problems, but I
never
> explicitly specified the key or type properties in the data-source tag, or
> the context-param in web.xml.  I just copied it right from the example app
> and put in my settings, but I'm using Tomcat 3.2.4 and 4.0.1.  Also, I'm
not
> using findDataSource to get the source in my Action classes.  I use:
>
> DataSource lSource = (DataSource)servlet.getServletContext()
> .getAttribute(Action.DATA_SOURCE_KEY);
>
> Hope that helps.
>
> -Original Message-
> From: Anant Sagar [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 28, 2002 5:16 AM
> To: 'Struts Users Mailing List'
> Subject: Database Access Problem.Need Help?
>
> Hello ,
>
> I am new to Struts and facing problem regarding the Database access .I m
> getting DataSource as null even though , i ve done changes in Data Source
> Configuratio .
> I m using Tomcat 3.2.1 .
>
> This is what I have done in struts-config.xml file
> ---
>  
>  type="org.apache.struts.util.GenericDataSource">
>   value="false"/>
>   value="Example Data Source Configuration"/>
>   value="oracle.jdbc.driver.OracleDriver"
>   value="4"/>
>   value="2"/>
>   value="sree"/>
>value="jdbc:oracle:thin:@199.100.100.100:1521:prod"
>   value="sree"/>
> 
>   
> ---
> And my web.xml has context
> -
> 
>   org.apache.struts.action.DATA_SOURCE
>   org.apache.struts.util.GenericDataSource
>   
> -
> My Action class reads as below to get the connection
> --
> javax.sql.DataSource dataSource  =
> servlet.findDataSource("org.apache.struts.action.DATA_SOURCE");
> java.sql.Connection myConnection =dataSource.getConnection();
> java.sql.Statement st  =  myConnection.createStatement();
> int x   =  st.executeUpdate( " Some _ Query ");
>
> --
>
> I m getting dataSource as null.
>
> What do you have to say bout this ?  Is there anything wrong. Please let
me
> know .
> Thanks in advance.
>
> - Sager
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access via OO

2000-11-09 Thread Michael Westbay

Pramod-san wrote:

> Hi all,

HTML off please.

> Does any one know about any good Java OO implmentations using which
> direct database access from the middle layer can be avoided to the
> maximum ?
> 
> A vague explanation will be like - Middle layer coders will not be
> accessing database directly,  what they do is, create objects and
> [...]

I think I understand what you want.  You want to allow users to access the
database in a read-only fassion.  Would something like giving a been the
table name as a parameter and getting a 2D hash of "SELECT * from {0}"
where "{0}" is the passed table name do?

I've written such classes before, but with further restrictions and very
much tied to a particular application.  I wish they were more portable.

> Sorry if its stupid/confusing. Even I dont have a clear idea on that.
> If u get what i mean, please help

Not stupid at all.  Perhaps just redefining the problem would make it
easier to come up with a solution to build yourself.

Other than the table name, what kind of restrictions do you want to place
on the SELECT statement?  For example, I wouldn't allow subqueries as
strings since it would put other sensitive data at risk.  Conditions were
another passed parameter, and had to be checked to make sure that no
subqueries were in there.  Pass a list of fields (comma seperated or as an
array) to get things like "SUM(n) as N" (again, checking for subqueries).

After getting "SELECT *", the bean can then process what all of the field
names are using the ResultSetMetaData.  Types can be retrieved from the
meta data as well, if you want to support more types than just Strings.

Now, am I being too vague?  I don't know of such a package, but these are
a few ideas of how to implement one.  (I'm not sure that this relates to
Struts, though.)

Well, hope that helps to get you on the right track.

--
Michael Westbay
Work: Beacon-IT http://www.beacon-it.co.jp/
Home:   http://www.seaple.icc.ne.jp/~westbay
Commentary: http://www.japanesebaseball.com/



RE: Database access via OO

2000-11-09 Thread Lacerda, Wellington (AFIS)

Have you seen Castor ?

http://www.exolab.org

Wellington Silva
UN/FAO

-Original Message-
From: Michael Westbay [mailto:[EMAIL PROTECTED]]
Sent: 09 November 2000 10:17
To: [EMAIL PROTECTED]
Subject: Re: Database access via OO


Pramod-san wrote:

> Hi all,

HTML off please.

> Does any one know about any good Java OO implmentations using which
> direct database access from the middle layer can be avoided to the
> maximum ?
> 
> A vague explanation will be like - Middle layer coders will not be
> accessing database directly,  what they do is, create objects and
> [...]

I think I understand what you want.  You want to allow users to access the
database in a read-only fassion.  Would something like giving a been the
table name as a parameter and getting a 2D hash of "SELECT * from {0}"
where "{0}" is the passed table name do?

I've written such classes before, but with further restrictions and very
much tied to a particular application.  I wish they were more portable.

> Sorry if its stupid/confusing. Even I dont have a clear idea on that.
> If u get what i mean, please help

Not stupid at all.  Perhaps just redefining the problem would make it
easier to come up with a solution to build yourself.

Other than the table name, what kind of restrictions do you want to place
on the SELECT statement?  For example, I wouldn't allow subqueries as
strings since it would put other sensitive data at risk.  Conditions were
another passed parameter, and had to be checked to make sure that no
subqueries were in there.  Pass a list of fields (comma seperated or as an
array) to get things like "SUM(n) as N" (again, checking for subqueries).

After getting "SELECT *", the bean can then process what all of the field
names are using the ResultSetMetaData.  Types can be retrieved from the
meta data as well, if you want to support more types than just Strings.

Now, am I being too vague?  I don't know of such a package, but these are
a few ideas of how to implement one.  (I'm not sure that this relates to
Struts, though.)

Well, hope that helps to get you on the right track.

--
Michael Westbay
Work: Beacon-IT http://www.beacon-it.co.jp/
Home:   http://www.seaple.icc.ne.jp/~westbay
Commentary: http://www.japanesebaseball.com/



RE: Database access via OO

2000-11-09 Thread Joel Schneider

Another one is jRelationalFramework:

http://sourceforge.net/projects/jrf/
http://jrf.sourceforge.net/

Joel

On Thu, 9 Nov 2000, Lacerda, Wellington (AFIS) wrote:
> Have you seen Castor ?
> 
> http://www.exolab.org
> 
> Wellington Silva
> UN/FAO
> 
> -Original Message-
> From: Michael Westbay [mailto:[EMAIL PROTECTED]]
> Sent: 09 November 2000 10:17
> To: [EMAIL PROTECTED]
> Subject: Re: Database access via OO
> 
> 
> Pramod-san wrote:
> 
> > Hi all,
> 
> HTML off please.
> 
> > Does any one know about any good Java OO implmentations using which
> > direct database access from the middle layer can be avoided to the
> > maximum ?




RE: Database access via OO

2000-11-09 Thread Matt Heinrichs

Might want to check out Expresso, from javacorporate.com

That is what we are planning to use with our Struts app for OO mapping, plus some of 
it's other services.


Matt
-
Matthew W. Heinrichs
Fax: 1(501)421-7321
cell: (612)749-

-Original Message-
From:Joel Schneider [EMAIL PROTECTED]
Sent:Thu, 9 Nov 2000 10:06:07 -0600 (CST)
To:  [EMAIL PROTECTED]
Subject: RE: Database access via OO


Another one is jRelationalFramework:

http://sourceforge.net/projects/jrf/
http://jrf.sourceforge.net/

Joel

On Thu, 9 Nov 2000, Lacerda, Wellington (AFIS) wrote:
> Have you seen Castor ?
> 
> http://www.exolab.org
> 
> Wellington Silva
> UN/FAO
> 
> -Original Message-
> From: Michael Westbay [mailto:[EMAIL PROTECTED]]
> Sent: 09 November 2000 10:17
> To: [EMAIL PROTECTED]
> Subject: Re: Database access via OO
> 
> 
> Pramod-san wrote:
> 
> > Hi all,
> 
> HTML off please.
> 
> > Does any one know about any good Java OO implmentations using which
> > direct database access from the middle layer can be avoided to the
> > maximum ?




___
Visit http://www.visto.com/info, your free web-based communications center.
Visto.com. Life on the Dot.




Re: Database access via OO

2000-11-09 Thread Pramod

Hi all,

Thank u very much for the help. I'll check these and tell u my observations.

Thanks,

Pramod

- Original Message -
From: Matt Heinrichs <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 09, 2000 10:45 PM
Subject: RE: Database access via OO


> Might want to check out Expresso, from javacorporate.com
>
> That is what we are planning to use with our Struts app for OO mapping,
plus some of it's other services.
>
>
> Matt
> -
> Matthew W. Heinrichs
> Fax: 1(501)421-7321
> cell: (612)749-
>
> -Original Message-
> From:Joel Schneider [EMAIL PROTECTED]
> Sent:Thu, 9 Nov 2000 10:06:07 -0600 (CST)
> To:  [EMAIL PROTECTED]
> Subject: RE: Database access via OO
>
>
> Another one is jRelationalFramework:
>
> http://sourceforge.net/projects/jrf/
> http://jrf.sourceforge.net/
>
> Joel
>
> On Thu, 9 Nov 2000, Lacerda, Wellington (AFIS) wrote:
> > Have you seen Castor ?
> >
> > http://www.exolab.org
> >
> > Wellington Silva
> > UN/FAO
> >
> > -Original Message-----
> > From: Michael Westbay [mailto:[EMAIL PROTECTED]]
> > Sent: 09 November 2000 10:17
> > To: [EMAIL PROTECTED]
> > Subject: Re: Database access via OO
> >
> >
> > Pramod-san wrote:
> >
> > > Hi all,
> >
> > HTML off please.
> >
> > > Does any one know about any good Java OO implmentations using which
> > > direct database access from the middle layer can be avoided to the
> > > maximum ?
>
>
>
>
>
___
> Visit http://www.visto.com/info, your free web-based communications
center.
> Visto.com. Life on the Dot.




RE: Database access design question

2002-06-10 Thread Vikram Goyal01

What exactly is your question? 
The samples given with Struts do not necessarily following the best practices, they 
are more like proof of concepts than anything else.

Rgs
Vikram

-Original Message-
From: rainer juenger [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 1:45 PM
To: Struts Users Mailing List
Subject: Database access design question


Hi,

I am using the Struts Database pooling.
My database connection is realised after the sample in the Struts User's
Guide.
http://jakarta.apache.org/struts/userGuide/building_model.html#databases
But I think the sample is very contradicting.
In chapter 2.5 Business Logic Beans is said:
"For maximum code re-use, business logic beans should be designed and
implemented so that they do not know they are being executed in a web
application environment. If you find yourself having to import a
javax.servlet.* class in your bean, you are tying this business logic to the
web application environment. "

but chapter 2.6 is Accessing the Database in the sample via a ActionServlet:
public ActionForward
   perform(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response)
{
 javax.sql.DataSource dataSource;
 java.sql.Connection myConnection;

 try {
   dataSource = servlet.findDataSource(null);
   myConnection = dataSource.getConnection();

Now I am pretty confused since I want to implement the Database Access in a
buiseness logic bean.


Thanks for your help!

Rainer


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access design question

2002-06-10 Thread rainer juenger

I want to accesss the database from a business logic bean that should not
emplement *.servelet.* classes.
But how can I then initialize the DataSource?
like: dataSource = servlet.findDataSource(null);

??

Thanks Rainer


> What exactly is your question?
> The samples given with Struts do not necessarily following the best
practices, they are more like proof of concepts than anything else.
>
> Rgs
> Vikram
>
> -Original Message-
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 1:45 PM
> To: Struts Users Mailing List
> Subject: Database access design question
>
>
> Hi,
>
> I am using the Struts Database pooling.
> My database connection is realised after the sample in the Struts User's
> Guide.
> http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> But I think the sample is very contradicting.
> In chapter 2.5 Business Logic Beans is said:
> "For maximum code re-use, business logic beans should be designed and
> implemented so that they do not know they are being executed in a web
> application environment. If you find yourself having to import a
> javax.servlet.* class in your bean, you are tying this business logic to
the
> web application environment. "
>
> but chapter 2.6 is Accessing the Database in the sample via a
ActionServlet:
> public ActionForward
>perform(ActionMapping mapping,
>ActionForm form,
>HttpServletRequest request,
>HttpServletResponse response)
> {
>  javax.sql.DataSource dataSource;
>  java.sql.Connection myConnection;
>
>  try {
>dataSource = servlet.findDataSource(null);
>myConnection = dataSource.getConnection();
>
> Now I am pretty confused since I want to implement the Database Access in
a
> buiseness logic bean.
>
>
> Thanks for your help!
>
> Rainer
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread Vikram Goyal01

1. Do not use the session bean to access the datasource... create a data access object 
which locates the datasource.
2. Lookup the datasource using a jndi name not a servlet. Register your datasource 
with the jndi server. (Does the servlet api implement such a method ??)
3. If using a connection pool (which you should really), get the connection object out 
of the pool and use it to access the database.

HTH
Vikram


-Original Message-
From: rainer juenger [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 2:04 PM
To: Struts Users Mailing List
Subject: Re: Database access design question


I want to accesss the database from a business logic bean that should not
emplement *.servelet.* classes.
But how can I then initialize the DataSource?
like: dataSource = servlet.findDataSource(null);

??

Thanks Rainer


> What exactly is your question?
> The samples given with Struts do not necessarily following the best
practices, they are more like proof of concepts than anything else.
>
> Rgs
> Vikram
>
> -Original Message- 
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 1:45 PM
> To: Struts Users Mailing List
> Subject: Database access design question
>
>
> Hi,
>
> I am using the Struts Database pooling.
> My database connection is realised after the sample in the Struts User's
> Guide.
> http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> But I think the sample is very contradicting.
> In chapter 2.5 Business Logic Beans is said:
> "For maximum code re-use, business logic beans should be designed and
> implemented so that they do not know they are being executed in a web
> application environment. If you find yourself having to import a
> javax.servlet.* class in your bean, you are tying this business logic to
the
> web application environment. "
>
> but chapter 2.6 is Accessing the Database in the sample via a
ActionServlet:
> public ActionForward
>perform(ActionMapping mapping,
>ActionForm form,
>HttpServletRequest request,
>HttpServletResponse response)
> {
>  javax.sql.DataSource dataSource;
>  java.sql.Connection myConnection;
>
>  try {
>dataSource = servlet.findDataSource(null);
>myConnection = dataSource.getConnection();
>
> Now I am pretty confused since I want to implement the Database Access in
a
> buiseness logic bean.
>
>
> Thanks for your help!
>
> Rainer
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access design question

2002-06-10 Thread rainer juenger

I am not sure but can I use JNDI when I configure the data-sources within
the struts-config.xml like:
  

  
How else can I access the datasource?

thx Rainer


> 1. Do not use the session bean to access the datasource... create a data
access object which locates the datasource.
> 2. Lookup the datasource using a jndi name not a servlet. Register your
datasource with the jndi server. (Does the servlet api implement such a
method ??)
> 3. If using a connection pool (which you should really), get the
connection object out of the pool and use it to access the database.
>
> HTH
> Vikram
>
>
> -Original Message-
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 2:04 PM
> To: Struts Users Mailing List
> Subject: Re: Database access design question
>
>
> I want to accesss the database from a business logic bean that should not
> emplement *.servelet.* classes.
> But how can I then initialize the DataSource?
> like: dataSource = servlet.findDataSource(null);
>
> ??
>
> Thanks Rainer
>
>
> > What exactly is your question?
> > The samples given with Struts do not necessarily following the best
> practices, they are more like proof of concepts than anything else.
> >
> > Rgs
> > Vikram
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 1:45 PM
> > To: Struts Users Mailing List
> > Subject: Database access design question
> >
> >
> > Hi,
> >
> > I am using the Struts Database pooling.
> > My database connection is realised after the sample in the Struts User's
> > Guide.
> > http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > But I think the sample is very contradicting.
> > In chapter 2.5 Business Logic Beans is said:
> > "For maximum code re-use, business logic beans should be designed and
> > implemented so that they do not know they are being executed in a web
> > application environment. If you find yourself having to import a
> > javax.servlet.* class in your bean, you are tying this business logic to
> the
> > web application environment. "
> >
> > but chapter 2.6 is Accessing the Database in the sample via a
> ActionServlet:
> > public ActionForward
> >perform(ActionMapping mapping,
> >ActionForm form,
> >HttpServletRequest request,
> >    HttpServletResponse response)
> > {
> >  javax.sql.DataSource dataSource;
> >  java.sql.Connection myConnection;
> >
> >  try {
> >dataSource = servlet.findDataSource(null);
> >myConnection = dataSource.getConnection();
> >
> > Now I am pretty confused since I want to implement the Database Access
in
> a
> > buiseness logic bean.
> >
> >
> > Thanks for your help!
> >
> > Rainer
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread Jerry Jalenak

I'm needing to move my data access from my Actions to a 'pure' business
bean.  Does anyone have a good example (or link) on how to create and use
DAO?

Thanks.

Jerry

-Original Message-
From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 3:43 AM
To: Struts Users Mailing List
Subject: RE: Database access design question


1. Do not use the session bean to access the datasource... create a data
access object which locates the datasource.
2. Lookup the datasource using a jndi name not a servlet. Register your
datasource with the jndi server. (Does the servlet api implement such a
method ??)
3. If using a connection pool (which you should really), get the connection
object out of the pool and use it to access the database.

HTH
Vikram


-Original Message-
From: rainer juenger [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 2:04 PM
To: Struts Users Mailing List
Subject: Re: Database access design question


I want to accesss the database from a business logic bean that should not
emplement *.servelet.* classes.
But how can I then initialize the DataSource?
like: dataSource = servlet.findDataSource(null);

??

Thanks Rainer


> What exactly is your question?
> The samples given with Struts do not necessarily following the best
practices, they are more like proof of concepts than anything else.
>
> Rgs
> Vikram
>
> -Original Message- 
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 1:45 PM
> To: Struts Users Mailing List
> Subject: Database access design question
>
>
> Hi,
>
> I am using the Struts Database pooling.
> My database connection is realised after the sample in the Struts User's
> Guide.
> http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> But I think the sample is very contradicting.
> In chapter 2.5 Business Logic Beans is said:
> "For maximum code re-use, business logic beans should be designed and
> implemented so that they do not know they are being executed in a web
> application environment. If you find yourself having to import a
> javax.servlet.* class in your bean, you are tying this business logic to
the
> web application environment. "
>
> but chapter 2.6 is Accessing the Database in the sample via a
ActionServlet:
> public ActionForward
>perform(ActionMapping mapping,
>ActionForm form,
>HttpServletRequest request,
>HttpServletResponse response)
> {
>  javax.sql.DataSource dataSource;
>  java.sql.Connection myConnection;
>
>  try {
>dataSource = servlet.findDataSource(null);
>myConnection = dataSource.getConnection();
>
> Now I am pretty confused since I want to implement the Database Access in
a
> buiseness logic bean.
>
>
> Thanks for your help!
>
> Rainer
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


This transmission (and any information attached to it) may be confidential and is 
intended solely for the use of the individual or entity to which it is addressed. If 
you are not the intended recipient or the person responsible for delivering the 
transmission to the intended recipient, be advised that you have received this 
transmission in error and that any use, dissemination, forwarding, printing, or 
copying of this information is strictly prohibited. If you have received this 
transmission in error, please immediately notify LabOne at (800)388-4675.



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread wbchmura


I did something and I have been wondering if it is right...  So this may 
be a good time.

I have three levels in my model...  They look like

Action (Struts action)
DAO object 
Database object 
Oracle DB


the action will call the DAO object along the lines of getCompanyList() 
or somethig
The DAO then eastablishes a connection to a database and passes it to 
the Database object
The Database object then does all of the SQL work to get the data back.

Is this good or bad?

As is, neither the DAO or the Database knows they are in a web 
application.  The actual Database layer works in JDBC but does not have 
any idea of the kind of JDBC database it is working in, only that it has 
a connection passed to it. 

This could be wrong, if so ... Someone tell me!

Thanks



-Original Message-
From: jakarta.rainer [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 4:34 AM
To: struts-user
Subject: Re: Database access design question


I want to accesss the database from a business logic bean that should 
not
emplement *.servelet.* classes.
But how can I then initialize the DataSource?
like: dataSource = servlet.findDataSource(null);

??

Thanks Rainer


> What exactly is your question?
> The samples given with Struts do not necessarily following the best
practices, they are more like proof of concepts than anything else.
>
> Rgs
> Vikram
>
> -Original Message-
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 1:45 PM
> To: Struts Users Mailing List
> Subject: Database access design question
>
>
> Hi,
>
> I am using the Struts Database pooling.
> My database connection is realised after the sample in the Struts 
User's
> Guide.
> 
http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> But I think the sample is very contradicting.
> In chapter 2.5 Business Logic Beans is said:
> "For maximum code re-use, business logic beans should be designed and
> implemented so that they do not know they are being executed in a web
> application environment. If you find yourself having to import a
> javax.servlet.* class in your bean, you are tying this business logic 
to
the
> web application environment. "
>
> but chapter 2.6 is Accessing the Database in the sample via a
ActionServlet:
> public ActionForward
>perform(ActionMapping mapping,
>ActionForm form,
>HttpServletRequest request,
>HttpServletResponse response)
> {
>  javax.sql.DataSource dataSource;
>  java.sql.Connection myConnection;
>
>  try {
>dataSource = servlet.findDataSource(null);
>myConnection = dataSource.getConnection();
>
> Now I am pretty confused since I want to implement the Database Access 
in
a
> buiseness logic bean.
>
>
> Thanks for your help!
>
> Rainer
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread Robert Taylor

It sounds like your DAO is really a business object and your db object
follows the DAO design pattern. I think you have the right concept though.
You may want to check out http://groups.yahoo.com/group/model_struts/. It
is dedicated to discussing the model layer using Struts.

robert

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:39 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Database access design question
>
>
>
> I did something and I have been wondering if it is right...  So this may
> be a good time.
>
> I have three levels in my model...  They look like
>
> Action (Struts action)
> DAO object
> Database object
> Oracle DB
>
>
> the action will call the DAO object along the lines of getCompanyList()
> or somethig
> The DAO then eastablishes a connection to a database and passes it to
> the Database object
> The Database object then does all of the SQL work to get the data back.
>
> Is this good or bad?
>
> As is, neither the DAO or the Database knows they are in a web
> application.  The actual Database layer works in JDBC but does not have
> any idea of the kind of JDBC database it is working in, only that it has
> a connection passed to it.
>
> This could be wrong, if so ... Someone tell me!
>
> Thanks
>
>
>
> -Original Message-
> From: jakarta.rainer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 4:34 AM
> To: struts-user
> Subject: Re: Database access design question
>
>
> I want to accesss the database from a business logic bean that should
> not
> emplement *.servelet.* classes.
> But how can I then initialize the DataSource?
> like: dataSource = servlet.findDataSource(null);
>
> ??
>
> Thanks Rainer
>
>
> > What exactly is your question?
> > The samples given with Struts do not necessarily following the best
> practices, they are more like proof of concepts than anything else.
> >
> > Rgs
> > Vikram
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 1:45 PM
> > To: Struts Users Mailing List
> > Subject: Database access design question
> >
> >
> > Hi,
> >
> > I am using the Struts Database pooling.
> > My database connection is realised after the sample in the Struts
> User's
> > Guide.
> >
> http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > But I think the sample is very contradicting.
> > In chapter 2.5 Business Logic Beans is said:
> > "For maximum code re-use, business logic beans should be designed and
> > implemented so that they do not know they are being executed in a web
> > application environment. If you find yourself having to import a
> > javax.servlet.* class in your bean, you are tying this business logic
> to
> the
> > web application environment. "
> >
> > but chapter 2.6 is Accessing the Database in the sample via a
> ActionServlet:
> > public ActionForward
> >perform(ActionMapping mapping,
> >    ActionForm form,
> >HttpServletRequest request,
> >HttpServletResponse response)
> > {
> >  javax.sql.DataSource dataSource;
> >  java.sql.Connection myConnection;
> >
> >  try {
> >dataSource = servlet.findDataSource(null);
> >myConnection = dataSource.getConnection();
> >
> > Now I am pretty confused since I want to implement the Database Access
> in
> a
> > buiseness logic bean.
> >
> >
> > Thanks for your help!
> >
> > Rainer
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread wbchmura


Thanks for the feedback on that one.  No matter how I sliced that one I 
always had some kind of problem with how I was seperating everything 
up...

I think the part that really confused me was that for this app, so far, 
there really is no business logic.  Its all lookups on the database... 

I took a quick look at the yahoo site - and will pursue that further, 
but can you recommend any write-ups anywhere on this?  

Thanks again...




-Original Message-
From: rtaylor [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 9:54 AM
To: struts-user
Subject: RE: Database access design question


It sounds like your DAO is really a business object and your db object
follows the DAO design pattern. I think you have the right concept 
though.
You may want to check out http://groups.yahoo.com/group/model_struts/. 
It
is dedicated to discussing the model layer using Struts.

robert

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:39 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Database access design question
>
>
>
> I did something and I have been wondering if it is right...  So this 
may
> be a good time.
>
> I have three levels in my model...  They look like
>
> Action (Struts action)
> DAO object
> Database object
> Oracle DB
>
>
> the action will call the DAO object along the lines of 
getCompanyList()
> or somethig
> The DAO then eastablishes a connection to a database and passes it to
> the Database object
> The Database object then does all of the SQL work to get the data 
back.
>
> Is this good or bad?
>
> As is, neither the DAO or the Database knows they are in a web
> application.  The actual Database layer works in JDBC but does not 
have
> any idea of the kind of JDBC database it is working in, only that it 
has
> a connection passed to it.
>
> This could be wrong, if so ... Someone tell me!
>
> Thanks
>
>
>
> -Original Message-
> From: jakarta.rainer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 4:34 AM
> To: struts-user
> Subject: Re: Database access design question
>
>
> I want to accesss the database from a business logic bean that should
> not
> emplement *.servelet.* classes.
> But how can I then initialize the DataSource?
> like: dataSource = servlet.findDataSource(null);
>
> ??
>
> Thanks Rainer
>
>
> > What exactly is your question?
> > The samples given with Struts do not necessarily following the best
> practices, they are more like proof of concepts than anything else.
> >
> > Rgs
> > Vikram
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 1:45 PM
> > To: Struts Users Mailing List
> > Subject: Database access design question
> >
> >
> > Hi,
> >
> > I am using the Struts Database pooling.
> > My database connection is realised after the sample in the Struts
> User's
> > Guide.
> >
> 
http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > But I think the sample is very contradicting.
> > In chapter 2.5 Business Logic Beans is said:
> > "For maximum code re-use, business logic beans should be designed 
and
> > implemented so that they do not know they are being executed in a 
web
> > application environment. If you find yourself having to import a
> > javax.servlet.* class in your bean, you are tying this business 
logic
> to
> the
> > web application environment. "
> >
> > but chapter 2.6 is Accessing the Database in the sample via a
> ActionServlet:
> > public ActionForward
> >perform(ActionMapping mapping,
> >    ActionForm form,
> >HttpServletRequest request,
> >HttpServletResponse response)
> > {
> >  javax.sql.DataSource dataSource;
> >  java.sql.Connection myConnection;
> >
> >  try {
> >dataSource = servlet.findDataSource(null);
> >myConnection = dataSource.getConnection();
> >
> > Now I am pretty confused since I want to implement the Database 
Access
> in
> a
> > buiseness logic bean.
> >
> >
> > Thanks for your help!
> >
> > Rainer
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread Robert Taylor

This is a subjective area. The Data Access Object is a design pattern which
really is
just a recommendation on how to implement access to the data store. There
are
several approaches, from home grown to commercial O/R products. Take a look
at Martin Fowlers site http://martinfowler.com/isa/index.html, Chuck
Caveness
book (chapter 6) http://www.theserverside.com/resources/strutsreview.jsp,
and then the archives are a great resource
http://www.mail-archive.com/struts-user%40jakarta.apache.org/.

HTH,

robert

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 10:14 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Database access design question
>
>
>
> Thanks for the feedback on that one.  No matter how I sliced that one I
> always had some kind of problem with how I was seperating everything
> up...
>
> I think the part that really confused me was that for this app, so far,
> there really is no business logic.  Its all lookups on the database...
>
> I took a quick look at the yahoo site - and will pursue that further,
> but can you recommend any write-ups anywhere on this?
>
> Thanks again...
>
>
>
>
> -Original Message-
> From: rtaylor [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 9:54 AM
> To: struts-user
> Subject: RE: Database access design question
>
>
> It sounds like your DAO is really a business object and your db object
> follows the DAO design pattern. I think you have the right concept
> though.
> You may want to check out http://groups.yahoo.com/group/model_struts/.
> It
> is dedicated to discussing the model layer using Struts.
>
> robert
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 9:39 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Database access design question
> >
> >
> >
> > I did something and I have been wondering if it is right...  So this
> may
> > be a good time.
> >
> > I have three levels in my model...  They look like
> >
> > Action (Struts action)
> > DAO object
> > Database object
> > Oracle DB
> >
> >
> > the action will call the DAO object along the lines of
> getCompanyList()
> > or somethig
> > The DAO then eastablishes a connection to a database and passes it to
> > the Database object
> > The Database object then does all of the SQL work to get the data
> back.
> >
> > Is this good or bad?
> >
> > As is, neither the DAO or the Database knows they are in a web
> > application.  The actual Database layer works in JDBC but does not
> have
> > any idea of the kind of JDBC database it is working in, only that it
> has
> > a connection passed to it.
> >
> > This could be wrong, if so ... Someone tell me!
> >
> > Thanks
> >
> >
> >
> > -Original Message-
> > From: jakarta.rainer [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 4:34 AM
> > To: struts-user
> > Subject: Re: Database access design question
> >
> >
> > I want to accesss the database from a business logic bean that should
> > not
> > emplement *.servelet.* classes.
> > But how can I then initialize the DataSource?
> > like: dataSource = servlet.findDataSource(null);
> >
> > ??
> >
> > Thanks Rainer
> >
> >
> > > What exactly is your question?
> > > The samples given with Struts do not necessarily following the best
> > practices, they are more like proof of concepts than anything else.
> > >
> > > Rgs
> > > Vikram
> > >
> > > -Original Message-
> > > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, June 10, 2002 1:45 PM
> > > To: Struts Users Mailing List
> > > Subject: Database access design question
> > >
> > >
> > > Hi,
> > >
> > > I am using the Struts Database pooling.
> > > My database connection is realised after the sample in the Struts
> > User's
> > > Guide.
> > >
> >
> http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > > But I think the sample is very contradicting.
> > > In chapter 2.5 Business Logic Beans is said:
> > > "For maximum code re-use, business logic beans should be designed
> and
> > > implemented so that they do not know they are being executed in a
> web
> > > application environment. If you find yourself having to import a
> > > javax.servle

Re: Database access design question

2002-06-10 Thread rainer juenger

Sorry but I am in another galaxy as you guys are. My problems are not that
complex yet and my knowledge isn't either.
I would only like to have a simple sample how I can access the Database
defined in the struts-config.xml without having to use any servlet depending
methodes/classes  like pageContext, sessions or what so ever. There must be
a way!

thanks 1000 times for a hint!

Rainer

- Original Message -
From: "Jerry Jalenak" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Monday, June 10, 2002 3:17 PM
Subject: RE: Database access design question


> I'm needing to move my data access from my Actions to a 'pure' business
> bean.  Does anyone have a good example (or link) on how to create and use
> DAO?
>
> Thanks.
>
> Jerry
>
> -Original Message-
> From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 3:43 AM
> To: Struts Users Mailing List
> Subject: RE: Database access design question
>
>
> 1. Do not use the session bean to access the datasource... create a data
> access object which locates the datasource.
> 2. Lookup the datasource using a jndi name not a servlet. Register your
> datasource with the jndi server. (Does the servlet api implement such a
> method ??)
> 3. If using a connection pool (which you should really), get the
connection
> object out of the pool and use it to access the database.
>
> HTH
> Vikram
>
>
> -Original Message-----
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 2:04 PM
> To: Struts Users Mailing List
> Subject: Re: Database access design question
>
>
> I want to accesss the database from a business logic bean that should not
> emplement *.servelet.* classes.
> But how can I then initialize the DataSource?
> like: dataSource = servlet.findDataSource(null);
>
> ??
>
> Thanks Rainer
>
>
> > What exactly is your question?
> > The samples given with Struts do not necessarily following the best
> practices, they are more like proof of concepts than anything else.
> >
> > Rgs
> > Vikram
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 1:45 PM
> > To: Struts Users Mailing List
> > Subject: Database access design question
> >
> >
> > Hi,
> >
> > I am using the Struts Database pooling.
> > My database connection is realised after the sample in the Struts User's
> > Guide.
> > http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > But I think the sample is very contradicting.
> > In chapter 2.5 Business Logic Beans is said:
> > "For maximum code re-use, business logic beans should be designed and
> > implemented so that they do not know they are being executed in a web
> > application environment. If you find yourself having to import a
> > javax.servlet.* class in your bean, you are tying this business logic to
> the
> > web application environment. "
> >
> > but chapter 2.6 is Accessing the Database in the sample via a
> ActionServlet:
> > public ActionForward
> >perform(ActionMapping mapping,
> >    ActionForm form,
> >HttpServletRequest request,
> >HttpServletResponse response)
> > {
> >  javax.sql.DataSource dataSource;
> >  java.sql.Connection myConnection;
> >
> >  try {
> >dataSource = servlet.findDataSource(null);
> >myConnection = dataSource.getConnection();
> >
> > Now I am pretty confused since I want to implement the Database Access
in
> a
> > buiseness logic bean.
> >
> >
> > Thanks for your help!
> >
> > Rainer
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> This transmission (and any information attached to it) may be confidential
and is intended solely for the use of the individual or entity to which it
is addressed. If you are not the intended recipient or the person
responsible for delivering the transmission to the intended recipient, be
advised that you have received this transmission in error and that any use,
dissemination, forwarding, printing, or copying of this information is
strictly prohibited. If you have received this transmission in error, please
immediately notify LabOne at (800)388-4675.
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Database access design question

2002-06-10 Thread Ted Husted

You can't access the generic datasource pool defined by the Struts
config from the business tier. The closest you can come is to pass up
the connection. The Struts generic datasource is really * not * the best
way to go for most applications. I do not recommend using it for
production applications. 

Many DBMS packages and containers provide their own connection pools,
including Tomcat 4 I believe. 

My best general recommendation is to grab Poolman 1.4 from 

http://sourceforge.net/project/showfiles.php?group_id=4899

and see:

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg25554.html


-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


rainer juenger wrote:
> 
> Sorry but I am in another galaxy as you guys are. My problems are not that
> complex yet and my knowledge isn't either.
> I would only like to have a simple sample how I can access the Database
> defined in the struts-config.xml without having to use any servlet depending
> methodes/classes  like pageContext, sessions or what so ever. There must be
> a way!
> 
> thanks 1000 times for a hint!
> 
> Rainer
> 
> - Original Message -
> From: "Jerry Jalenak" <[EMAIL PROTECTED]>
> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> Sent: Monday, June 10, 2002 3:17 PM
> Subject: RE: Database access design question
> 
> > I'm needing to move my data access from my Actions to a 'pure' business
> > bean.  Does anyone have a good example (or link) on how to create and use
> > DAO?
> >
> > Thanks.
> >
> > Jerry
> >
> > -----Original Message-
> > From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 3:43 AM
> > To: Struts Users Mailing List
> > Subject: RE: Database access design question
> >
> >
> > 1. Do not use the session bean to access the datasource... create a data
> > access object which locates the datasource.
> > 2. Lookup the datasource using a jndi name not a servlet. Register your
> > datasource with the jndi server. (Does the servlet api implement such a
> > method ??)
> > 3. If using a connection pool (which you should really), get the
> connection
> > object out of the pool and use it to access the database.
> >
> > HTH
> > Vikram
> >
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 2:04 PM
> > To: Struts Users Mailing List
> > Subject: Re: Database access design question
> >
> >
> > I want to accesss the database from a business logic bean that should not
> > emplement *.servelet.* classes.
> > But how can I then initialize the DataSource?
> > like: dataSource = servlet.findDataSource(null);
> >
> > ??
> >
> > Thanks Rainer
> >
> >
> > > What exactly is your question?
> > > The samples given with Struts do not necessarily following the best
> > practices, they are more like proof of concepts than anything else.
> > >
> > > Rgs
> > > Vikram
> > >
> > > -Original Message-
> > > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, June 10, 2002 1:45 PM
> > > To: Struts Users Mailing List
> > > Subject: Database access design question
> > >
> > >
> > > Hi,
> > >
> > > I am using the Struts Database pooling.
> > > My database connection is realised after the sample in the Struts User's
> > > Guide.
> > > http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > > But I think the sample is very contradicting.
> > > In chapter 2.5 Business Logic Beans is said:
> > > "For maximum code re-use, business logic beans should be designed and
> > > implemented so that they do not know they are being executed in a web
> > > application environment. If you find yourself having to import a
> > > javax.servlet.* class in your bean, you are tying this business logic to
> > the
> > > web application environment. "
> > >
> > > but chapter 2.6 is Accessing the Database in the sample via a
> > ActionServlet:
> > > public ActionForward
> > >perform(ActionMapping mapping,
> > >ActionForm form,
> > >HttpServletRequest request,
> > >HttpServletResponse response)
> > > {
> > >  javax.sql.DataSource dataSource;
> > >  java.sql.Connection myConnection;
> > >
> > >  try {
> > >dataSource = servlet.findDataSource(null);
> > >myConnection = dataSource.getConnection();
> > >
> > > Now I am pretty confused since I want to implement the Database Access
> in
> > a
> > > buiseness logic bean.
> > >
> > >
> > > Thanks for your help!
> > >
> > > Rainer
> > >
> > >
> > > --

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Database access design question

2002-06-10 Thread wbchmura


I have that now I think...  I get the connection and pass that to the 
program that does not have any ties to the servlets...

the olsource object does not have any knowledge of the fact its a web 
app.  I could drop the same code into a java gui and as long as I passed 
the connection it should run

(Of course I dont know what I am doing either)

Bill


public HashMap getGroupList (org.apache.struts.action.ActionServlet 
servlet, int companyId) {
java.util.HashMap list = new java.util.HashMap();
javax.sql.DataSource dataSource = null;

try {
dataSource = 
(DataSource)servlet.getServletContext().getAttribute("Oracle");
list = olsource.getGroupList(dataSource, companyId); 
  

} catch (Exception e) {
System.out.println ("Connection.process" + e);
e.printStackTrace();
}
return (list);
}




-Original Message-
From: jakarta.rainer [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 11:47 AM
To: struts-user
Subject: Re: Database access design question


Sorry but I am in another galaxy as you guys are. My problems are not 
that
complex yet and my knowledge isn't either.
I would only like to have a simple sample how I can access the Database
defined in the struts-config.xml without having to use any servlet 
depending
methodes/classes  like pageContext, sessions or what so ever. There must 
be
a way!

thanks 1000 times for a hint!

Rainer

- Original Message -
From: "Jerry Jalenak" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Monday, June 10, 2002 3:17 PM
Subject: RE: Database access design question


> I'm needing to move my data access from my Actions to a 'pure' 
business
> bean.  Does anyone have a good example (or link) on how to create and 
use
> DAO?
>
> Thanks.
>
> Jerry
>
> -Original Message-
> From: Vikram Goyal01 [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 3:43 AM
> To: Struts Users Mailing List
> Subject: RE: Database access design question
>
>
> 1. Do not use the session bean to access the datasource... create a 
data
> access object which locates the datasource.
> 2. Lookup the datasource using a jndi name not a servlet. Register 
your
> datasource with the jndi server. (Does the servlet api implement such 
a
> method ??)
> 3. If using a connection pool (which you should really), get the
connection
> object out of the pool and use it to access the database.
>
> HTH
> Vikram
>
>
> -Original Message-
> From: rainer juenger [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 2:04 PM
> To: Struts Users Mailing List
> Subject: Re: Database access design question
>
>
> I want to accesss the database from a business logic bean that should 
not
> emplement *.servelet.* classes.
> But how can I then initialize the DataSource?
> like: dataSource = servlet.findDataSource(null);
>
> ??
>
> Thanks Rainer
>
>
> > What exactly is your question?
> > The samples given with Struts do not necessarily following the best
> practices, they are more like proof of concepts than anything else.
> >
> > Rgs
> > Vikram
> >
> > -Original Message-
> > From: rainer juenger [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 10, 2002 1:45 PM
> > To: Struts Users Mailing List
> > Subject: Database access design question
> >
> >
> > Hi,
> >
> > I am using the Struts Database pooling.
> > My database connection is realised after the sample in the Struts 
User's
> > Guide.
> > 
http://jakarta.apache.org/struts/userGuide/building_model.html#databases
> > But I think the sample is very contradicting.
> > In chapter 2.5 Business Logic Beans is said:
> > "For maximum code re-use, business logic beans should be designed 
and
> > implemented so that they do not know they are being executed in a 
web
> > application environment. If you find yourself having to import a
> > javax.servlet.* class in your bean, you are tying this business 
logic to
> the
> > web application environment. "
> >
> > but chapter 2.6 is Accessing the Database in the sample via a
> ActionServlet:
> > public ActionForward
> >perform(ActionMapping mapping,
> >ActionForm form,
> >HttpServletRequest request,
> >HttpServletResponse response)
> > {
> >  javax.sql.DataSource dataSource;
> >  java.sql.Connection myConnection;
> >
> >  try {
> >dataSource = servlet.findDataSource(null);
> >myConnection = dataSource.getConnection();
&

Re: Database access using JSTL sql

2003-02-25 Thread David Graham
Yes, it is frowned upon to perform business logic in your view.  You place 
objects in the request, session, or application scope for your jsp to 
display.

David



From: "Paul Pattison" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Mailing List (E-mail)" <[EMAIL PROTECTED]>
Subject: Database access using JSTL sql
Date: Tue, 25 Feb 2003 21:54:18 -0500
Hi all,

I'm trying return an xml page based on a simple sql query.  I thought that 
this would be easily done using the JSTL sql tags. How do I access the 
Struts datasource from the jsp?  What should the value of my 'dataSource' 
element in the 'sql:query' tag be?  I haven't been able to get it work and 
I couldn't find any clues in the archive.

Secondly, is this method looked down upon because I'm accessing the 
database from my jsp?  I have written Actions that access the database, but 
how can I pass the result object to the jsp so that I can easily output it 
using the 'c.out' tags from JSTL?

Thanks,

Paul

Here is my datasource as defined in struts-config.xml:


  
  
  
  
  
  
  
  

Here is my test.jsp:

<%@ page contentType="text/xml" %>
<%@ page import="java.util.*" %>
<%@ taglib uri="/tags/jstl-c" prefix="c" %>
<%@ taglib uri="/tags/jstl-sql" prefix="sql" %>

  SELECT task_id,task_def_id,approve_date
FROM tasks



  

  
  

  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Best Approach for Database Access?

2002-02-12 Thread Keith Chew

Hi Paul

I follow this design practice for both EJB and non-EJB applications. The
ones marked with * live at the application server JVM.

(1) Non-EJB environment
===
JSP -> ActionBean -> ServiceBean -> DaoBean -> DB

(2) EJB environment (BMP or Session)

JSP -> ActionBean -> * ServiceBean -> * DaoBean -> DB

(3) EJB environment (CMP)
=
JSP -> ActionBean -> * ServiceBean -> DB

Notes:
==
ActionBeans are the action classes of Struts
DaoBeans are normal JavaBean classes which knows how to communicate with the
DB, ie all SQL code goes here.
In (1), you need to take care of transactions on your own.
The ServiceBean in (1) is a normal JavaBean, but an EJB in (2) and (3)
In (3), we do not need a Dao, since the CMP does all that work for us.

Hope this helps
Keith

-Original Message-
From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 13 February 2002 9:38 a.m.
To: [EMAIL PROTECTED]
Subject: Best Approach for Database Access?
Importance: High


Could you kindly provide guidance on the best approach to implement database
access.?
I have encountered various schools of thought in my reading, that suggest
extracting the business logic and database code from the jsp into a jsp bean
or ejb or servlet.

Thanks,

Paul Idusogie
Technical Architect
Consulting Services
Stellent Inc.
 Golden Triangle Drive
Eden Prairie, MN 55104
Desk: 952.656.2755
Fax: 952.903.2115
Email: [EMAIL PROTECTED]
website: http://www.stellent.com

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Best Approach for Database Access?

2002-02-12 Thread Thompson, Darryl

Hello Keith,

 In my environment we employ options 2 and 3 but with this little twist:

  3) EJB environment (CMP)
 JSP -> ActionBean -> ( ServiceHelper -->ServiceLocator ) - >
ServiceBean -> DB

The ServiceLocator is a regular Java class that encapsulates all jndi Home
lookup logic, and the ther ServiceHelper is also a regular Java class that
contains methods to
support the business model. All ServiceHelper methods are static and the
Action Class calls these from the appropriate exec(..) method.

We are still trying to get a handle on this framework so if this is in left
field let me know.

Regards,
Darryl

> -Original Message-
> From: Keith Chew [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, February 12, 2002 2:47 PM
> To:   Struts Users Mailing List
> Subject:  RE: Best Approach for Database Access?
> 
> Hi Paul
> 
> I follow this design practice for both EJB and non-EJB applications. The
> ones marked with * live at the application server JVM.
> 
> (1) Non-EJB environment
> ===
> JSP -> ActionBean -> ServiceBean -> DaoBean -> DB
> 
> (2) EJB environment (BMP or Session)
> 
> JSP -> ActionBean -> * ServiceBean -> * DaoBean -> DB
> 
> (3) EJB environment (CMP)
> =
> JSP -> ActionBean -> * ServiceBean -> DB
> 
> Notes:
> ==
> ActionBeans are the action classes of Struts
> DaoBeans are normal JavaBean classes which knows how to communicate with
> the
> DB, ie all SQL code goes here.
> In (1), you need to take care of transactions on your own.
> The ServiceBean in (1) is a normal JavaBean, but an EJB in (2) and (3)
> In (3), we do not need a Dao, since the CMP does all that work for us.
> 
> Hope this helps
> Keith
> 
> -Original Message-----
> From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 13 February 2002 9:38 a.m.
> To: [EMAIL PROTECTED]
> Subject: Best Approach for Database Access?
> Importance: High
> 
> 
> Could you kindly provide guidance on the best approach to implement
> database
> access.?
> I have encountered various schools of thought in my reading, that suggest
> extracting the business logic and database code from the jsp into a jsp
> bean
> or ejb or servlet.
> 
> Thanks,
> 
> Paul Idusogie
> Technical Architect
> Consulting Services
> Stellent Inc.
>  Golden Triangle Drive
> Eden Prairie, MN 55104
> Desk: 952.656.2755
> Fax: 952.903.2115
> Email: [EMAIL PROTECTED]
> website: http://www.stellent.com
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Best Approach for Database Access?

2002-02-12 Thread Keith Chew

Hi Darryl

Yes, I use a ResourceLocator, which does that same thing. In addition, it
does caching of home interfaces and  storing of application context
constants, thus not called a ServiceLocator (locating a service is only one
of it's jobs).

I have made the ServiceLocator a Singleton, thus avoided having a
ServiceHelper. So, to get an EJB, I just go:

DummyService dummyService = (DummyService)
ResourceLocator.getInstance().getEjb (DummyServiceBeanHome.class);

One line, simple and tidy. Also, the JNDI name is in the home interface,
thus the ResourceLocator uses reflection to get that. Optionally, you can
choose to supply a JNDI name.

Hope this helps.

Keith

-Original Message-
From: Thompson, Darryl [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 13 February 2002 10:18 a.m.
To: Struts Users Mailing List
Subject: RE: Best Approach for Database Access?


Hello Keith,

 In my environment we employ options 2 and 3 but with this little twist:

  3) EJB environment (CMP)
 JSP -> ActionBean -> ( ServiceHelper -->ServiceLocator ) - >
ServiceBean -> DB

The ServiceLocator is a regular Java class that encapsulates all jndi Home
lookup logic, and the ther ServiceHelper is also a regular Java class that
contains methods to
support the business model. All ServiceHelper methods are static and the
Action Class calls these from the appropriate exec(..) method.

We are still trying to get a handle on this framework so if this is in left
field let me know.

Regards,
Darryl

> -Original Message-
> From: Keith Chew [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, February 12, 2002 2:47 PM
> To:   Struts Users Mailing List
> Subject:  RE: Best Approach for Database Access?
>
> Hi Paul
>
> I follow this design practice for both EJB and non-EJB applications. The
> ones marked with * live at the application server JVM.
>
> (1) Non-EJB environment
> ===
> JSP -> ActionBean -> ServiceBean -> DaoBean -> DB
>
> (2) EJB environment (BMP or Session)
> 
> JSP -> ActionBean -> * ServiceBean -> * DaoBean -> DB
>
> (3) EJB environment (CMP)
> =
> JSP -> ActionBean -> * ServiceBean -> DB
>
> Notes:
> ==
> ActionBeans are the action classes of Struts
> DaoBeans are normal JavaBean classes which knows how to communicate with
> the
> DB, ie all SQL code goes here.
> In (1), you need to take care of transactions on your own.
> The ServiceBean in (1) is a normal JavaBean, but an EJB in (2) and (3)
> In (3), we do not need a Dao, since the CMP does all that work for us.
>
> Hope this helps
> Keith
>
> -Original Message-
> From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 13 February 2002 9:38 a.m.
> To: [EMAIL PROTECTED]
> Subject: Best Approach for Database Access?
> Importance: High
>
>
> Could you kindly provide guidance on the best approach to implement
> database
> access.?
> I have encountered various schools of thought in my reading, that suggest
> extracting the business logic and database code from the jsp into a jsp
> bean
> or ejb or servlet.
>
> Thanks,
>
> Paul Idusogie
> Technical Architect
> Consulting Services
> Stellent Inc.
>  Golden Triangle Drive
> Eden Prairie, MN 55104
> Desk: 952.656.2755
> Fax: 952.903.2115
> Email: [EMAIL PROTECTED]
> website: http://www.stellent.com
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Best Approach for Database Access?

2002-02-12 Thread Francisco Hernandez

could you guys post some sample psuedo code on how you guys implement this?

im very intrested in using EJBs in my web apps.. im just not too sure on
what the best way to do this is.

- Original Message -
From: "Thompson, Darryl" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 1:17 PM
Subject: RE: Best Approach for Database Access?


> Hello Keith,
>
>  In my environment we employ options 2 and 3 but with this little twist:
>
>   3) EJB environment (CMP)
>  JSP -> ActionBean -> ( ServiceHelper -->ServiceLocator ) - >
> ServiceBean -> DB
>
> The ServiceLocator is a regular Java class that encapsulates all jndi Home
> lookup logic, and the ther ServiceHelper is also a regular Java class that
> contains methods to
> support the business model. All ServiceHelper methods are static and the
> Action Class calls these from the appropriate exec(..) method.
>
> We are still trying to get a handle on this framework so if this is in
left
> field let me know.
>
> Regards,
> Darryl
>
> > -Original Message-
> > From: Keith Chew [SMTP:[EMAIL PROTECTED]]
> > Sent: Tuesday, February 12, 2002 2:47 PM
> > To: Struts Users Mailing List
> > Subject: RE: Best Approach for Database Access?
> >
> > Hi Paul
> >
> > I follow this design practice for both EJB and non-EJB applications. The
> > ones marked with * live at the application server JVM.
> >
> > (1) Non-EJB environment
> > ===
> > JSP -> ActionBean -> ServiceBean -> DaoBean -> DB
> >
> > (2) EJB environment (BMP or Session)
> > 
> > JSP -> ActionBean -> * ServiceBean -> * DaoBean -> DB
> >
> > (3) EJB environment (CMP)
> > =
> > JSP -> ActionBean -> * ServiceBean -> DB
> >
> > Notes:
> > ==
> > ActionBeans are the action classes of Struts
> > DaoBeans are normal JavaBean classes which knows how to communicate with
> > the
> > DB, ie all SQL code goes here.
> > In (1), you need to take care of transactions on your own.
> > The ServiceBean in (1) is a normal JavaBean, but an EJB in (2) and (3)
> > In (3), we do not need a Dao, since the CMP does all that work for us.
> >
> > Hope this helps
> > Keith
> >
> > -Original Message-
> > From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, 13 February 2002 9:38 a.m.
> > To: [EMAIL PROTECTED]
> > Subject: Best Approach for Database Access?
> > Importance: High
> >
> >
> > Could you kindly provide guidance on the best approach to implement
> > database
> > access.?
> > I have encountered various schools of thought in my reading, that
suggest
> > extracting the business logic and database code from the jsp into a jsp
> > bean
> > or ejb or servlet.
> >
> > Thanks,
> >
> > Paul Idusogie
> > Technical Architect
> > Consulting Services
> > Stellent Inc.
> >  Golden Triangle Drive
> > Eden Prairie, MN 55104
> > Desk: 952.656.2755
> > Fax: 952.903.2115
> > Email: [EMAIL PROTECTED]
> > website: http://www.stellent.com
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Best Approach for Database Access?

2002-02-12 Thread Francisco Hernandez

once you get your DummyService, are you passing it the current ActionForm?

how are you getting results/errors from that DummyService?

- Original Message -
From: "Keith Chew" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 1:43 PM
Subject: RE: Best Approach for Database Access?


> Hi Darryl
>
> Yes, I use a ResourceLocator, which does that same thing. In addition, it
> does caching of home interfaces and  storing of application context
> constants, thus not called a ServiceLocator (locating a service is only
one
> of it's jobs).
>
> I have made the ServiceLocator a Singleton, thus avoided having a
> ServiceHelper. So, to get an EJB, I just go:
>
> DummyService dummyService = (DummyService)
> ResourceLocator.getInstance().getEjb (DummyServiceBeanHome.class);
>
> One line, simple and tidy. Also, the JNDI name is in the home interface,
> thus the ResourceLocator uses reflection to get that. Optionally, you can
> choose to supply a JNDI name.
>
> Hope this helps.
>
> Keith
>
> -Original Message-
> From: Thompson, Darryl [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 13 February 2002 10:18 a.m.
> To: Struts Users Mailing List
> Subject: RE: Best Approach for Database Access?
>
>
> Hello Keith,
>
>  In my environment we employ options 2 and 3 but with this little twist:
>
>   3) EJB environment (CMP)
>  JSP -> ActionBean -> ( ServiceHelper -->ServiceLocator ) - >
> ServiceBean -> DB
>
> The ServiceLocator is a regular Java class that encapsulates all jndi Home
> lookup logic, and the ther ServiceHelper is also a regular Java class that
> contains methods to
> support the business model. All ServiceHelper methods are static and the
> Action Class calls these from the appropriate exec(..) method.
>
> We are still trying to get a handle on this framework so if this is in
left
> field let me know.
>
> Regards,
> Darryl
>
> > -Original Message-
> > From: Keith Chew [SMTP:[EMAIL PROTECTED]]
> > Sent: Tuesday, February 12, 2002 2:47 PM
> > To: Struts Users Mailing List
> > Subject: RE: Best Approach for Database Access?
> >
> > Hi Paul
> >
> > I follow this design practice for both EJB and non-EJB applications. The
> > ones marked with * live at the application server JVM.
> >
> > (1) Non-EJB environment
> > ===
> > JSP -> ActionBean -> ServiceBean -> DaoBean -> DB
> >
> > (2) EJB environment (BMP or Session)
> > 
> > JSP -> ActionBean -> * ServiceBean -> * DaoBean -> DB
> >
> > (3) EJB environment (CMP)
> > =
> > JSP -> ActionBean -> * ServiceBean -> DB
> >
> > Notes:
> > ==
> > ActionBeans are the action classes of Struts
> > DaoBeans are normal JavaBean classes which knows how to communicate with
> > the
> > DB, ie all SQL code goes here.
> > In (1), you need to take care of transactions on your own.
> > The ServiceBean in (1) is a normal JavaBean, but an EJB in (2) and (3)
> > In (3), we do not need a Dao, since the CMP does all that work for us.
> >
> > Hope this helps
> > Keith
> >
> > -Original Message-
> > From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, 13 February 2002 9:38 a.m.
> > To: [EMAIL PROTECTED]
> > Subject: Best Approach for Database Access?
> > Importance: High
> >
> >
> > Could you kindly provide guidance on the best approach to implement
> > database
> > access.?
> > I have encountered various schools of thought in my reading, that
suggest
> > extracting the business logic and database code from the jsp into a jsp
> > bean
> > or ejb or servlet.
> >
> > Thanks,
> >
> > Paul Idusogie
> > Technical Architect
> > Consulting Services
> > Stellent Inc.
> >  Golden Triangle Drive
> > Eden Prairie, MN 55104
> > Desk: 952.656.2755
> > Fax: 952.903.2115
> > Email: [EMAIL PROTECTED]
> > website: http://www.stellent.com
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Best Approach for Database Access?

2002-02-12 Thread Galbreath, Mark

Check out the "Guidelines" and "Patterns" at

http://java.sun.com/blueprints/,

"Accessing Relational Databases" at

http://jakarta.apache.org/struts/userGuide/index.html,

and get 'hold of "Core J2EE Patterns" by Alur, et al.

Mark

-Original Message-
From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 12, 2002 3:38 PM

Could you kindly provide guidance on the best approach to implement database
access.?
I have encountered various schools of thought in my reading, that suggest
extracting the business logic and database code from the jsp into a jsp bean
or ejb or servlet.

Thanks,

Paul Idusogie 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Best Approach for Database Access?

2002-02-12 Thread Rooms, Christoph

Check out castor, worked fine for me !!!

http://www.castor.org

-Original Message-
From: Galbreath, Mark
To: 'Struts Users Mailing List'
Sent: 12/02/2002 22:52
Subject: RE: Best Approach for Database Access?

Check out the "Guidelines" and "Patterns" at

http://java.sun.com/blueprints/,

"Accessing Relational Databases" at

http://jakarta.apache.org/struts/userGuide/index.html,

and get 'hold of "Core J2EE Patterns" by Alur, et al.

Mark

-Original Message-
From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 12, 2002 3:38 PM

Could you kindly provide guidance on the best approach to implement
database
access.?
I have encountered various schools of thought in my reading, that
suggest
extracting the business logic and database code from the jsp into a jsp
bean
or ejb or servlet.

Thanks,

Paul Idusogie 

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Best Approach for Database Access?

2002-02-12 Thread Keith Chew


More pointers...

In the example I gave earlier, the DaoBean is responsible for communicating
with the database. So, you can implement the data access with any of these
technologies:
- direct SQL
- O/R mapper like Castor, Toplink, Cocobase
- JDO
- ...

In the CMP environment, the container will take care of all these. However,
you need to configure the O/R settings at the container level.

PS: The Core J2EE Patterns is a very good reference book. Definitely
worthwhile getting a copy.

Keith


-Original Message-
From: Rooms, Christoph [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 13 February 2002 11:04 a.m.
To: 'Galbreath, Mark '; ''Struts Users Mailing List' '
Subject: RE: Best Approach for Database Access?


Check out castor, worked fine for me !!!

http://www.castor.org

-Original Message-
From: Galbreath, Mark
To: 'Struts Users Mailing List'
Sent: 12/02/2002 22:52
Subject: RE: Best Approach for Database Access?

Check out the "Guidelines" and "Patterns" at

http://java.sun.com/blueprints/,

"Accessing Relational Databases" at

http://jakarta.apache.org/struts/userGuide/index.html,

and get 'hold of "Core J2EE Patterns" by Alur, et al.

Mark

-Original Message-
From: Paul Idusogie [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 12, 2002 3:38 PM

Could you kindly provide guidance on the best approach to implement
database
access.?
I have encountered various schools of thought in my reading, that
suggest
extracting the business logic and database code from the jsp into a jsp
bean
or ejb or servlet.

Thanks,

Paul Idusogie

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re[2]: Database access design question

2002-06-10 Thread Rick Reumann

On Monday, June 10, 2002, 10:13:34 AM, wbchmura wrote:

wEBc> I took a quick look at the yahoo site - and will pursue that further, 
wEBc> but can you recommend any write-ups anywhere on this?

  I just went through the same struggles you are going through.
  Robert wrote up a great post that really helped clarify things
  for me. I'm trying the find the post now and I'll send it to
  you. (I have it saved at home and if I can't find it I'll send
  it to you later).

  Also be sure to check out Chuck's chapter 6 at this link:
  http://www.theserverside.com/resources/strutsreview.jsp

  Vic's webPIM application handles the architecture in a different
  way and you could find out more by downloading the sample app:
  http://www.basebeans.com/downloads.jsp

  I'll also send you what I came up with if you are interested
  (which for the most part follows the design principals Robert
  and Chuck helped me understand).

-- 

Rick
mailto:[EMAIL PROTECTED]

"Instead of studying for finals, what about just going to the Bahamas
and catching some rays? Maybe you'll flunk, but you might have flunked
anyway; that's my point." 
  -Jack Handey


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Subject: Re: Best Approach for Database Access?

2002-02-12 Thread @Basebeans.com

Subject: Subject: Re: Best Approach for Database Access?
5311:From: Vic Cekvenich <[EMAIL PROTECTED]>
 ===

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Re[2]: Database access design question

2002-06-10 Thread wbchmura


ANY information on this would be a great help.  

I am familar with the concept of patterns and have been trying to get 
used to them and how to use them...  

If you describe what you came up with that would be cool too!

If anyone has a good illustration of the model layers that work best I 
could use that also.  I've been thinking (up till recently) that the 
ActionClass is part of the controller, but now I am thinking of it 
almost as half controller, half view.  I am tryting to segment it out to 
mostly setting up the data to be sent to the view, and handling input so 
the controller acts correctly.

My head hurts sometimes, but the voices tell me it will be okay...







-Original Message-
From: maillist [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 10:29 AM
To: struts-user
Subject: Re[2]: Database access design question


On Monday, June 10, 2002, 10:13:34 AM, wbchmura wrote:

wEBc> I took a quick look at the yahoo site - and will pursue that 
further, 
wEBc> but can you recommend any write-ups anywhere on this?

  I just went through the same struggles you are going through.
  Robert wrote up a great post that really helped clarify things
  for me. I'm trying the find the post now and I'll send it to
  you. (I have it saved at home and if I can't find it I'll send
  it to you later).

  Also be sure to check out Chuck's chapter 6 at this link:
  http://www.theserverside.com/resources/strutsreview.jsp

  Vic's webPIM application handles the architecture in a different
  way and you could find out more by downloading the sample app:
  http://www.basebeans.com/downloads.jsp

  I'll also send you what I came up with if you are interested
  (which for the most part follows the design principals Robert
  and Chuck helped me understand).

-- 

Rick
mailto:[EMAIL PROTECTED]

"Instead of studying for finals, what about just going to the Bahamas
and catching some rays? Maybe you'll flunk, but you might have flunked
anyway; that's my point." 
  -Jack Handey


--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Re[2]: Database access design question

2002-06-10 Thread Craig R. McClanahan



On Mon, 10 Jun 2002 [EMAIL PROTECTED] wrote:

> Date: Mon, 10 Jun 2002 13:35:33 -0400
> From: [EMAIL PROTECTED]
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED], [EMAIL PROTECTED]
> Subject: RE: Re[2]: Database access design question
>
>
> ANY information on this would be a great help.
>
> I am familar with the concept of patterns and have been trying to get
> used to them and how to use them...
>
> If you describe what you came up with that would be cool too!
>
> If anyone has a good illustration of the model layers that work best I
> could use that also.  I've been thinking (up till recently) that the
> ActionClass is part of the controller, but now I am thinking of it
> almost as half controller, half view.  I am tryting to segment it out to
> mostly setting up the data to be sent to the view, and handling input so
> the controller acts correctly.
>
> My head hurts sometimes, but the voices tell me it will be okay...
>

Actions are definitely in the controller tier, although in small apps
people tend to embed business logic directly in them (which makes them
somewhat part of the model tier as well).

The only time Actions are part of the presentation tier is when you are
generating the output directly from the Action (such as rendering some XML
content or a dynamically generated graph) rather than forwarding to a
presentation tier resource for the final output.

ActionForms, by the way, *are* part of the presentation tier -- their only
purpose in life is to represent the server side state of client user
interface components.

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Re[2]: Database access design question

2002-06-10 Thread wbchmura


Okay, here is why I was thinking that...

If I have business logic that would produce the results as a hashmap, 
but I need an arraylist to populate a control in the JSP, is the action 
now preparing data for the presentation as opposed to preparing data?  
for example, in a perfect world I should be able to take my business 
logic and use it as a desktop app if I slap a GUI on the front of it?  
Basically I would need to replace the ACTION with something else that 
would populate the data into the controls.  Hmmm, or would that be the 
JSP...

I have no idea what I am talking about...



-Original Message-
From: craigmcc [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 3:05 PM
To: struts-user
Cc: maillist
Subject: RE: Re[2]: Database access design question




On Mon, 10 Jun 2002 [EMAIL PROTECTED] wrote:

> Date: Mon, 10 Jun 2002 13:35:33 -0400
> From: [EMAIL PROTECTED]
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED], [EMAIL PROTECTED]
> Subject: RE: Re[2]: Database access design question
>
>
> ANY information on this would be a great help.
>
> I am familar with the concept of patterns and have been trying to get
> used to them and how to use them...
>
> If you describe what you came up with that would be cool too!
>
> If anyone has a good illustration of the model layers that work best I
> could use that also.  I've been thinking (up till recently) that the
> ActionClass is part of the controller, but now I am thinking of it
> almost as half controller, half view.  I am tryting to segment it out 
to
> mostly setting up the data to be sent to the view, and handling input 
so
> the controller acts correctly.
>
> My head hurts sometimes, but the voices tell me it will be okay...
>

Actions are definitely in the controller tier, although in small apps
people tend to embed business logic directly in them (which makes them
somewhat part of the model tier as well).

The only time Actions are part of the presentation tier is when you are
generating the output directly from the Action (such as rendering some 
XML
content or a dynamically generated graph) rather than forwarding to a
presentation tier resource for the final output.

ActionForms, by the way, *are* part of the presentation tier -- their 
only
purpose in life is to represent the server side state of client user
interface components.

Craig


--
To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: 
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Hi folks, a newbie asking a question about database access from withinstruts applications

2002-02-06 Thread theron . kousek


Hi Folks:

I am a newbie to struts so please excuse my ignorance.Can I ask advice
or get comments from the struts gurus on this list?

What is the best way to do a client/server application from within struts?
Do you have your JDBC calls primarily on the server side in your Model
(Business) objects and then "serve" the data up to your JSP pages?

Is JDBC from within the model beans the best way with which to perform
database calls from within a struts application?Or is there some other
kind of tool/package that is preferred (ie, similar to what entity beans do
for EJB)?

Do you try and avoid (at all costs) situations where you're keeping
resultsets open between requests and such? is there a web-site that
discusses the best way to do database applications from within the Struts
framework?

We'd like to duplicate our JFC/Swing application by which we log in and
create a user-profile object to be shared amongst all of our pages.   I'm
thinking with struts our user-profile object could be a JavaBean with
session-scope that can be accessed amongst all pages.   But would this bean
and other objects associated be able to use JDBC as a "clean" approach to
doing database applications with struts?

We looked at dbtaglib but don't want to use that as we want our SQL's and
business logic to be contained within beans rather than on the JSP pages.
We will consider using dbtaglib for simple things like reports and other
queries that we can throw together for users.

thanks again for any help or comments,
Theron Kousek


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Struts Fast Track: J2EE/JSP Framework: Practical Application with Database Access and Struts Extension

2002-03-22 Thread @Basebeans.com

Subject: Struts Fast Track: J2EE/JSP Framework: Practical Application with Database 
Access and Struts Extension
From: "Nav Sandhu" <[EMAIL PROTECTED]>
 ===
This might be of some help.

Struts Fast Track: J2EE/JSP Framework: Practical Application with Database
Access and Struts Extension

http://www.amazon.com/exec/obidos/ASIN/0971661901/qid%3D1016818089/sr%3D1-2/
ref%3Dsr%5F1%5F2/002-8523198-7363226




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Struts Fast Track: J2EE/JSP Framework: Practical Application with Database Access and Struts Extension

2002-03-22 Thread Andrew H. Peterson

I purchased this book and was very, very disapointed in it.  It is not even
worth the paper it is written on.  Needless to say, I returned it.  Checkout
the reviews on Amazon and you'll see what I mean.

Andrew

-Original Message-
From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 6:40 PM
To: [EMAIL PROTECTED]
Subject: Struts Fast Track: J2EE/JSP Framework: Practical Application
with Database Access and Struts Extension


Subject: Struts Fast Track: J2EE/JSP Framework: Practical Application with
Database Access and Struts Extension
From: "Nav Sandhu" <[EMAIL PROTECTED]>
 ===
This might be of some help.

Struts Fast Track: J2EE/JSP Framework: Practical Application with Database
Access and Struts Extension

http://www.amazon.com/exec/obidos/ASIN/0971661901/qid%3D1016818089/sr%3D1-2/
ref%3Dsr%5F1%5F2/002-8523198-7363226




--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>