如何比较两个SQL查询语句产生的结果集是否相同???
我用JDBC连接了MYSQL数据库,对一个表(表的名字叫Coffees)进行的查询操作,我的代码如下:
public class Coffees {
/** Creates a new instance of Coffees */
public Coffees() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Connection con; Statement sql; ResultSet rs;
try { Class.forName( "com.mysql.jdbc.Driver ");
}
catch(
ClassNotFoundException e)
{System.out.println( " "+e + " TEST ");}
try{ con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/COFFEES ", "root ", "nbuser ");
sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = sql.executeQuery( "SELECT COF_NAME, PRICE FROM COFFEES ");
while(rs.next())
{
String name = rs.getString( "COF_NAME ");
Double price = rs.getDouble( "PRICE ");
System.out.println(name + " " + price);
}
con.close();
}
catch (
SQLException sqlexception){