Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd261a5e

Browse files
author
Peter Mount
committed
Transactions in ImageViewer
1 parent21e0321 commitd261a5e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

‎src/interfaces/jdbc/CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Tue May 18 07:00:00 BST 1999
2+
- Set the ImageViewer application to use transactions
3+
14
Tue May 18 00:00:00 BST 1999
25
- Just after committing, I realised why internationalisation isn't
36
working. This is now fixed (in the Makefile).

‎src/interfaces/jdbc/example/ImageViewer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ public void actionPerformed(ActionEvent e) {
192192
// Create a statement
193193
stat =db.createStatement();
194194

195+
// Set the connection to use transactions
196+
db.setAutoCommit(false);
197+
195198
// Also, get the LargeObjectManager for this connection
196199
lom = ((postgresql.Connection)db).getLargeObjectAPI();
197200

@@ -209,6 +212,7 @@ public void init()
209212
try {
210213
stat.executeUpdate("create table images (imgname name,imgoid oid)");
211214
label.setText("Initialised database");
215+
db.commit();
212216
}catch(SQLExceptionex) {
213217
label.setText(ex.toString());
214218
}
@@ -310,6 +314,7 @@ public void run() {
310314
// our own thread
311315
stat =db.createStatement();
312316
stat.executeUpdate("insert into images values ('"+name+"',"+oid+")");
317+
db.commit();
313318

314319
// Finally refresh the names list, and display the current image
315320
ImageViewer.this.refreshList();
@@ -372,9 +377,11 @@ public void removeImage()
372377

373378
// Finally delete any entries for that name
374379
stat.executeUpdate("delete from images where imgname='"+currentImage+"'");
380+
db.commit();
375381

376382
label.setText(currentImage+" deleted");
377383
currentImage=null;
384+
db.commit();
378385
refreshList();
379386
}catch(SQLExceptionex) {
380387
label.setText(ex.toString());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp