Veröffentlicht 30. Oktober 200123 j Hi Ich hab ein Problem mit dem einfügen eines Wertes in eine Datenbank (In ein Feld mit dem Typ Clob)! Mein Code sieht so aus: <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Zitat:</font><HR> try { Connection con = null; Statement stmt = null; ResultSet rs = null; con = pool.getConnection(); if (DEBUG) System.out.println("con :" + con); stmt = con.createStatement(); if (DEBUG) System.out.println("stmt :" + stmt); //Initialisierung des Clobs CLOB clob = null; stmt.execute("SELECT text from helptext"); rs = stmt.getResultSet(); while (rs.next()) { clob = ((OracleResultSet)rs).getCLOB("text"); } //ERROR (ORA-22920) == The row containing the LOB value must be locked before updating the LOB value OracleCallableStatement cstmt = (OracleCallableStatement) con.prepareCall ("BEGIN DBMS_LOB.OPEN(" + " ?, DBMS_LOB.LOB_READWRITE); END;"); cstmt.setCLOB(1, clob); cstmt.execute(); String s = this.text; // some Unicode character data java.io.Writer wr = clob.getCharacterOutputStream(); //Write the input stream containing your ASCII data to the output stream. The write operation is finalized when you call the flush() method on the OutputStream object. char[] b = s.toCharArray(); // converts 's' to a character array wr.write(; wr.flush(); //Clean up: cstmt = (OracleCallableStatement) con.prepareCall ("BEGIN DBMS_LOB.CLOSE(?); END;"); cstmt.setCLOB(1, clob); cstmt.execute(); wr.close(); stmt.close(); con.close(); } catch (SQLException sqle) { if (DEBUG) sqle.printStackTrace(); System.err.println("SQL Exception :" + sqle); } catch (Exception e) { if (DEBUG) e.printStackTrace(); System.err.println("Exception :" + e); }
2. November 200123 j Hallo Backup-Verschläfer, ich habe zwar keine Ahnung was ein clob oder lob ist, aber die Fehlermeldung : [exec] java.sql.SQLException: ORA-22292: Cannot open a LOB in read-write mode without a transaction [exec] ORA-06512: at "SYS.DBMS_LOB", line 599 [exec] ORA-06512: at line 1 sagt mir, soweit ich das beurteilen kann, daß Du diesen Wert nur dann editieren darfst, wenn du den "Locken " tust. That means, wie auch schon die Fehlermeldung es andeutet, du musst deinen Zugriff, eigentlich wie alle Datenbankzugriffe, in eine Transaktion packen: Gibt so nette Methoden wie beginTransaction(); endTransactin(); ... Schau mal in die Doku Mfg
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.