From 8713e81887e1adf622d67f25cc62fa8c7872a126 Mon Sep 17 00:00:00 2001 From: akwizgran <akwizgran@users.sourceforge.net> Date: Wed, 19 Oct 2011 12:48:34 +0100 Subject: [PATCH] Use ZERO() to initialise columns where appropriate. --- components/net/sf/briar/db/JdbcDatabase.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/components/net/sf/briar/db/JdbcDatabase.java b/components/net/sf/briar/db/JdbcDatabase.java index df59f88b23..d68fccfe72 100644 --- a/components/net/sf/briar/db/JdbcDatabase.java +++ b/components/net/sf/briar/db/JdbcDatabase.java @@ -514,29 +514,24 @@ abstract class JdbcDatabase implements Database<Connection> { // Initialise the subscription timestamps sql = "INSERT INTO subscriptionTimestamps" + " (contactId, sent, received, modified)" - + " VALUES (?, ?, ?, ?)"; + + " VALUES (?, ZERO(), ZERO(), ZERO())"; ps = txn.prepareStatement(sql); ps.setInt(1, c.getInt()); - ps.setLong(2, 0L); - ps.setLong(3, 0L); - ps.setLong(4, 1L); affected = ps.executeUpdate(); if(affected != 1) throw new DbStateException(); ps.close(); // Initialise the transport timestamps sql = "INSERT INTO transportTimestamps" + " (contactId, sent, received, modified)" - + " VALUES (?, ?, ?, ?)"; + + " VALUES (?, ZERO(), ZERO(), ZERO())"; ps = txn.prepareStatement(sql); ps.setInt(1, c.getInt()); - ps.setLong(2, 0L); - ps.setLong(3, 0L); - ps.setLong(4, 1L); affected = ps.executeUpdate(); if(affected != 1) throw new DbStateException(); ps.close(); return c; } catch(SQLException e) { + tryToClose(rs); tryToClose(ps); throw new DbException(e); } @@ -871,13 +866,10 @@ abstract class JdbcDatabase implements Database<Connection> { ps.close(); sql = "INSERT INTO connectionWindows" + " (contactId, transportId, centre, bitmap, outgoing)" - + " VALUES(?, ?, ?, ?, ?)"; + + " VALUES(?, ?, ZERO(), ZERO(), ZERO())"; ps = txn.prepareStatement(sql); ps.setInt(1, c.getInt()); ps.setInt(2, t.getInt()); - ps.setLong(3, 0L); - ps.setInt(4, 0); - ps.setLong(5, 0L); int affected = ps.executeUpdate(); if(affected != 1) throw new DbStateException(); ps.close(); @@ -1854,13 +1846,12 @@ abstract class JdbcDatabase implements Database<Connection> { ps.close(); sql = "INSERT INTO connectionWindows" + " (contactId, transportId, centre, bitmap, outgoing)" - + " VALUES(?, ?, ?, ?, ?)"; + + " VALUES(?, ?, ?, ?, ZERO())"; ps = txn.prepareStatement(sql); ps.setInt(1, c.getInt()); ps.setInt(2, t.getInt()); ps.setLong(3, w.getCentre()); ps.setInt(4, w.getBitmap()); - ps.setLong(5, 0L); int affected = ps.executeUpdate(); if(affected != 1) throw new DbStateException(); ps.close(); -- GitLab