X-Original-To: pgsql-jdbc@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AD1C3474E42 for ; Wed, 23 Apr 2003 23:07:58 -0400 (EDT) Received: from sm204.163.com (unknown [202.108.44.204]) by postgresql.org (Postfix) with ESMTP id 50BAE475E4D for ; Wed, 23 Apr 2003 23:07:47 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by sm204.163.com (Postfix) with SMTP id C208D1C462B51 for ; Thu, 24 Apr 2003 11:07:42 +0800 (CST) Received: from 192.168.0.80 (unknown [218.247.247.226]) by 192.168.1.204 (Coremail:www.163.com) with SMTP id zQcAAP1Upz6KLPfi.1 for ; Thu, 24 Apr 2003 11:07:42 +0800 (CST) From: "milimeter@163.com" Reply-To: milimeter@163.com Organization: milimeter@163.com To: pgsql-jdbc@postgresql.org Subject: Re: jdbc problem Date: Thu, 24 Apr 2003 11:06:30 +0800 User-Agent: KMail/1.5 References: <200304241020.54649."milimeter@163.com"> <3EA750E7.5040503@xythos.com> In-Reply-To: <3EA750E7.5040503@xythos.com> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200304241106.16523."milimeter@163.com"> Content-Type: text/plain; charset="gb18030" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-9.4 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,RCVD_IN_OSIRUSOFT_COM, RCVD_IN_RFCI,RCVD_IN_SBL,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/215 X-Sequence-Number: 7054 Thank you, Barry You know, I have to work with oracle and postgresql at the same time now.= In=20 company, I have to use oracle, and at home, I will use postgresql to develo= p=20 application. So I hope my java codes can work anywhere (other coworker only= =20 use oracle, so I have to adapt all postgresql features to be fit to oracle). Now, someone wrote a code line as: ResultSet rs =3D ..... int age =3D rs.getInt("age"); //here, feild "age" is a char(4) type The above codes can work well on oracle jdbc driver, but on postgresql, n= ot=20 work, because if age is 20, then in database it's "20 " but no "20". The= =20 reason is that jdbc driver of oracle automaticlly trim the returned result= =20 string; but postgresql not. There's so many places in codes of my company= =20 where get an integer from a char(...) feild, I can't change them all. So I= =20 hope jdbc driver of postgresql can also do it. Another problem when programming jdbc codes: "INSERT INTO person VALUES ('100')" //here, the field is an integer, bu= t I=20 insert as a string The above SQL can work well on both oracle and postgresql, but: "INSERT INTO person VALUES ('')" can work only on oracle but not work on postgresql. On oracle, a default= =20 value will be inserted, but postgresql will report an error. I hope I have expressed myself clearly. If I can't, it's my fault. Thank you very much, mili =D4=DA =D0=C7=C6=DA=CB=C4 24 =CB=C4=D4=C2 2003 10:50=A3=AC=C4=FA=D0=B4=B5= =C0=A3=BA > Mili, > > I don't understand your issues. Can you explain them in a bit more > detail? Perhaps with code examples? > > thanks, > --Barry > > milimeter@163.com wrote: > > Hi, all > > > > I have a table: CREATE TABLE person (age char(4)) > > After executing "select age from person" with jdbc, I extract the > > value with: > > getInt("age") > > Now is the problem, the same code can succeed on oracle, but on > > postgresql, because of not triming space automaticlly, it cause an erro= r. > > > > So, I hope the newest jdbc driver for postgresql can automaticlly > > trim space just like oracle. The same problem also exists when execute > > insert: Provided "age" is an integer, then "insert into person values > > ('30')" can be executed correctly, but "insert into person values ('')" > > can not. On oracle, a default value will be added. So jdbc driver for > > postgresql should also do it. > > > > Yours, > > mili > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster