📄 connection_base.java
字号:
{
stmt.commit();
// stmt.executeQuery(sql);
}
else
{
stmt.rollback();
// stmt.executeQuery(sqlRollback);
}
}
// XXX need to put all of these into the warning chain.
//
// Don't think so, the warnings would belong to Statement anyway -- SB
catch (java.sql.SQLException e)
{
exception = e;
}
catch (java.io.IOException e)
{
exception = new SQLException(e.getMessage());
}
catch (com.internetcds.jdbc.tds.TdsException e)
{
exception = new SQLException(e.getMessage());
}
/* if (stmt instanceof CallableStatement)
{
((PreparedStatementHelper)stmt).dropAllProcedures();
throw new SQLException("Not implemented");
}
else if (stmt instanceof PreparedStatement)
{
((PreparedStatementHelper)stmt).dropAllProcedures();
}
*/
}
if (exception != null)
{
throw exception;
}
}
/**
* In some cases, it is desirable to immediately release a
* Connection's database and JDBC resources instead of waiting for
* them to be automatically released; the close method provides this
* immediate release.
*
* <P><B>Note:</B> A Connection is automatically closed when it is
* garbage collected. Certain fatal errors also result in a closed
* Connection.
*
* @exception SQLException if a database-access error occurs.
*/
public void close() throws SQLException
{
int i;
for(i=0; i<allStatements.size(); i++)
{
Statement stmt = (Statement)allStatements.elementAt(i);
{
if( !stmt.isClosed() )
stmt.close();
}
}
for(i=0; i<tdsPool.size(); i++)
{
((TdsInstance)tdsPool.elementAt(i)).tds.close();
}
clearWarnings();
isClosed = true;
}
/**
* Tests to see if a Connection is closed.
*
* @return true if the connection is closed; false if it's still open
* @exception SQLException if a database-access error occurs.
*/
public boolean isClosed() throws SQLException
{
return isClosed;
}
/**
* A connection's database is able to provide information describing
* its tables, its supported SQL grammar, its stored procedures, the
* capabilities of this connection, etc. This information is made
* available through a DatabaseMetaData object.
*
* @return a DatabaseMetaData object for this connection
* @exception SQLException if a database access error occurs
*/
public java.sql.DatabaseMetaData getMetaData() throws SQLException
{
try
{
if (databaseMetaData == null)
{
// The DatabaseMetaData may need the tds connection
// at some later time. Therefore we shouldn't relinquish the
// tds.
Tds tds = this.allocateTds();
databaseMetaData = new com.internetcds.jdbc.tds.DatabaseMetaData(this, tds);
}
return databaseMetaData;
}
catch(java.io.IOException e)
{
throw new SQLException(e.getMessage());
}
catch(com.internetcds.jdbc.tds.TdsException e)
{
throw new SQLException(e.getMessage());
}
// catch(java.net.UnknownHostException e)
// {
// throw new SQLException(e.getMessage());
// }
}
/**
* You can put a connection in read-only mode as a hint to enable
* database optimizations
*
* <B>Note:</B> setReadOnly cannot be called while in the middle
* of a transaction
*
* @param readOnly - true enables read-only mode; false disables it
* @exception SQLException if a database access error occurs
*/
public void setReadOnly (boolean readOnly) throws SQLException
{
throw new SQLException("Not implemented (setReadOnly)");
}
/**
* Tests to see if the connection is in read-only mode.
*
* @return true if connection is read-only
* @exception SQLException if a database-access error occurs.
*/
public boolean isReadOnly() throws SQLException
{
throw new SQLException("Not implemented (isReadOnly)");
}
/**
* A sub-space of this Connection's database may be selected by setting a
* catalog name. If the driver does not support catalogs it will
* silently ignore this request.
*
* @exception SQLException if a database-access error occurs.
*/
public void setCatalog(String catalog) throws SQLException
{
throw new SQLException("Not implemented (setCatalog)");
}
/**
* Return the Connection's current catalog name.
*
* @return the current catalog name or null
* @exception SQLException if a database-access error occurs.
*/
public String getCatalog() throws SQLException
{
throw new SQLException("Not implemented (getCatalog)");
}
/**
* You can call this method to try to change the transaction
* isolation level using one of the TRANSACTION_* values.
*
* <P><B>Note:</B> setTransactionIsolation cannot be called while
* in the middle of a transaction.
*
* @param level one of the TRANSACTION_* isolation values with the
* exception of TRANSACTION_NONE; some databases may not support
* other values
* @exception SQLException if a database-access error occurs.
* @see DatabaseMetaData#supportsTransactionIsolationLevel
*/
public void setTransactionIsolation(int level)
throws SQLException
{
int i;
String sql;
transactionIsolationLevel = level;
sql = sqlStatementToSetTransactionIsolationLevel();
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
stmt.execute(sql);
}
}
}
/**
* Get this Connection's current transaction isolation mode.
*
* @return the current TRANSACTION_* mode value
* @exception SQLException if a database-access error occurs.
*/
public int getTransactionIsolation() throws SQLException
{
return transactionIsolationLevel;
}
/**
* The first warning reported by calls on this Connection is
* returned.
*
* <P><B>Note:</B> Subsequent warnings will be chained to this
* SQLWarning.
*
* @return the first SQLWarning or null
* @exception SQLException if a database-access error occurs.
*/
public SQLWarning getWarnings() throws SQLException
{
return warningChain.getWarnings();
}
/**
* After this call, getWarnings returns null until a new warning
* is reported for this connection.
*
* @exception SQLException if a database access error occurs
*/
public void clearWarnings() throws SQLException
{
warningChain.clearWarnings();
}
//--------------------------JDBC 2.0-----------------------------
/**
* JDBC 2.0
*
* Creates a <code>Statement</code> object that will generate
* <code>ResultSet</code> objects with the given type and concurrency.
* This method is the same as the <code>createStatement</code> method
* above, but it allows the default result set
* type and result set concurrency type to be overridden.
*
* @param resultSetType a result set type; see ResultSet.TYPE_XXX
* @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX
* @return a new Statement object
* @exception SQLException if a database access error occurs
*/
public java.sql.Statement createStatement(
int resultSetType,
int resultSetConcurrency)
throws SQLException
{
Tds tmpTds = null;
try
{
tmpTds = this.allocateTds();
}
catch(com.internetcds.jdbc.tds.TdsException e)
{
throw new SQLException(e.getMessage());
}
catch(java.io.IOException e)
{
throw new SQLException(e.getMessage());
}
com.internetcds.jdbc.tds.Statement result;
result = new com.internetcds.jdbc.tds.Statement(this, tmpTds);
allStatements.addElement(result);
return result;
}
/**
* JDBC 2.0
*
* Creates a <code>PreparedStatement</code> object that will generate
* <code>ResultSet</code> objects with the given type and concurrency.
* This method is the same as the <code>prepareStatement</code> method
* above, but it allows the default result set
* type and result set concurrency type to be overridden.
*
* @param resultSetType a result set type; see ResultSet.TYPE_XXX
* @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX
* @return a new PreparedStatement object containing the
* pre-compiled SQL statement
* @exception SQLException if a database access error occurs
*/
public java.sql.PreparedStatement prepareStatement(
String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
{
NotImplemented();
return null;
}
/**
* JDBC 2.0
*
* Creates a <code>CallableStatement</code> object that will generate
* <code>ResultSet</code> objects with the given type and concurrency.
* This method is the same as the <code>prepareCall</code> method
* above, but it allows the default result set
* type and result set concurrency type to be overridden.
*
* @param resultSetType a result set type; see ResultSet.TYPE_XXX
* @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX
* @return a new CallableStatement object containing the
* pre-compiled SQL statement
* @exception SQLException if a database access error occurs
*/
public java.sql.CallableStatement prepareCall(
String sql,
int resultSetType,
int resultSetConcurrency) throws SQLException
{
NotImplemented();
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -