Re: JSTL Date Format Question

2002-04-01 Thread Shawn Bayern

A variable that prints a string starting with [B is likely a primitive
byte array (byte[]).  This means that the MYSQL JDBC driver you're using
is probably returning a byte[] for the column aliased Date when it's
retrieved using ResultSet.getObject().  You could add

  c:out value=${row.Date.class} /

to the loop just to be sure.

I'm not sure this is anything the JSTL RI can address.  If DBTags works
with exactly the same JDBC driver, it might be that the critical
difference is that the driver returns a usable string when its ResultSet's
getString() method is called; I believe DBTags uses getString() where we
use getObject().

If you let me know specifically what MySQL JDBC driver you're using (a
pointer to its URL would be all I need), I can attempt to trace the
problem further and perhaps resolve the issue with the driver's
maintainers.  (Or, of course, my own replication of the problem could show
that it's really our bug.)

Thanks for the report,

-- 
Shawn Bayern
Author, JSP Standard Tag Library  http://www.jstlbook.com
(coming this summer from Manning Publications)

On Mon, 1 Apr 2002, Zvolensky, Thomas J {PDBI~Nutley} wrote:

 I have a query that selects records from a datetime column using the JSTL
 and MYSQL.  When I output the rows to a JSP page I'm getting the following:
 
 Anderau, Eoma BASEL [B@b6421 
 Andersson, Lisa   BASEL [B@5acb2b 
   [B@5092c0 
   [B@52883b 
   [B@6e1775 
   [B@462631 
   [B@756456 
 Andrews, Stella WELWYN[B@e6899 
   [B@752125
 
 The last column should display a date (dd-mmm-yy).
 
 My JSP code looks like this:
 
 sql:query var=visitor dataSource=${example}
 select distinct Authentications.userid,
 DATE_FORMAT(Authentications.authtime,'%d,%b,%y') as Date, UserInfo.*,
 UserInfo.firstname from Authentications,UserInfo
 where (UserInfo.userid=Authentications.userid) and
 (Authentications.docbase='eurpr1') 
 and UserInfo.userid NOT in ('eurpr1','erispre','dmadmin') order by
 UserInfo.lastname,Date
 /sql:query
 .
 .
 .
 !-- Loop through the rows of the query and display in the table --
 
 c:set var=oldname value=/c:set
 c:forEach var=row items=${visitor.rows}
 c:set var=newname value=${row.lastname}/c:set
 
 !-- New user encountered, print name and location --
 c:if test=${newname != oldname}
   tr
   td align=leftc:out
 value=${row.lastname}/,nbsp;c:out value=${row.firstname}//td
   td align=leftc:out value=${row.city}//td
   td align=leftc:out value=${row.Date}//td
  /tr
 /c:if
 
 !-- Same user.  List visit date only --
 c:if test=${newname == oldname}
   tr
   td align=leftnbsp;/td
   td align=leftnbsp;/td
   td align=leftc:out value=${row.Date}//td
  /tr
 /c:if
 c:set var=oldname value=${row.lastname}/c:set
 
 /c:forEach
 
 Is a conversion from datetime/date format to text required before the c:out
 value=${row.Date}/ tag?  If I run the same query and list the records
 using th DBTAGS library, the date comes out correct.
 
 TIA


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




RE: JSTL Date Format Question

2002-04-01 Thread Zvolensky, Thomas J {PDBI~Nutley}

c:out value=${row.Date.class} / produced a blank for the date column.

My JDBC driver is mm.mysql-2.0.11-bin.jar which can be downloaded from
http://prdownloads.sourceforge.net/mmmysql/mm.mysql-2.0.11-you-must-unjar-me
.jar

Regards.

-Original Message-
From: Shawn Bayern [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 12:09 PM
To: Tag Libraries Users List
Subject: Re: JSTL Date Format Question


A variable that prints a string starting with [B is likely a primitive
byte array (byte[]).  This means that the MYSQL JDBC driver you're using
is probably returning a byte[] for the column aliased Date when it's
retrieved using ResultSet.getObject().  You could add

  c:out value=${row.Date.class} /

to the loop just to be sure.

I'm not sure this is anything the JSTL RI can address.  If DBTags works
with exactly the same JDBC driver, it might be that the critical
difference is that the driver returns a usable string when its ResultSet's
getString() method is called; I believe DBTags uses getString() where we
use getObject().

If you let me know specifically what MySQL JDBC driver you're using (a
pointer to its URL would be all I need), I can attempt to trace the
problem further and perhaps resolve the issue with the driver's
maintainers.  (Or, of course, my own replication of the problem could show
that it's really our bug.)

Thanks for the report,

-- 
Shawn Bayern
Author, JSP Standard Tag Library  http://www.jstlbook.com
(coming this summer from Manning Publications)

On Mon, 1 Apr 2002, Zvolensky, Thomas J {PDBI~Nutley} wrote:

 I have a query that selects records from a datetime column using the JSTL
 and MYSQL.  When I output the rows to a JSP page I'm getting the
following:
 
 Anderau, Eoma BASEL [B@b6421 
 Andersson, Lisa   BASEL [B@5acb2b 
   [B@5092c0 
   [B@52883b 
   [B@6e1775 
   [B@462631 
   [B@756456 
 Andrews, Stella WELWYN[B@e6899 
   [B@752125
 
 The last column should display a date (dd-mmm-yy).
 
 My JSP code looks like this:
 
 sql:query var=visitor dataSource=${example}
 select distinct Authentications.userid,
 DATE_FORMAT(Authentications.authtime,'%d,%b,%y') as Date, UserInfo.*,
 UserInfo.firstname from Authentications,UserInfo
 where (UserInfo.userid=Authentications.userid) and
 (Authentications.docbase='eurpr1') 
 and UserInfo.userid NOT in ('eurpr1','erispre','dmadmin') order by
 UserInfo.lastname,Date
 /sql:query
 .
 .
 .
 !-- Loop through the rows of the query and display in the table --
 
 c:set var=oldname value=/c:set
 c:forEach var=row items=${visitor.rows}
 c:set var=newname value=${row.lastname}/c:set
 
 !-- New user encountered, print name and location --
 c:if test=${newname != oldname}
   tr
   td align=leftc:out
 value=${row.lastname}/,nbsp;c:out value=${row.firstname}//td
   td align=leftc:out value=${row.city}//td
   td align=leftc:out value=${row.Date}//td
  /tr
 /c:if
 
 !-- Same user.  List visit date only --
 c:if test=${newname == oldname}
   tr
   td align=leftnbsp;/td
   td align=leftnbsp;/td
   td align=leftc:out value=${row.Date}//td
  /tr
 /c:if
 c:set var=oldname value=${row.lastname}/c:set
 
 /c:forEach
 
 Is a conversion from datetime/date format to text required before the
c:out
 value=${row.Date}/ tag?  If I run the same query and list the records
 using th DBTAGS library, the date comes out correct.
 
 TIA


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




RE: JSTL Date Format Question

2002-04-01 Thread Shawn Bayern

Okay, I looked at the JDBC driver's code.  It returns a byte[] in cases
where the underlying object is java.sql.Types.LONGVARBINARY.  For some
reason, then, it looks like MySQL is returning a LONGVARBINARY column for
the one you're labeling Date.  This might be because the DATE_FORMAT
function results in a column of MySQL's TEXT type, which may be
translated to JDBC's LONGVARBINARY.

Here's what I would suggest:  avoid formatting the date in the query.  
That is, let the query ultimately return an actual java.util.Date if the
JDBC driver supports it, or a plain string (parsable with fmt:parseDate)
if it doesn't.

You could try calling getColumnType() to confirm what I've guessed here.  
Either way, though, I don't think there's anything we can do in the JSTL
RI to address this MySQL/JDBC issue.  Alternatively, the JSTL spec could
be modified to support byte[] more cleanly:  for instance, the JSTL EL
could print out a byte[] by converting it to a String using the default
character encoding.  This is somewhat ugly, but it might fit nicely with
our other type conversions.  I'll raise it to the expert group.

Thanks again for the report,

-- 
Shawn Bayern
Author, JSP Standard Tag Library  http://www.jstlbook.com
(coming this summer from Manning Publications)

On Mon, 1 Apr 2002, Zvolensky, Thomas J {PDBI~Nutley} wrote:

 c:out value=${row.Date.class} / produced a blank for the date column.
 
 My JDBC driver is mm.mysql-2.0.11-bin.jar which can be downloaded from
 http://prdownloads.sourceforge.net/mmmysql/mm.mysql-2.0.11-you-must-unjar-me
 .jar
 
 Regards.
 
 -Original Message-
 From: Shawn Bayern [mailto:[EMAIL PROTECTED]]
 Sent: Monday, April 01, 2002 12:09 PM
 To: Tag Libraries Users List
 Subject: Re: JSTL Date Format Question
 
 
 A variable that prints a string starting with [B is likely a primitive
 byte array (byte[]).  This means that the MYSQL JDBC driver you're using
 is probably returning a byte[] for the column aliased Date when it's
 retrieved using ResultSet.getObject().  You could add
 
   c:out value=${row.Date.class} /
 
 to the loop just to be sure.
 
 I'm not sure this is anything the JSTL RI can address.  If DBTags works
 with exactly the same JDBC driver, it might be that the critical
 difference is that the driver returns a usable string when its ResultSet's
 getString() method is called; I believe DBTags uses getString() where we
 use getObject().
 
 If you let me know specifically what MySQL JDBC driver you're using (a
 pointer to its URL would be all I need), I can attempt to trace the
 problem further and perhaps resolve the issue with the driver's
 maintainers.  (Or, of course, my own replication of the problem could show
 that it's really our bug.)
 
 Thanks for the report,


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




RE: JSTL Date Format Question

2002-04-01 Thread Henri Yandell



On Mon, 1 Apr 2002, Shawn Bayern wrote:

 Okay, I looked at the JDBC driver's code.  It returns a byte[] in cases
 where the underlying object is java.sql.Types.LONGVARBINARY.  For some
 reason, then, it looks like MySQL is returning a LONGVARBINARY column for
 the one you're labeling Date.  This might be because the DATE_FORMAT
 function results in a column of MySQL's TEXT type, which may be
 translated to JDBC's LONGVARBINARY.

Am pretty sure this is true. For some reason MySQL TEXT = one of the
Binary types in JDBC. It's not normally a big issue as the getString still
seems to get the text properly.

Hen



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




RE: JSTL Date Format Question

2002-04-01 Thread Shawn Bayern

On Mon, 1 Apr 2002, Henri Yandell wrote:

  Okay, I looked at the JDBC driver's code.  It returns a byte[] in cases
  where the underlying object is java.sql.Types.LONGVARBINARY.  For some
  reason, then, it looks like MySQL is returning a LONGVARBINARY column for
  the one you're labeling Date.  This might be because the DATE_FORMAT
  function results in a column of MySQL's TEXT type, which may be
  translated to JDBC's LONGVARBINARY.
 
 Am pretty sure this is true. For some reason MySQL TEXT = one of the
 Binary types in JDBC. It's not normally a big issue as the getString
 still seems to get the text properly.

Interesting.  To be more general, JSTL uses getObject() instead of
getString().  The idea of converting byte[] to String (using whatever
character encoding is available) is growing on me; it's certainly no worse
than ResultSet.getString(), and it's also certainly no worse than printing
[B@x.

MySQL, alas, is common enough that we probably want to at least consider
this; in fairness, it's not really a case specific to MySQL, but a more
general question of how our EL deals with byte[].

-- 
Shawn Bayern
Author, JSP Standard Tag Library  http://www.jstlbook.com
(coming this summer from Manning Publications)


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




RE: JSTL Date Format Question

2002-04-01 Thread Zvolensky, Thomas J {PDBI~Nutley}

This is unfortunate as I need to return one record per user per date in my
query, necessitating the DATE_FORMAT( ) function in my select.  I'm using
MYSQL as a temporary development platform until a specific ORACLE server
becomes available.

Do you think that the proper date will be displayed under ORACLE?  If so,
I'll move on to other things.

-Original Message-
From: Shawn Bayern [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 2:02 PM
To: Tag Libraries Users List
Subject: RE: JSTL Date Format Question


Okay, I looked at the JDBC driver's code.  It returns a byte[] in cases
where the underlying object is java.sql.Types.LONGVARBINARY.  For some
reason, then, it looks like MySQL is returning a LONGVARBINARY column for
the one you're labeling Date.  This might be because the DATE_FORMAT
function results in a column of MySQL's TEXT type, which may be
translated to JDBC's LONGVARBINARY.

Here's what I would suggest:  avoid formatting the date in the query.  
That is, let the query ultimately return an actual java.util.Date if the
JDBC driver supports it, or a plain string (parsable with fmt:parseDate)
if it doesn't.

You could try calling getColumnType() to confirm what I've guessed here.  
Either way, though, I don't think there's anything we can do in the JSTL
RI to address this MySQL/JDBC issue.  Alternatively, the JSTL spec could
be modified to support byte[] more cleanly:  for instance, the JSTL EL
could print out a byte[] by converting it to a String using the default
character encoding.  This is somewhat ugly, but it might fit nicely with
our other type conversions.  I'll raise it to the expert group.

Thanks again for the report,

-- 
Shawn Bayern
Author, JSP Standard Tag Library  http://www.jstlbook.com
(coming this summer from Manning Publications)

On Mon, 1 Apr 2002, Zvolensky, Thomas J {PDBI~Nutley} wrote:

 c:out value=${row.Date.class} / produced a blank for the date column.
 
 My JDBC driver is mm.mysql-2.0.11-bin.jar which can be downloaded from

http://prdownloads.sourceforge.net/mmmysql/mm.mysql-2.0.11-you-must-unjar-me
 .jar
 
 Regards.
 
 -Original Message-
 From: Shawn Bayern [mailto:[EMAIL PROTECTED]]
 Sent: Monday, April 01, 2002 12:09 PM
 To: Tag Libraries Users List
 Subject: Re: JSTL Date Format Question
 
 
 A variable that prints a string starting with [B is likely a primitive
 byte array (byte[]).  This means that the MYSQL JDBC driver you're using
 is probably returning a byte[] for the column aliased Date when it's
 retrieved using ResultSet.getObject().  You could add
 
   c:out value=${row.Date.class} /
 
 to the loop just to be sure.
 
 I'm not sure this is anything the JSTL RI can address.  If DBTags works
 with exactly the same JDBC driver, it might be that the critical
 difference is that the driver returns a usable string when its ResultSet's
 getString() method is called; I believe DBTags uses getString() where we
 use getObject().
 
 If you let me know specifically what MySQL JDBC driver you're using (a
 pointer to its URL would be all I need), I can attempt to trace the
 problem further and perhaps resolve the issue with the driver's
 maintainers.  (Or, of course, my own replication of the problem could show
 that it's really our bug.)
 
 Thanks for the report,


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