Account for NULL types in queries
Also fixed a variable that may have been creating redundant connections
This commit is contained in:
parent
d8905f6914
commit
90527ad370
@ -28,7 +28,8 @@ public class DatabaseProvider {
|
|||||||
SQLiteConnectionPoolDataSource dataSource = new SQLiteConnectionPoolDataSource();
|
SQLiteConnectionPoolDataSource dataSource = new SQLiteConnectionPoolDataSource();
|
||||||
dataSource.setDatabaseName(DB_NAME);
|
dataSource.setDatabaseName(DB_NAME);
|
||||||
dataSource.setUrl(DB_ADDR);
|
dataSource.setUrl(DB_ADDR);
|
||||||
return dataSource.getConnection();
|
c = dataSource.getConnection();
|
||||||
|
return c;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Could not connect to database, double check config values");
|
System.out.println("Could not connect to database, double check config values");
|
||||||
@ -58,6 +59,8 @@ public class DatabaseProvider {
|
|||||||
}
|
}
|
||||||
else if (p instanceof Timestamp) {
|
else if (p instanceof Timestamp) {
|
||||||
query.setTimestamp(index, (Timestamp) p);
|
query.setTimestamp(index, (Timestamp) p);
|
||||||
|
} else if (p == null) {
|
||||||
|
query.setNull(index, Types.NULL);
|
||||||
} else {
|
} else {
|
||||||
throw new UnknownParameterException(p, index);
|
throw new UnknownParameterException(p, index);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user