Received: from fep03-svc.swip.net (fep03.swip.net [130.244.199.131]) by hub.org (8.10.1/8.10.1) with ESMTP id e8S9NQ740665 for ; Thu, 28 Sep 2000 05:23:26 -0400 (EDT) Received: from lysator.liu.se ([212.151.0.33]) by fep03-svc.swip.net (InterMail vM.5.01.01.01 201-252-104) with ESMTP id <20000928092320.KOCI24714.fep03-svc.swip.net@lysator.liu.se> for ; Thu, 28 Sep 2000 11:23:20 +0200 Message-ID: <39D30D7F.3259B35@lysator.liu.se> Date: Thu, 28 Sep 2000 11:21:03 +0200 From: Jens Carlberg X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Re: Newlines in String inserts with JDBC References: <39D28E41.B22FFB7C@toad.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200009/108 Ken Kachnowich wrote: > > Is there a method that could be used to insert Strings containing > newline charaters using the JDBC interface? I haven't tried this, but allow me to speculate: 1. If new-line isn't allowed as a char, it can't be done at all. Then you have to invent a mapping on your own. I would recommend "\n"; it's failrly standard. Note that this means you have to escape "\" too; I recommend "\\". 2. However, if new-line is allowed (and I suspect it is), it should probably be 'escaped' somehow. This might be database specific; your Java-code shouldn't be, though. To solve this, use the PreparedStatement class, and simply set the String: String aString = "Row 1: Before newline\nRow 2: After newline"; PreparedStatement aStmt = aConn.prepareStatement(); aStmt.setString(aString); This way, you delegate to the classes developed for this specific database to handle all issues specific to the database, as it should be. > Ken ///Jens Carlberg