[JDBC] setAutoCommit closes results?
HLafleur at phoenixforge.com
Wed Aug 2 12:02:37 EDT 2000
Just as a disclaimer, I'm a newbie with programmatic transactions.
I downloaded the latest snapshot of FreeTDS_jdbc a couple of weeks ago. I
was testing transactions for a database access class that I am rewriting
(from J++ :-( ), and the setAutoCommit seems to close all result sets on all
statements. So, if I have a result set open and I want to turn off auto
commit to do a group of transactions, my result set goes away. This happens
when it executes the SQL on that connection (see The code).
Is this correct? I guess this assumes that you'll be using transactions to
start and finish all result sets before you open any results? But, the way
that my class works is that it uses an open result set to get metadata to
build update SQL statements and the metadata disappears after setting
// in class Connection_base
public void setAutoCommit(boolean value) throws SQLException
String sql = null;
autoCommit = value;
sql = sqlStatementToSetCommit();
for(i=0; i<allStatements.size(); i++)
Statement stmt = (Statement)allStatements.elementAt(i);
// Note- stmt.execute implicitly eats the END_TOKEN
// that will come back from the commit command
//--Here it executes the "set implicit_transactions off"
// In class Statement
public boolean execute(String sql) throws SQLException
SQLException exception = null;
if (tds == null)
throw new SQLException("Statement is closed");
//-- Here it closes results from a previous query: i.e. my ResultSet -- I
won't show deeper...
updateCount = -1;
sql = Tds.toNativeSql(sql, tds.getServerType());
tds.executeQuery(sql, this, timeout);
throw new SQLException("Network error- " + e.getMessage());
throw new SQLException("TDS error- " + e.getMessage());
} // execute()
More information about the FreeTDS