|
|
Choosing A Webhost: |
Problem with LargeObject/jdbc when writing short (Repost): msg#00400db.postgresql.jdbc
Hi group, since my last mail made it through, I assume that the previous one just magically diappeared. Here it is again: I have a problem when trying to use the getInputStream()/getOutputStream() methods of LargeObject. The problem is demonstrated by the code I append to this post. There I create a LargeObject and put there all numbers from 100 to 2000 as shorts. Afterwards, I re-open this object by its oid, read itout and print it on the screen. The funny thing is that the program stops after writing the 127 on the screen. So, either the writing was silently stopping with number 128, or the reader creates a EOFException when the 8th bit was set. The Postgresql version is 7.2.2, the jdbc driver is jdbc7.1-1.2.jar, both directly from the SuSE 8.1 CD. What is the cause of that and what can I do to get a correct behaviour? Is it a bug or did I just not carefully read the manual? Ciao Ole This is the Code: ---------------------------------8<------------------------------------------ import java.io.*; import java.sql.*; import org.postgresql.largeobject.*; public class PgTest { public static void main (String[] args) { try { Class.forName("org.postgresql.Driver"); Connection dbConn = DriverManager.getConnection("jdbc:postgresql:ole", "ole", "nixda"); dbConn.setAutoCommit(false); LargeObjectManager lobjm = ((org.postgresql.Connection)dbConn).getLargeObjectAPI(); int oid = lobjm.create(LargeObjectManager.READ | LargeObjectManager.WRITE); System.out.println("Oid is " + oid); // *** 1st Step: write 1900 shorts *** LargeObject wobj = lobjm.open(oid, LargeObjectManager.WRITE); DataOutputStream dos = new DataOutputStream(wobj.getOutputStream()); for (short i = 100; i < 2000; i++) { dos.writeShort(i); } dos.close(); wobj.close(); dbConn.commit(); // *** 2nd Step: read these shorts back from the same OID *** LargeObject robj = lobjm.open(oid, LargeObjectManager.READ); DataInputStream is = new DataInputStream(robj.getInputStream()); try { while (true) { System.out.println(is.readShort()); } } catch (EOFException e) { System.out.println("End of file reached."); } robj.close(); } catch (Exception e) { e.printStackTrace(); } } } ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Another LargeObject problem, Ole Streicher |
|---|---|
| Next by Date: | Another exception (Transaction level), Ole Streicher |
| Previous by Thread: | Another LargeObject problem, Ole Streicher |
| Next by Thread: | Re: Problem with LargeObject/jdbc when writing short (Repost), Fernando Nasser |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |