import java.sql.*;
import javax.sql.*;
import com.sun.rowset.*;
public class TestRowSetEvent {
public static void main(String[] args)
throws SQLException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded");
RowSet rowSet = new JdbcRowSetImpl();
rowSet.addRowSetListener(new RowSetListener() {
public void cursorMoved(RowSetEvent e) {
System.out.println("Cursor moved");
}
public void rowChanged(RowSetEvent e) {
System.out.println("Row changed");
}
public void rowSetChanged(RowSetEvent e) {
System.out.println("row set changed");
}
});
rowSet.setUrl("jdbc:mysql://localhost/javabook");
rowSet.setUsername("scott");
rowSet.setPassword("tiger");
rowSet.setCommand("select * from Student");
rowSet.execute();
rowSet.last();
rowSet.updateString("lastName", "Yao");
rowSet.updateRow();
rowSet.close();
}
}