* Set connection readonly flag to true in executeRetrieval() and false in executeUpdate().
* Remove a few unneeded local variables.
This commit is contained in:
parent
a878d5919a
commit
ac0fc677a5
1 changed files with 8 additions and 9 deletions
|
@ -198,18 +198,17 @@ public class DatabaseObject {
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
connection.setReadOnly(true);
|
||||||
statement = connection.createStatement();
|
statement = connection.createStatement();
|
||||||
resultSet = statement.executeQuery(sql); // will return true if first result is a result set
|
resultSet = statement.executeQuery(sql); // will return true if first result is a result set
|
||||||
|
|
||||||
RowSet rowSet = new RowSet(sql, this, statement, resultSet);
|
return new RowSet(sql, this, statement, resultSet);
|
||||||
|
} catch (SQLException e) {
|
||||||
return rowSet;
|
|
||||||
} catch(SQLException e) {
|
|
||||||
// System.err.println("##Cannot retrieve: " + e);
|
// System.err.println("##Cannot retrieve: " + e);
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
lastError = e;
|
lastError = e;
|
||||||
try {
|
try {
|
||||||
if (statement!=null) statement.close();
|
if (statement != null) statement.close();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
statement = null;
|
statement = null;
|
||||||
|
@ -226,11 +225,12 @@ public class DatabaseObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
connection.setReadOnly(false);
|
||||||
statement = connection.createStatement();
|
statement = connection.createStatement();
|
||||||
count = statement.executeUpdate(sql); // will return true if first result is a result set
|
count = statement.executeUpdate(sql); // will return true if first result is a result set
|
||||||
} catch(SQLException e) {
|
} catch (SQLException e) {
|
||||||
// System.err.println("##Cannot retrieve: " + e);
|
// System.err.println("##Cannot retrieve: " + e);
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
lastError = e;
|
lastError = e;
|
||||||
|
@ -594,8 +594,7 @@ class RowSet {
|
||||||
|
|
||||||
|
|
||||||
public String[] getSpecialPropertyNames() {
|
public String[] getSpecialPropertyNames() {
|
||||||
String [] ns = {"length"};
|
return new String[] {"length"};
|
||||||
return ns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue