Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

[no subject]



--=20
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.1/355 - Release Date: 6/2/2006
=20

------_=_NextPart_001_01C68858.E628ABC4
Content-Type: text/html;
	charset="Windows-1251"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dwindows-1251">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.2900.2873" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D244144712-02062006>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D244144712-02062006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D244144712-02062006>am =
actually using=20
postgres8.1.4 and JDBC driver 8.1-4.0.7. With this am&nbsp;having a =
problem with=20
database encoding. </SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D244144712-02062006>I've =
created a db=20
with encoding&nbsp;LATIN1 and having problem when inserting for example =
the euro=20
character '=88' in my db</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D244144712-02062006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D244144712-02062006>After =
search the=20
jdbc doc I found the following:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D244144712-02062006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><SPAN class=3D244144712-02062006>
<DT><FONT color=3D#0000ff><FONT size=3D2><SPAN class=3Dterm><CODE=20
class=3Dvarname>charSet</CODE> =3D <SPAN =
class=3Dtype>String</SPAN></SPAN>=20
</FONT></FONT>
<DD>
<P><FONT color=3D#0000ff size=3D2>The character set to use for data sent =
to the=20
database or recieved from the database. This property is only relevent =
for=20
server versions less than or equal to 7.2. The 7.3 release was the first =
with=20
multibyte support compiled by default and the driver uses its character =
set=20
translation facilities instead of trying to do it itself. </FONT></P>
<DT><FONT color=3D#0000ff><FONT size=3D2><SPAN class=3Dterm><CODE=20
class=3Dvarname>allowEncodingChanges</CODE> =3D <SPAN=20
class=3Dtype>boolean</SPAN></SPAN> </FONT></FONT>
<DD>
<P><FONT color=3D#0000ff><FONT size=3D2>When using the V3 protocol the =
driver=20
monitors changes in certain server configuration parameters that should =
not be=20
touched by end users. The <CODE class=3Dliteral>client_encoding</CODE> =
setting is=20
set by the driver and should not be altered<SPAN=20
class=3D244144712-02062006>..............</SPAN></FONT></FONT></P></SPAN>=
</FONT></DD></DIV>
<DIV><SPAN class=3D244144712-02062006><FONT =
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D244144712-02062006><FONT size=3D2>Now I've downloaded =
the source=20
code of the JDBC driver and in the class 'ConnectionFactoryImpl.java' I =
found=20
this:</FONT></SPAN></DIV>
<DIV><SPAN class=3D244144712-02062006><FONT =
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D244144712-02062006><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT><FONT =
color=3D#0000ff=20
size=3D2>if (dbVersion.compareTo("7.3") &gt;=3D=20
0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
// set=20
encoding to be unicode; set datestyle; ensure autocommit is=20
on<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
//=20
(no-op on 7.4, but might be needed under=20
7.3)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; //=20
The begin/commit is to avoid leaving a transaction open if we're talking =
to=20
a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
// 7.3=20
server that defaults to autocommit =3D off.</FONT></SPAN></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff size=3D2><SPAN=20
class=3D244144712-02062006>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
if=20
(Driver.logDebug)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Driver.debug("Switching to UNICODE =
client_encoding");</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff size=3D2><SPAN=20
class=3D244144712-02062006>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
runSetupQuery(protoConnection, "begin; set autocommit =3D on; set =
client_encoding=20
=3D 'UNICODE'; commit",=20
false);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;=20
protoConnection.setEncoding(Encoding.getDatabaseEncoding("UNICODE"));<BR>=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
String=20
dbEncoding =3D (results[1] =3D=3D null ? null :=20
protoConnection.getEncoding().decode(results[1]));<BR>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
if=20
(Driver.logDebug)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
Driver.debug("Specified charset:&nbsp; " +=20
charSet);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Driver.debug("Database encoding: " +=20
dbEncoding);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
}</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff size=3D2><SPAN=20
class=3D244144712-02062006>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
if (charSet !=3D=20
null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
// Explicitly specified=20
encoding.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
protoConnection.setEncoding(Encoding.getJVMEncoding(charSet));<BR>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
else if=20
(dbEncoding !=3D=20
null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
// Use database-supplied=20
encoding.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
protoConnection.setEncoding(Encoding.getDatabaseEncoding(dbEncoding));<BR=
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
// Fall back to=20
defaults.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
// XXX is this ever=20
reached?<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
protoConnection.setEncoding(Encoding.defaultEncoding());<BR>&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</SPAN></FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#0000ff><SPAN=20
class=3D244144712-02062006><BR>&nbsp;</DIV></SPAN></FONT>
<DIV><SPAN class=3D244144712-02062006><FONT size=3D2>From the code I =
found that if=20
my postgresql version is above or equal to&nbsp;7.3, the encoding is =
FORCED to=20
'UNICODE', else the encoding is the database =
encoding.</FONT></SPAN></DIV>
<DIV><SPAN class=3D244144712-02062006><FONT size=3D2>Why it is like =
this&nbsp;and=20
how can I set the client_encoding to LATIN1<SPAN =
class=3D400493004-05062006> or is=20
there a way so that I can insert the euro character without havin =
encoding=20
problem</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=3D244144712-02062006><FONT =
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D244144712-02062006><FONT size=3D2>thanks in=20
advance</FONT></SPAN></DIV>
<DIV><SPAN class=3D244144712-02062006><FONT =
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D244144712-02062006><FONT=20
size=3D2>gulshan</FONT></DIV></SPAN></FONT></DIV></BODY></HTML>
<BR>

<P><FONT SIZE=3D2>--<BR>
No virus found in this outgoing message.<BR>
Checked by AVG Free Edition.<BR>
Version: 7.1.394 / Virus Database: 268.8.1/355 - Release Date: =
6/2/2006<BR>
</FONT> </P>

------_=_NextPart_001_01C68858.E628ABC4--



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group