Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.databases > #443 > unrolled thread

Problem with JDBC driver and MySQL date_format function

Started byJens Riedel <JensRie@gmx.de>
First post2011-05-13 08:11 +0200
Last post2011-05-15 21:17 +0200
Articles 10 — 5 participants

Back to article view | Back to comp.lang.java.databases


Contents

  Problem with JDBC driver and MySQL date_format function Jens Riedel <JensRie@gmx.de> - 2011-05-13 08:11 +0200
    Re: Problem with JDBC driver and MySQL date_format function "John B. Matthews" <nospam@nospam.invalid> - 2011-05-14 18:19 -0400
      Re: Problem with JDBC driver and MySQL date_format function Lew <noone@lewscanon.com> - 2011-05-15 06:59 -0400
    Re: Problem with JDBC driver and MySQL date_format function Hans Castorp <REWYRLXHEGHO@spammotel.com> - 2011-05-15 13:37 +0200
      Re: Problem with JDBC driver and MySQL date_format function "John B. Matthews" <nospam@nospam.invalid> - 2011-05-15 19:51 -0400
        Re: Problem with JDBC driver and MySQL date_format function Stanimir Stamenkov <s7an10@netscape.net> - 2011-05-16 08:35 +0300
          Re: Problem with JDBC driver and MySQL date_format function Lew <noone@lewscanon.com> - 2011-05-16 01:42 -0400
            Re: Problem with JDBC driver and MySQL date_format function "John B. Matthews" <nospam@nospam.invalid> - 2011-05-16 08:46 -0400
              Re: Problem with JDBC driver and MySQL date_format function Lew <noone@lewscanon.com> - 2011-05-16 10:23 -0400
    Re: Problem with JDBC driver and MySQL date_format function Jens Riedel <JensRie@gmx.de> - 2011-05-15 21:17 +0200

#443 — Problem with JDBC driver and MySQL date_format function

FromJens Riedel <JensRie@gmx.de>
Date2011-05-13 08:11 +0200
SubjectProblem with JDBC driver and MySQL date_format function
Message-ID<9340c7F40hU1@mid.individual.net>
Hello,

I have the following problem with a java application:

Since I updated my mysql driver version 3 to version 5 
(mysql-connector-java-5.1.7-bin.jar) I get funny strings like 
"[B@b57546" when I format datetime columns with the date_format function 
instead of the correct formatted date string.

When I execute the statement with HeidiSQL or another DB client directly 
everything is working fine, also when I switch back to 
mysql-connector-java-3.1.12-bin.jar.

Does anybody know this problem and a solution for this?

Thanks
Jens

[toc] | [next] | [standalone]


#444

From"John B. Matthews" <nospam@nospam.invalid>
Date2011-05-14 18:19 -0400
Message-ID<nospam-CC3166.18193614052011@news.aioe.org>
In reply to#443
In article <9340c7F40hU1@mid.individual.net>,
 Jens Riedel <JensRie@gmx.de> wrote:

> I have the following problem with a java application:
> 
> Since I updated my mysql driver version 3 to version 5 
> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like 
> "[B@b57546" when I format datetime columns with the date_format 
> function instead of the correct formatted date string.
> 
> When I execute the statement with HeidiSQL or another DB client 
> directly everything is working fine, also when I switch back to 
> mysql-connector-java-3.1.12-bin.jar.
> 
> Does anybody know this problem and a solution for this?

I haven't used MySQL recently enough to give a specific answer, but 
incorrect character encoding is the first thing that leaps to mind. 
Unfortunately, the "funny strings" usually have a different appearance. 
What this _does_ look like is a reference to a byte array, mentioned 
here:

<http://stackoverflow.com/questions/2558031>

The "@b57546" part is akin to a memory pointer or handle. It is possible 
that the byte array contains the result for code points that are not 
decipherable using the character encoding in effect.

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#445

FromLew <noone@lewscanon.com>
Date2011-05-15 06:59 -0400
Message-ID<iqoblv$ugm$1@news.albasani.net>
In reply to#444
On 05/14/2011 06:19 PM, John B. Matthews wrote:
> In article<9340c7F40hU1@mid.individual.net>,
>   Jens Riedel<JensRie@gmx.de>  wrote:
>
>> I have the following problem with a java application:
>>
>> Since I updated my mysql driver version 3 to version 5
>> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like
>> "[B@b57546" when I format datetime columns with the date_format
>> function instead of the correct formatted date string.
>>
>> When I execute the statement with HeidiSQL or another DB client
>> directly everything is working fine, also when I switch back to
>> mysql-connector-java-3.1.12-bin.jar.
>>
>> Does anybody know this problem and a solution for this?
>
> I haven't used MySQL recently enough to give a specific answer, but
> incorrect character encoding is the first thing that leaps to mind.
> Unfortunately, the "funny strings" usually have a different appearance.
> What this _does_ look like is a reference to a byte array, mentioned
> here:
>
> <http://stackoverflow.com/questions/2558031>
>
> The "@b57546" part is akin to a memory pointer or handle. It is possible
> that the byte array contains the result for code points that are not
> decipherable using the character encoding in effect.

We need to see code, otherwise we're pissing into the wind.

Best would be an SSCCE.
<http://sscce.org/>

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#446

FromHans Castorp <REWYRLXHEGHO@spammotel.com>
Date2011-05-15 13:37 +0200
Message-ID<939s7hFsqnU1@mid.individual.net>
In reply to#443
Jens Riedel wrote on 13.05.2011 08:11:
> Since I updated my mysql driver version 3 to version 5
> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like
> "[B@b57546" when I format datetime columns with the date_format
> function instead of the correct formatted date string.
>

That sure looks like the default toString() output of java.lang.Object

What exactly are you passing to the date_format() function?
Show us your SQL statement and the Java code

[toc] | [prev] | [next] | [standalone]


#448

From"John B. Matthews" <nospam@nospam.invalid>
Date2011-05-15 19:51 -0400
Message-ID<nospam-96B5BF.19514915052011@news.aioe.org>
In reply to#446
In article <939s7hFsqnU1@mid.individual.net>,
 Hans Castorp <REWYRLXHEGHO@spammotel.com> wrote:

> Jens Riedel wrote on 13.05.2011 08:11:
> > Since I updated my mysql driver version 3 to version 5 
> > (mysql-connector-java-5.1.7-bin.jar) I get funny strings like 
> > "[B@b57546" when I format datetime columns with the date_format 
> > function instead of the correct formatted date string.
> >
> 
> That sure looks like the default toString() output of 
> java.lang.Object

No, java.lang.Object looks like this: java.lang.Object@771c8a71

> What exactly are you passing to the date_format() function? Show us 
> your SQL statement and the Java code

Yes.

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#449

FromStanimir Stamenkov <s7an10@netscape.net>
Date2011-05-16 08:35 +0300
Message-ID<iqqd23$dq4$1@dont-email.me>
In reply to#448
Sun, 15 May 2011 19:51:49 -0400, /John B. Matthews/:
> In article <939s7hFsqnU1@mid.individual.net>, Hans Castorp wrote:
>> Jens Riedel wrote on 13.05.2011 08:11:
>>
>>> Since I updated my mysql driver version 3 to version 5
>>> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like
>>> "[B@b57546" when I format datetime columns with the date_format
>>> function instead of the correct formatted date string.
>>
>> That sure looks like the default toString() output of
>> java.lang.Object
>
> No, java.lang.Object looks like this: java.lang.Object@771c8a71

That looks like the output of java.lang.Object.toString() invoked on 
a byte[] instance:

     getClass().getName() + '@' + Integer.toHexString(hashCode())

http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#toString%28%29

http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29

-- 
Stanimir

[toc] | [prev] | [next] | [standalone]


#450

FromLew <noone@lewscanon.com>
Date2011-05-16 01:42 -0400
Message-ID<iqqdg9$lj7$1@news.albasani.net>
In reply to#449
On 05/16/2011 01:35 AM, Stanimir Stamenkov wrote:
> Sun, 15 May 2011 19:51:49 -0400, /John B. Matthews/:
>> In article <939s7hFsqnU1@mid.individual.net>, Hans Castorp wrote:
>>> Jens Riedel wrote on 13.05.2011 08:11:
>>>
>>>> Since I updated my mysql driver version 3 to version 5
>>>> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like
>>>> "[B@b57546" when I format datetime columns with the date_format
>>>> function instead of the correct formatted date string.
>>>
>>> That sure looks like the default toString() output of
>>> java.lang.Object
>>
>> No, java.lang.Object looks like this: java.lang.Object@771c8a71
>
> That looks like the output of java.lang.Object.toString() invoked on a byte[]
> instance:
>
> getClass().getName() + '@' + Integer.toHexString(hashCode())
>
> http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#toString%28%29
>
> http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29

You guys are talking at cross purposes because you're using different 
definitions of 'java.lang.Object.toString()'.  Stanimir means the method as 
implemented in 'Object' and not overridden by 'byte[]'.  John means the method 
as applied to 'Object' itself.  Both of you are correct.  Now you can stop 
arguing.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#451

From"John B. Matthews" <nospam@nospam.invalid>
Date2011-05-16 08:46 -0400
Message-ID<nospam-25C6E3.08465916052011@news.aioe.org>
In reply to#450
In article <iqqdg9$lj7$1@news.albasani.net>, Lew <noone@lewscanon.com> 
wrote:

> On 05/16/2011 01:35 AM, Stanimir Stamenkov wrote:
> > Sun, 15 May 2011 19:51:49 -0400, /John B. Matthews/:
> >> In article <939s7hFsqnU1@mid.individual.net>, Hans Castorp wrote:
> >>> Jens Riedel wrote on 13.05.2011 08:11:
> >>>
> >>>> Since I updated my mysql driver version 3 to version 5 
> >>>> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like 
> >>>> "[B@b57546" when I format datetime columns with the date_format 
> >>>> function instead of the correct formatted date string.
> >>>
> >>> That sure looks like the default toString() output of 
> >>> java.lang.Object
> >>
> >> No, java.lang.Object looks like this: java.lang.Object@771c8a71
> >
> > That looks like the output of java.lang.Object.toString() invoked 
> > on a byte[] instance:
> >
> > getClass().getName() + '@' + Integer.toHexString(hashCode())
> >
> > http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#toString%28%29
> >
> > http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29
> 
> You guys are talking at cross purposes because you're using different 
> definitions of 'java.lang.Object.toString()'.  Stanimir means the 
> method as implemented in 'Object' and not overridden by 'byte[]'.  
> John means the method as applied to 'Object' itself.  Both of you are 
> correct.  Now you can stop arguing.

Stanimir: I never noticed the correspondence between the numeric 
portion and the result from hashCode(), but it's right there in the 
source, as quoted in the API. Thanks.

Lew: This looks like another good argument for continually reviewing 
APIs, even familiar ones.

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#452

FromLew <noone@lewscanon.com>
Date2011-05-16 10:23 -0400
Message-ID<iqrc0g$r3d$1@news.albasani.net>
In reply to#451
On 05/16/2011 08:46 AM, John B. Matthews wrote:
> In article<iqqdg9$lj7$1@news.albasani.net>, Lew<noone@lewscanon.com>
> wrote:
>
>> On 05/16/2011 01:35 AM, Stanimir Stamenkov wrote:
>>> Sun, 15 May 2011 19:51:49 -0400, /John B. Matthews/:
>>>> In article<939s7hFsqnU1@mid.individual.net>, Hans Castorp wrote:
>>>>> Jens Riedel wrote on 13.05.2011 08:11:
>>>>>
>>>>>> Since I updated my mysql driver version 3 to version 5
>>>>>> (mysql-connector-java-5.1.7-bin.jar) I get funny strings like
>>>>>> "[B@b57546" when I format datetime columns with the date_format
>>>>>> function instead of the correct formatted date string.
>>>>>
>>>>> That sure looks like the default toString() output of
>>>>> java.lang.Object
>>>>
>>>> No, java.lang.Object looks like this: java.lang.Object@771c8a71
>>>
>>> That looks like the output of java.lang.Object.toString() invoked
>>> on a byte[] instance:
>>>
>>> getClass().getName() + '@' + Integer.toHexString(hashCode())
>>>
>>> http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#toString%28%29
>>>
>>> http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29
>>
>> You guys are talking at cross purposes because you're using different
>> definitions of 'java.lang.Object.toString()'.  Stanimir means the
>> method as implemented in 'Object' and not overridden by 'byte[]'.
>> John means the method as applied to 'Object' itself.  Both of you are
>> correct.  Now you can stop arguing.
>
> Stanimir: I never noticed the correspondence between the numeric
> portion and the result from hashCode(), but it's right there in the
> source, as quoted in the API. Thanks.

Note the advice that the hash code "is typically implemented by converting the 
internal address of the object into an integer, but this implementation 
technique is not required by the JavaTM programming language."  Either way, 
whatever the hash code is will be part of the base 'Object#toString()'.

> Lew: This looks like another good argument for continually reviewing
> APIs, even familiar ones.

I may be (am) out of shape now, but years ago when I took karate, every 
instructor always made us relearn the basics several times a year.  Same thing 
in music - every musician I know who's any good tells me they spend hours 
daily just practicing scales.  Pro athletes are always drilling the basics 
over and over and over.  It is a concomitant to expertise in any skill activity.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#447

FromJens Riedel <JensRie@gmx.de>
Date2011-05-15 21:17 +0200
Message-ID<93an6mFmd3U1@mid.individual.net>
In reply to#443
Thanks for your answers so far.
Meanwhile I found out that this seems to be an issue that's known and 
described here:

http://bugs.mysql.com/bug.php?id=32505

I checked it with DB Visualizer and I also get a BLOB there for "select 
date_format(now(), '%Y%m%d')", for example.

The problem is: as long as I work on my local Windows Mysql DB version 
5.0.67, everything is working fine; when I try on one of our both Linux 
MySQL 5.0.27 DBs I get this problem.
As it is a customer system an update to the same version would be much 
effort; what configuration settings should I check first to try to get 
rid of this problem for the Linux DBs?

Thanks for any ideas
Jens

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.databases


csiph-web