Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem mit einfügen einer Datenbank über Java!

Empfohlene Antworten

Veröffentlicht

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(B);

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);

}

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.