Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sun.rowset.*;
- import java.sql.*;
- import javax.sql.rowset.CachedRowSet;
- import javax.sql.rowset.JdbcRowSet;
- /**
- *
- * @author tnngo2
- */
- public class CachedRowSetDemo {
- Connection cn;
- public static void main(String[] args) throws ClassNotFoundException, SQLException{
- CachedRowSet rowSet = new CachedRowSetImpl();
- rowSet.setUrl("jdbc:sqlserver://localhost;DatabaseName=DeveloperApps");
- rowSet.setUsername("sa");
- rowSet.setPassword("123456");
- rowSet.setCommand("SELECT * FROM ToppingDetails");
- int[] keys = {1};
- rowSet.setKeyColumns(keys);
- rowSet.execute();
- while (rowSet.next()) {
- System.out.println(rowSet.getString(1) + " " + rowSet.getString(2));
- }
- rowSet.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement