Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ViTqS-0000Xs-9W for pgsql-jdbc@arkaria.postgresql.org; Mon, 18 Nov 2013 18:46:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1ViTqR-0004zH-Ib for pgsql-jdbc@arkaria.postgresql.org; Mon, 18 Nov 2013 18:46:47 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ViTqQ-0004yy-Ii for pgsql-jdbc@postgresql.org; Mon, 18 Nov 2013 18:46:46 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ViTqI-0000eA-MD for pgsql-jdbc@postgresql.org; Mon, 18 Nov 2013 18:46:45 +0000 Received: from [192.168.157.132] (unknown [65.19.243.151]) by outbound.vnet-inc.com (Postfix) with ESMTP id 6D4587CDF for ; Mon, 18 Nov 2013 11:45:37 -0700 (MST) Message-ID: <528A5F6A.8030508@ttc-cmc.net> Date: Mon, 18 Nov 2013 11:41:46 -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: PostgreSQL JDBC Subject: Re: preparedStatement, Batch, DEFAULT, getGeneratedKeys() 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 Martin Eriksson wrote: > Hi, > > I've been scourging the mailing list for a while and general > google/stack overflow looking for a solution dealing with JDBC, and > batching.. > > 2. I've been searching and searching for a way to set "DEFAULT" on a > prepared statement, is it even possible? e.g. "INSERT INTO a (id) > VALUES (?) and then doing something like > prepStatment.setInt(1,"DEFAULT"); I have found no way of doing > this... when doing big batches that would be very nice indeed.... > to not having to split everything depending on the existence of > data in default fields > > Cheers > Martin > Hello Martin, With regard to 2. Some databases do allow you to insert default in the prepared statement, but I have not found that to be the case with PostgreSQL to my knowledge. Default can be inserted though via the following. Given: CREATE TABLE "keY_tAble2" ( "Host" char(60) NOT NULL default '', "Db" char(64) NOT NULL default '', "Username" char(16) NOT NULL default '', Select_priv boolean NOT NULL default TRUE, PRIMARY KEY ("Host","Db","Username") ); To give the default value to "Host" Use the following prepared statement. INSERT INTO "public"."keY_tAble2" ("Db", "Username", "select_priv") VALUES (?, ?, ?) I guess as you said though this does not help with batching. danap. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc