Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Td4SJ-0008MX-KM for pgsql-jdbc@arkaria.postgresql.org; Mon, 26 Nov 2012 19:34:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Td4SI-0001df-LQ for pgsql-jdbc@arkaria.postgresql.org; Mon, 26 Nov 2012 19:34:58 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Td4SH-0001dZ-Ly for pgsql-jdbc@postgresql.org; Mon, 26 Nov 2012 19:34:57 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Td4S9-0001TZ-Hf for pgsql-jdbc@postgresql.org; Mon, 26 Nov 2012 19:34:56 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 0BACD5A83; Mon, 26 Nov 2012 12:34:48 -0700 (MST) Message-ID: <50B3C130.2050400@ttc-cmc.net> Date: Mon, 26 Nov 2012 12:21:20 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Ermengol Bota , pgsql-jdbc@postgresql.org Subject: Re: Problems with BIT datatype and preparedStatment References: <866187325.381425.1353953148394.JavaMail.root@vilafranca> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Ermengol Bota wrote: > 2012/11/26 dmp > > > Hello, > > A search of the forum may turn up a better answer, but: > > > I searched "the web" :-D and I just found the code below that it's > supposed to work. I thought that the patch sended was included "by > default" in newer jdbc versions... > > http://archives.postgresql.__org/pgsql-patches/2003-06/__msg00402.php > > > btw, which forum do you refer? This forum, jdbc.postgresql. The search you turned up for the example given appears to be from the server forum. The patch you refer to: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java,v seems to be for the server not the JDBC code. It is also very old, 2003, while might have worked then does not now it appear. There has many changes I suspect in the last 8,9 years. > So the first problem with your execution above is you have tried to > insert a PostgreSQL boolean type into a defined PostgreSQL bit type. > You definition is actually by default bit(1), it could have been > bit(2) has the example bit2_type above. Can not use setBoolean() with > bit type in the way you have tried. > > The one way that it can be done has I have seen before would be to > do a CAST. > > pstmt = con.prepareStatement("INSERT INTO jdbc_demo VALUES (?::bit)"); > pstmt.setString(1, "1"); > > > This way works! great :-) > > I'm not used to do cast conversion on the prepareStatement definition, > thank you for the clue! > > Now I see that I didn't understand the hint at the error message "Hint: > You will need to rewrite or cast the expression." > > Thanks a lot. The documentation http://www.postgresql.org/files/documentation/pdf/9.2/postgresql-9.2-A4.pdf I think chapter 8 discusses data types in PostgreSQL. The manual is your friend. danap. > -- > * Ermengol * > ************************************************* > * Els ordinadors no resolen problemes, * > * simplement executen solucions * > ************************************************* -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc