实现方法如下:
{
Connection c = new Connection();
c.setConnectionString ("dsn=aDSNName;pwd=aName;pwd=aPWD;database=aDatabase");
c.setCommandTimeout (10);
c.setConnectionTimeout (10);
c.setCursorLocation (AdoEnums.adUseClientBatch);


c.open();
c.setDefaultDatabase ("aSpecificDatabase");
System.out.println ("Connection string = " + c.getConnectionString());


// Verify that the propertiea on the connection
// were set correctly. If not, return a fail condition.
if (c.getCommandTimeout() != 10)
return false;


if (c.getConnectionTimeout() != 10)
return false;


if (c.getCursorLocation() != AdoEnums.adUseClientBatch)
return false;


if (c.getMode() != AdoEnums.adModeUnknown)
return false;


// Create a new Recordset to contain the results
// of the SQL DML operation (select * ...).
Recordset rs= c.execute ("select * from authors");
rs.moveFirst();
rs.moveLast();


// Delete all rows from the authors table.
c.executeUpdate ("delete from authors");


// Close the Connection and Recordset.
rs.close();
c.close();
return true;
}  

posted on 2006-10-15 18:04  振奋人心  阅读(635)  评论(0)    收藏  举报