RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread Mindaugas Idzelis

Well, I guess a way to work around that problem would be to create a data
structure to represent the entire resultset. This could be a LinkedList of
hashtables, with each key being the column name, and the value being the
result.

The disadvantage of this approach is that is requires the entire resultset
to be loaded into memory, which may have some performance problems, right?

--min

-Original Message-
From: Jonathan Asbell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 06, 2001 11:47 PM
To: [EMAIL PROTECTED]
Subject: Re: Suggestion/Idea for iterate tag: Iterate ResultSets


Result sets ARE tied to the connection in a way.  Some DB drivers throw
exceptions when you try to manipulate data while you still have a pointer to
rows.  At work we were trying to manipulate a stream which was pointing to
an output parameter in a stored proc while the connection was open.  The
result was that we had to convert the stream into another object (String in
our case) and close the connection just to manipulate the data.

- Original Message -
From: Mindaugas Idzelis [EMAIL PROTECTED]
To: struts [EMAIL PROTECTED]
Sent: Sunday, May 06, 2001 9:33 PM
Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


 I just thought up of an excellent idea (although, I wasn't the only one).
 Use the iterate tag to iterate over the rows of a resultset. The column
meta
 data could be exposed as beans named as the column name. A bean:write
 operation would display the data in the column.

 I did a search about this topic in the mailing list archive, and I found
 this message:

 http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2

 It talk about ResultSets being tied to connections. This is not the case.
 ResultSets are tied to the statements that produced them, and as far as I
 can tell, statements are not closed when the connection is closed.

 Other than that, It should be easy to change the iterate tag to support
 resultsets. If anyone is interested in helping me extend or develop a tag
 for this purpose, please message me.

 --min





RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread Mindaugas Idzelis

I just thought of another option: If resultsets are tied to a connection and
a statement, then specify the sql query within the iterator:

Hypothetical taglibs:
sql:query id=myQuery
SELECT col1, col2
FROM table
WHERE id  1
!-- even use bean:write in here to dynamically make queries --
/sql:query
logic:iterate id=row query=myQuery
bean:write name=row property=col1/
bean:write name=row property=col2/
br
/logic:iterate

Where sql:query would only be evauluated once per iteration. Would this be
possible to create? I have never authored a taglib, so any feedback from
taglib veterans is greatly appreciated. I think this would be a great
addition to the taglibs framework.

--min

-Original Message-
From: Jonathan Asbell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 06, 2001 11:47 PM
To: [EMAIL PROTECTED]
Subject: Re: Suggestion/Idea for iterate tag: Iterate ResultSets


Result sets ARE tied to the connection in a way.  Some DB drivers throw
exceptions when you try to manipulate data while you still have a pointer to
rows.  At work we were trying to manipulate a stream which was pointing to
an output parameter in a stored proc while the connection was open.  The
result was that we had to convert the stream into another object (String in
our case) and close the connection just to manipulate the data.

- Original Message -
From: Mindaugas Idzelis [EMAIL PROTECTED]
To: struts [EMAIL PROTECTED]
Sent: Sunday, May 06, 2001 9:33 PM
Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


 I just thought up of an excellent idea (although, I wasn't the only one).
 Use the iterate tag to iterate over the rows of a resultset. The column
meta
 data could be exposed as beans named as the column name. A bean:write
 operation would display the data in the column.

 I did a search about this topic in the mailing list archive, and I found
 this message:

 http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2

 It talk about ResultSets being tied to connections. This is not the case.
 ResultSets are tied to the statements that produced them, and as far as I
 can tell, statements are not closed when the connection is closed.

 Other than that, It should be easy to change the iterate tag to support
 resultsets. If anyone is interested in helping me extend or develop a tag
 for this purpose, please message me.

 --min





RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread Cook, Levi

If you are interested in executing SQL from your JSPs, the taglibs project
might save you some time.

Check into:
http://jakarta.apache.org/taglibs/doc/dbtags-doc/intro.html


For what its worth, this approach breaks the model-view separation struts
may have provided for your project. If that's ok for your project, then the
afore-mentioned taglibs should save you time. On the other hand, if your not
sure what model-view separation is, I would recommend reviewing the Struts
User's Guide - Introduction at:
http://jakarta.apache.org/struts/userGuide/introduction.html


Regards,
Levi Cook


-Original Message-
From: Mindaugas Idzelis [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 07, 2001 9:06 AM
To: [EMAIL PROTECTED]; Jonathan Asbell
Subject: RE: Suggestion/Idea for iterate tag: Iterate ResultSets


I just thought of another option: If resultsets are tied to a connection and
a statement, then specify the sql query within the iterator:

Hypothetical taglibs:
sql:query id=myQuery
SELECT col1, col2
FROM table
WHERE id  1
!-- even use bean:write in here to dynamically make
queries --
/sql:query
logic:iterate id=row query=myQuery
bean:write name=row property=col1/
bean:write name=row property=col2/
br
/logic:iterate

Where sql:query would only be evauluated once per iteration. Would this be
possible to create? I have never authored a taglib, so any feedback from
taglib veterans is greatly appreciated. I think this would be a great
addition to the taglibs framework.

--min

-Original Message-
From: Jonathan Asbell [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 06, 2001 11:47 PM
To: [EMAIL PROTECTED]
Subject: Re: Suggestion/Idea for iterate tag: Iterate ResultSets


Result sets ARE tied to the connection in a way.  Some DB drivers throw
exceptions when you try to manipulate data while you still have a pointer to
rows.  At work we were trying to manipulate a stream which was pointing to
an output parameter in a stored proc while the connection was open.  The
result was that we had to convert the stream into another object (String in
our case) and close the connection just to manipulate the data.

- Original Message -
From: Mindaugas Idzelis [EMAIL PROTECTED]
To: struts [EMAIL PROTECTED]
Sent: Sunday, May 06, 2001 9:33 PM
Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


 I just thought up of an excellent idea (although, I wasn't the only one).
 Use the iterate tag to iterate over the rows of a resultset. The column
meta
 data could be exposed as beans named as the column name. A bean:write
 operation would display the data in the column.

 I did a search about this topic in the mailing list archive, and I found
 this message:

 http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2

 It talk about ResultSets being tied to connections. This is not the case.
 ResultSets are tied to the statements that produced them, and as far as I
 can tell, statements are not closed when the connection is closed.

 Other than that, It should be easy to change the iterate tag to support
 resultsets. If anyone is interested in helping me extend or develop a tag
 for this purpose, please message me.

 --min




RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread boB Rudis

I think Struts does a good job dealing with the whole MVC separation
issues... Embedding SQL into yet-another-custom tag seems to (IMHO)
violate a number of the principles Struts is trying to uphold.

Truth-be-told, I haven't been a real JSP/custom tag fan from the start
(aren't there enough languages to learn alrady? *:^) after spending
countless hours sifting through bugs in other folkk's ASP pages and
ColdFusion pages, but the whole Struts framework feels right and does a
great job letting you have a *manageable*, *flexible* and *structured*
view while doing most of the controller work for you, leaving only the
icky model details to really work out. The fact that it works with Java
is icing on the cake *:^)

Tossing SQL directly into the view re-introduces the potential for
unmanageabe web code (again, IMHO).

It would be great to hear from those who have dealt with this more in the
Java world, tho, on their feelings of SQL-JSP-MVC.

As an aside, there is a good start on SQL taglibs - the DBTags tag library
- in the jakarta-taglibs project -
http://jakarta.apache.org/taglibs/doc/dbtags-doc/intro.html in case an
individual wanted to see how to integrate this into Struts w/o
re-inventing the wheel. An excerpt from their example page yields the
following (which looks similar to what you were trying to do):

%-- print the rows in an HTML table --%
table
sql:statement id=stmt1 conn=conn1
 
  sql:query
select id, name, description from test_books
order by 1
  /sql:query
  
  %-- loop through the rows of your query --%
  sql:resultSet id=rset2
tr
  tdsql:getColumn position=1//td
  tdsql:getColumn position=2//td
  tdsql:getColumn position=3/
  %-- print out a comment if the book has no description --%
  sql:wasNull[no description]/sql:wasNull/td
/tr
  /sql:resultSet
  
/sql:statement
/table


boB Rudis
[EMAIL PROTECTED]
http://www.rudis.net/

++
| Mind the gap |
++

On Mon, 7 May 2001, Mindaugas Idzelis wrote:

 I just thought of another option: If resultsets are tied to a connection and
 a statement, then specify the sql query within the iterator:
 
 Hypothetical taglibs:
 sql:query id=myQuery
   SELECT col1, col2
   FROM table
   WHERE id  1
   !-- even use bean:write in here to dynamically make queries --
 /sql:query
 logic:iterate id=row query=myQuery
   bean:write name=row property=col1/
   bean:write name=row property=col2/
   br
 /logic:iterate
 
 Where sql:query would only be evauluated once per iteration. Would this be
 possible to create? I have never authored a taglib, so any feedback from
 taglib veterans is greatly appreciated. I think this would be a great
 addition to the taglibs framework.
 
 --min
 
 -Original Message-
 From: Jonathan Asbell [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 06, 2001 11:47 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Suggestion/Idea for iterate tag: Iterate ResultSets
 
 
 Result sets ARE tied to the connection in a way.  Some DB drivers throw
 exceptions when you try to manipulate data while you still have a pointer to
 rows.  At work we were trying to manipulate a stream which was pointing to
 an output parameter in a stored proc while the connection was open.  The
 result was that we had to convert the stream into another object (String in
 our case) and close the connection just to manipulate the data.
 
 - Original Message -
 From: Mindaugas Idzelis [EMAIL PROTECTED]
 To: struts [EMAIL PROTECTED]
 Sent: Sunday, May 06, 2001 9:33 PM
 Subject: Suggestion/Idea for iterate tag: Iterate ResultSets
 
 
  I just thought up of an excellent idea (although, I wasn't the only one).
  Use the iterate tag to iterate over the rows of a resultset. The column
 meta
  data could be exposed as beans named as the column name. A bean:write
  operation would display the data in the column.
 
  I did a search about this topic in the mailing list archive, and I found
  this message:
 
  http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2
 
  It talk about ResultSets being tied to connections. This is not the case.
  ResultSets are tied to the statements that produced them, and as far as I
  can tell, statements are not closed when the connection is closed.
 
  Other than that, It should be easy to change the iterate tag to support
  resultsets. If anyone is interested in helping me extend or develop a tag
  for this purpose, please message me.
 
  --min
 
 
 




RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread Niall Pemberton

I haven't used it, but this looks similar to whats been developed in the
jakarta taglibs project - see JDBC taglib.

   http://jakarta.apache.org/taglibs/doc/jdbc-doc/intro.html

Niall

 -Original Message-
 From: Mindaugas Idzelis [mailto:[EMAIL PROTECTED]]
 Sent: 07 May 2001 15:06
 To: [EMAIL PROTECTED]; Jonathan Asbell
 Subject: RE: Suggestion/Idea for iterate tag: Iterate ResultSets


 I just thought of another option: If resultsets are tied to a
 connection and
 a statement, then specify the sql query within the iterator:

 Hypothetical taglibs:
 sql:query id=myQuery
   SELECT col1, col2
   FROM table
   WHERE id  1
   !-- even use bean:write in here to dynamically
 make queries --
 /sql:query
 logic:iterate id=row query=myQuery
   bean:write name=row property=col1/
   bean:write name=row property=col2/
   br
 /logic:iterate

 Where sql:query would only be evauluated once per iteration. Would this be
 possible to create? I have never authored a taglib, so any feedback from
 taglib veterans is greatly appreciated. I think this would be a great
 addition to the taglibs framework.

 --min

 -Original Message-
 From: Jonathan Asbell [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 06, 2001 11:47 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Suggestion/Idea for iterate tag: Iterate ResultSets


 Result sets ARE tied to the connection in a way.  Some DB drivers throw
 exceptions when you try to manipulate data while you still have a
 pointer to
 rows.  At work we were trying to manipulate a stream which was pointing to
 an output parameter in a stored proc while the connection was open.  The
 result was that we had to convert the stream into another object
 (String in
 our case) and close the connection just to manipulate the data.

 - Original Message -
 From: Mindaugas Idzelis [EMAIL PROTECTED]
 To: struts [EMAIL PROTECTED]
 Sent: Sunday, May 06, 2001 9:33 PM
 Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


  I just thought up of an excellent idea (although, I wasn't the
 only one).
  Use the iterate tag to iterate over the rows of a resultset. The column
 meta
  data could be exposed as beans named as the column name. A bean:write
  operation would display the data in the column.
 
  I did a search about this topic in the mailing list archive, and I found
  this message:
 
  http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2
 
  It talk about ResultSets being tied to connections. This is not
 the case.
  ResultSets are tied to the statements that produced them, and
 as far as I
  can tell, statements are not closed when the connection is closed.
 
  Other than that, It should be easy to change the iterate tag to support
  resultsets. If anyone is interested in helping me extend or
 develop a tag
  for this purpose, please message me.
 
  --min
 






RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread Lewis Henderson

See this for remote resultsets...

http://developer.java.sun.com/developer/earlyAccess/crs/

also there is a good section in Professional Java Server Programming J2EE
Edition (Wrox press) Page 587 on a TableModel tag library...

Lewis

-Original Message-
From: Mindaugas Idzelis [mailto:[EMAIL PROTECTED]]
Sent: 07 May 2001 02:33
To: struts
Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


I just thought up of an excellent idea (although, I wasn't the only one).
Use the iterate tag to iterate over the rows of a resultset. The column meta
data could be exposed as beans named as the column name. A bean:write
operation would display the data in the column.

I did a search about this topic in the mailing list archive, and I found
this message:

http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2

It talk about ResultSets being tied to connections. This is not the case.
ResultSets are tied to the statements that produced them, and as far as I
can tell, statements are not closed when the connection is closed.

Other than that, It should be easy to change the iterate tag to support
resultsets. If anyone is interested in helping me extend or develop a tag
for this purpose, please message me.

--min





Re: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-06 Thread Jonathan Asbell

Result sets ARE tied to the connection in a way.  Some DB drivers throw
exceptions when you try to manipulate data while you still have a pointer to
rows.  At work we were trying to manipulate a stream which was pointing to
an output parameter in a stored proc while the connection was open.  The
result was that we had to convert the stream into another object (String in
our case) and close the connection just to manipulate the data.

- Original Message -
From: Mindaugas Idzelis [EMAIL PROTECTED]
To: struts [EMAIL PROTECTED]
Sent: Sunday, May 06, 2001 9:33 PM
Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


 I just thought up of an excellent idea (although, I wasn't the only one).
 Use the iterate tag to iterate over the rows of a resultset. The column
meta
 data could be exposed as beans named as the column name. A bean:write
 operation would display the data in the column.

 I did a search about this topic in the mailing list archive, and I found
 this message:

 http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2

 It talk about ResultSets being tied to connections. This is not the case.
 ResultSets are tied to the statements that produced them, and as far as I
 can tell, statements are not closed when the connection is closed.

 Other than that, It should be easy to change the iterate tag to support
 resultsets. If anyone is interested in helping me extend or develop a tag
 for this purpose, please message me.

 --min