mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Use ZERO() to initialise columns where appropriate.
This commit is contained in:
@@ -514,29 +514,24 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
// Initialise the subscription timestamps
|
// Initialise the subscription timestamps
|
||||||
sql = "INSERT INTO subscriptionTimestamps"
|
sql = "INSERT INTO subscriptionTimestamps"
|
||||||
+ " (contactId, sent, received, modified)"
|
+ " (contactId, sent, received, modified)"
|
||||||
+ " VALUES (?, ?, ?, ?)";
|
+ " VALUES (?, ZERO(), ZERO(), ZERO())";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setInt(1, c.getInt());
|
ps.setInt(1, c.getInt());
|
||||||
ps.setLong(2, 0L);
|
|
||||||
ps.setLong(3, 0L);
|
|
||||||
ps.setLong(4, 1L);
|
|
||||||
affected = ps.executeUpdate();
|
affected = ps.executeUpdate();
|
||||||
if(affected != 1) throw new DbStateException();
|
if(affected != 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
// Initialise the transport timestamps
|
// Initialise the transport timestamps
|
||||||
sql = "INSERT INTO transportTimestamps"
|
sql = "INSERT INTO transportTimestamps"
|
||||||
+ " (contactId, sent, received, modified)"
|
+ " (contactId, sent, received, modified)"
|
||||||
+ " VALUES (?, ?, ?, ?)";
|
+ " VALUES (?, ZERO(), ZERO(), ZERO())";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setInt(1, c.getInt());
|
ps.setInt(1, c.getInt());
|
||||||
ps.setLong(2, 0L);
|
|
||||||
ps.setLong(3, 0L);
|
|
||||||
ps.setLong(4, 1L);
|
|
||||||
affected = ps.executeUpdate();
|
affected = ps.executeUpdate();
|
||||||
if(affected != 1) throw new DbStateException();
|
if(affected != 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
return c;
|
return c;
|
||||||
} catch(SQLException e) {
|
} catch(SQLException e) {
|
||||||
|
tryToClose(rs);
|
||||||
tryToClose(ps);
|
tryToClose(ps);
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
@@ -871,13 +866,10 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ps.close();
|
ps.close();
|
||||||
sql = "INSERT INTO connectionWindows"
|
sql = "INSERT INTO connectionWindows"
|
||||||
+ " (contactId, transportId, centre, bitmap, outgoing)"
|
+ " (contactId, transportId, centre, bitmap, outgoing)"
|
||||||
+ " VALUES(?, ?, ?, ?, ?)";
|
+ " VALUES(?, ?, ZERO(), ZERO(), ZERO())";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setInt(1, c.getInt());
|
ps.setInt(1, c.getInt());
|
||||||
ps.setInt(2, t.getInt());
|
ps.setInt(2, t.getInt());
|
||||||
ps.setLong(3, 0L);
|
|
||||||
ps.setInt(4, 0);
|
|
||||||
ps.setLong(5, 0L);
|
|
||||||
int affected = ps.executeUpdate();
|
int affected = ps.executeUpdate();
|
||||||
if(affected != 1) throw new DbStateException();
|
if(affected != 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -1854,13 +1846,12 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ps.close();
|
ps.close();
|
||||||
sql = "INSERT INTO connectionWindows"
|
sql = "INSERT INTO connectionWindows"
|
||||||
+ " (contactId, transportId, centre, bitmap, outgoing)"
|
+ " (contactId, transportId, centre, bitmap, outgoing)"
|
||||||
+ " VALUES(?, ?, ?, ?, ?)";
|
+ " VALUES(?, ?, ?, ?, ZERO())";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setInt(1, c.getInt());
|
ps.setInt(1, c.getInt());
|
||||||
ps.setInt(2, t.getInt());
|
ps.setInt(2, t.getInt());
|
||||||
ps.setLong(3, w.getCentre());
|
ps.setLong(3, w.getCentre());
|
||||||
ps.setInt(4, w.getBitmap());
|
ps.setInt(4, w.getBitmap());
|
||||||
ps.setLong(5, 0L);
|
|
||||||
int affected = ps.executeUpdate();
|
int affected = ps.executeUpdate();
|
||||||
if(affected != 1) throw new DbStateException();
|
if(affected != 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user