Skip to content

Commit d261a5e

Browse files
author
Peter Mount
committed
Transactions in ImageViewer
1 parent 21e0321 commit d261a5e

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(SQLException ex) {
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(SQLException ex) {
380387
label.setText(ex.toString());

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy