Thread: JDBC Driver Munging My Text?

JDBC Driver Munging My Text?

From
Hunter Hillegas
Date:
We are seeing some strange behavior in our system that uses Postgres 7.1.3
and JDBC. System: Red Hat Linux 7.1/Intel.

Basically what we are seeing is that text stored in a VARCHAR is entered
like this: "hello, how are you" is stored like this: "hello ,how are you".
Notice the space and comma being transposed...

The plot thickens...

This is on a new server. The old server, also running 7.1.3, though built
quite a long time ago, does not exhibit this behavior.

Any ideas? Known bug? Strange config? It is possible that I built the JDBC
driver on the old machine and just copied it to the new machine... I can't
remember but it shouldn't matter, should it?

Thanks,
Hunter


Re: JDBC Driver Munging My Text?

From
"Nick Fankhauser"
Date:

> Basically what we are seeing is that text stored in a VARCHAR is entered
> like this: "hello, how are you" is stored like this: "hello ,how are you".
> Notice the space and comma being transposed...

No ideas to fix it, but I can add the info that it has never happened to me
using the jdbc7.1-1.1.jar or  jdbc7.1-1.2.jar driver files. We have one
field, "full name" in our db that is of the format "Smith, Joe", so I think
I'd have experienced the problem if it exists in our system. (Debian 2.4,
PGSQL 7.1.3, IBM Java 2 compiler & vm)

I'd suggest downloading one of the precompiled jar files & dropping them
into your misbehaving new server, just to eliminate any possibility that the
build is involved (though I can't see how it could be...) The precompiled
drivers live at: http://jdbc.postgresql.org/download.html

-Nick

--------------------------------------------------------------------------
Nick Fankhauser  nickf@ontko.com  Phone 1.765.935.4283  Fax 1.765.962.9788
Ray Ontko & Co.     Software Consulting Services     http://www.ontko.com/


Re: JDBC Driver Munging My Text?

From
"Dave Cramer"
Date:
Hunter,

Can you provide the insert statement that inserts this

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hunter Hillegas
Sent: Thursday, December 20, 2001 11:45 AM
To: PostgreSQL; Postgre JDBC
Subject: [JDBC] JDBC Driver Munging My Text?


We are seeing some strange behavior in our system that uses Postgres
7.1.3 and JDBC. System: Red Hat Linux 7.1/Intel.

Basically what we are seeing is that text stored in a VARCHAR is entered
like this: "hello, how are you" is stored like this: "hello ,how are
you". Notice the space and comma being transposed...

The plot thickens...

This is on a new server. The old server, also running 7.1.3, though
built quite a long time ago, does not exhibit this behavior.

Any ideas? Known bug? Strange config? It is possible that I built the
JDBC driver on the old machine and just copied it to the new machine...
I can't remember but it shouldn't matter, should it?

Thanks,
Hunter


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Re: JDBC Driver Munging My Text?

From
Hunter Hillegas
Date:
Dave-

Here's where I am at now:

I have replicated it on another machine. This is leading me to think it
might be my app but I am very skeptical because this part of the app is very
simple. Anyway, I am adding a bunch of logging to try to figure out where
things are getting screwed up.

I'll report back here.

Thanks,
Hunter

> From: "Dave Cramer" <dave@fastcrypt.com>
> Organization: Fast Crypt
> Reply-To: <dave@fastcrypt.com>
> Date: Thu, 20 Dec 2001 22:59:26 -0500
> To: "'Hunter Hillegas'" <lists@lastonepicked.com>,
> <Dave@micro-automation.net>, "'Postgre JDBC'" <pgsql-jdbc@postgresql.org>
> Subject: RE: [JDBC] JDBC Driver Munging My Text?
>
> Hunter,
>
> There must be something else going on here. I would be very interested
> if rebuilding the driver works. It shouldn't!
>
> You may want to try putting some logging statements in there to see what
> is going on. It is puzzling. The fact that you can only replicate it on
> one machine is troublesome
>
> Dave
>
> -----Original Message-----
> From: Hunter Hillegas [mailto:lists@lastonepicked.com]
> Sent: Thursday, December 20, 2001 10:50 PM
> To: Dave@micro-automation.net; Postgre JDBC
> Subject: Re: [JDBC] JDBC Driver Munging My Text?
>
>
> Sure!
>
> This is what I am using:
>
> //do the database action
> PreparedStatement pst = con.prepareStatement("insert into news (rec_num,
> title, body, lead_in, location, source, display_order, date_of_entry,
> entered_by, active_status) values (nextval('news_seq'), ?, ?, ?, ?, ?,
> ?, ?, ?, ?)");
>
> pst.clearParameters();
> pst.setString(1, request.getParameter("title")); pst.setString(2,
> request.getParameter("body")); pst.setString(3,
> request.getParameter("lead_in")); pst.setString(4,
> request.getParameter("location"));
> pst.setString(5, request.getParameter("source")); pst.setString(6,
> displayOrderID); pst.setString(7, "NOW()"); pst.setString(8,
> theUserBean.getRecNum()); pst.setString(9,
> request.getParameter("active_status"));
> pst.executeUpdate();
> pst = null;
>
> That inserts into the table as defined below... I'm only able to
> replicate the problem on one machine... I think I am going to try to
> rebuild the driver on the machine itself, to see if that helps.
>
> Hunter
>
>> From: "Dave Cramer" <Dave@micro-automation.net>
>> Organization: Micro Automation Inc
>> Reply-To: <Dave@micro-automation.net>
>> Date: Thu, 20 Dec 2001 20:19:10 -0500
>> To: "'Hunter Hillegas'" <lists@lastonepicked.com>, "'Postgre JDBC'"
>> <pgsql-jdbc@postgresql.org>
>> Subject: RE: [JDBC] JDBC Driver Munging My Text?
>>
>> Hunter,
>>
>> I was unable to replicate the problem. Would it be possible for you to
>
>> send a small piece of code that does replicate it?
>>
>> Here is the code I tried with
>>
>>     PreparedStatement pstmt = con.prepareStatement("insert into
>> testcomma (id,info,info2,num) values
>> (nextval('testcomma_id_seq'),?,?,?)");
>>     pstmt.setString(1,"hello, how are you");
>>     pstmt.setString(2,"how are you, today");
>>     pstmt.setInt(3,1);
>> pstmt.execute()
>>
>> My table looks like this
>>
>> create table testcomma (id serial,info text, info2 text,num int);
>>
>> Dave
>>
>> -----Original Message-----
>> From: pgsql-jdbc-owner@postgresql.org
>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hunter Hillegas
>> Sent: Thursday, December 20, 2001 2:38 PM
>> To: Postgre JDBC
>> Subject: FW: [JDBC] JDBC Driver Munging My Text?
>>
>>
>> Forgot to add the list...
>>
>>
>> ------ Forwarded Message
>> From: Hunter Hillegas <lists@lastonepicked.com>
>> Date: Thu, 20 Dec 2001 09:54:41 -0800
>> To: <Dave@micro-automation.net>
>> Subject: Re: [JDBC] JDBC Driver Munging My Text?
>>
>> Sure...
>>
>> The Java code is like this:
>>
>> pst = con.prepareStatement("insert into news (rec_num, title, body,
>> lead_in, location, source, display_order, date_of_entry, entered_by,
>> active_status) values (nextval('news_seq'), ?, ?, ?, ?, ?, ?, ?, ?,
>> ?)");
>>
>> The news table looks like this:
>>
>> CREATE TABLE news (
>>   rec_num integer NOT NULL PRIMARY KEY,
>>   title varchar(255),
>>   body text,
>>   lead_in text,
>>   location varchar(255),
>>   source varchar(255),
>>   display_order integer,
>>   date_of_entry date,
>>   entered_by integer REFERENCES users,
>>   active_status boolean
>> );
>>
>>> From: "Dave Cramer" <Dave@micro-automation.net>
>>> Organization: Micro Automation Inc
>>> Reply-To: <Dave@micro-automation.net>
>>> Date: Thu, 20 Dec 2001 12:52:08 -0500
>>> To: "'Hunter Hillegas'" <lists@lastonepicked.com>, "'PostgreSQL'"
>>> <pgsql-general@postgresql.org>, "'Postgre JDBC'"
>>> <pgsql-jdbc@postgresql.org>
>>> Subject: RE: [JDBC] JDBC Driver Munging My Text?
>>>
>>> Hunter,
>>>
>>> Can you provide the insert statement that inserts this
>>>
>>> Dave
>>>
>>> -----Original Message-----
>>> From: pgsql-jdbc-owner@postgresql.org
>>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hunter Hillegas
>>> Sent: Thursday, December 20, 2001 11:45 AM
>>> To: PostgreSQL; Postgre JDBC
>>> Subject: [JDBC] JDBC Driver Munging My Text?
>>>
>>>
>>> We are seeing some strange behavior in our system that uses Postgres
>>> 7.1.3 and JDBC. System: Red Hat Linux 7.1/Intel.
>>>
>>> Basically what we are seeing is that text stored in a VARCHAR is
>>> entered like this: "hello, how are you" is stored like this: "hello
>>> ,how are you". Notice the space and comma being transposed...
>>>
>>> The plot thickens...
>>>
>>> This is on a new server. The old server, also running 7.1.3, though
>>> built quite a long time ago, does not exhibit this behavior.
>>>
>>> Any ideas? Known bug? Strange config? It is possible that I built the
>
>>> JDBC driver on the old machine and just copied it to the new
>>> machine... I can't remember but it shouldn't matter, should it?
>>>
>>> Thanks,
>>> Hunter
>>>
>>>
>>> ---------------------------(end of
>>> broadcast)---------------------------
>>> TIP 6: Have you searched our list archives?
>>>
>>> http://archives.postgresql.org
>>>
>>
>> ------ End of Forwarded Message
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 5: Have you checked our extensive FAQ?
>>
>> http://www.postgresql.org/users-lounge/docs/faq.html
>>
>


Re: JDBC Driver Munging My Text?

From
Hunter Hillegas
Date:
I have found that it was a bug in my Servlet container, not my code or
PostgreSQL.

Sorry to trouble y'all.


> From: "Dave Cramer" <dave@fastcrypt.com>
> Organization: Fast Crypt
> Reply-To: <dave@fastcrypt.com>
> Date: Thu, 20 Dec 2001 22:59:26 -0500
> To: "'Hunter Hillegas'" <lists@lastonepicked.com>,
> <Dave@micro-automation.net>, "'Postgre JDBC'" <pgsql-jdbc@postgresql.org>
> Subject: RE: [JDBC] JDBC Driver Munging My Text?
>
> Hunter,
>
> There must be something else going on here. I would be very interested
> if rebuilding the driver works. It shouldn't!
>
> You may want to try putting some logging statements in there to see what
> is going on. It is puzzling. The fact that you can only replicate it on
> one machine is troublesome
>
> Dave
>
> -----Original Message-----
> From: Hunter Hillegas [mailto:lists@lastonepicked.com]
> Sent: Thursday, December 20, 2001 10:50 PM
> To: Dave@micro-automation.net; Postgre JDBC
> Subject: Re: [JDBC] JDBC Driver Munging My Text?
>
>
> Sure!
>
> This is what I am using:
>
> //do the database action
> PreparedStatement pst = con.prepareStatement("insert into news (rec_num,
> title, body, lead_in, location, source, display_order, date_of_entry,
> entered_by, active_status) values (nextval('news_seq'), ?, ?, ?, ?, ?,
> ?, ?, ?, ?)");
>
> pst.clearParameters();
> pst.setString(1, request.getParameter("title")); pst.setString(2,
> request.getParameter("body")); pst.setString(3,
> request.getParameter("lead_in")); pst.setString(4,
> request.getParameter("location"));
> pst.setString(5, request.getParameter("source")); pst.setString(6,
> displayOrderID); pst.setString(7, "NOW()"); pst.setString(8,
> theUserBean.getRecNum()); pst.setString(9,
> request.getParameter("active_status"));
> pst.executeUpdate();
> pst = null;
>
> That inserts into the table as defined below... I'm only able to
> replicate the problem on one machine... I think I am going to try to
> rebuild the driver on the machine itself, to see if that helps.
>
> Hunter
>
>> From: "Dave Cramer" <Dave@micro-automation.net>
>> Organization: Micro Automation Inc
>> Reply-To: <Dave@micro-automation.net>
>> Date: Thu, 20 Dec 2001 20:19:10 -0500
>> To: "'Hunter Hillegas'" <lists@lastonepicked.com>, "'Postgre JDBC'"
>> <pgsql-jdbc@postgresql.org>
>> Subject: RE: [JDBC] JDBC Driver Munging My Text?
>>
>> Hunter,
>>
>> I was unable to replicate the problem. Would it be possible for you to
>
>> send a small piece of code that does replicate it?
>>
>> Here is the code I tried with
>>
>>     PreparedStatement pstmt = con.prepareStatement("insert into
>> testcomma (id,info,info2,num) values
>> (nextval('testcomma_id_seq'),?,?,?)");
>>     pstmt.setString(1,"hello, how are you");
>>     pstmt.setString(2,"how are you, today");
>>     pstmt.setInt(3,1);
>> pstmt.execute()
>>
>> My table looks like this
>>
>> create table testcomma (id serial,info text, info2 text,num int);
>>
>> Dave
>>
>> -----Original Message-----
>> From: pgsql-jdbc-owner@postgresql.org
>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hunter Hillegas
>> Sent: Thursday, December 20, 2001 2:38 PM
>> To: Postgre JDBC
>> Subject: FW: [JDBC] JDBC Driver Munging My Text?
>>
>>
>> Forgot to add the list...
>>
>>
>> ------ Forwarded Message
>> From: Hunter Hillegas <lists@lastonepicked.com>
>> Date: Thu, 20 Dec 2001 09:54:41 -0800
>> To: <Dave@micro-automation.net>
>> Subject: Re: [JDBC] JDBC Driver Munging My Text?
>>
>> Sure...
>>
>> The Java code is like this:
>>
>> pst = con.prepareStatement("insert into news (rec_num, title, body,
>> lead_in, location, source, display_order, date_of_entry, entered_by,
>> active_status) values (nextval('news_seq'), ?, ?, ?, ?, ?, ?, ?, ?,
>> ?)");
>>
>> The news table looks like this:
>>
>> CREATE TABLE news (
>>   rec_num integer NOT NULL PRIMARY KEY,
>>   title varchar(255),
>>   body text,
>>   lead_in text,
>>   location varchar(255),
>>   source varchar(255),
>>   display_order integer,
>>   date_of_entry date,
>>   entered_by integer REFERENCES users,
>>   active_status boolean
>> );
>>
>>> From: "Dave Cramer" <Dave@micro-automation.net>
>>> Organization: Micro Automation Inc
>>> Reply-To: <Dave@micro-automation.net>
>>> Date: Thu, 20 Dec 2001 12:52:08 -0500
>>> To: "'Hunter Hillegas'" <lists@lastonepicked.com>, "'PostgreSQL'"
>>> <pgsql-general@postgresql.org>, "'Postgre JDBC'"
>>> <pgsql-jdbc@postgresql.org>
>>> Subject: RE: [JDBC] JDBC Driver Munging My Text?
>>>
>>> Hunter,
>>>
>>> Can you provide the insert statement that inserts this
>>>
>>> Dave
>>>
>>> -----Original Message-----
>>> From: pgsql-jdbc-owner@postgresql.org
>>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hunter Hillegas
>>> Sent: Thursday, December 20, 2001 11:45 AM
>>> To: PostgreSQL; Postgre JDBC
>>> Subject: [JDBC] JDBC Driver Munging My Text?
>>>
>>>
>>> We are seeing some strange behavior in our system that uses Postgres
>>> 7.1.3 and JDBC. System: Red Hat Linux 7.1/Intel.
>>>
>>> Basically what we are seeing is that text stored in a VARCHAR is
>>> entered like this: "hello, how are you" is stored like this: "hello
>>> ,how are you". Notice the space and comma being transposed...
>>>
>>> The plot thickens...
>>>
>>> This is on a new server. The old server, also running 7.1.3, though
>>> built quite a long time ago, does not exhibit this behavior.
>>>
>>> Any ideas? Known bug? Strange config? It is possible that I built the
>
>>> JDBC driver on the old machine and just copied it to the new
>>> machine... I can't remember but it shouldn't matter, should it?
>>>
>>> Thanks,
>>> Hunter
>>>
>>>
>>> ---------------------------(end of
>>> broadcast)---------------------------
>>> TIP 6: Have you searched our list archives?
>>>
>>> http://archives.postgresql.org
>>>
>>
>> ------ End of Forwarded Message
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 5: Have you checked our extensive FAQ?
>>
>> http://www.postgresql.org/users-lounge/docs/faq.html
>>
>