Stack Exchange
Issues with WebRowSet
My code is as below:
    int [] keyCols = {1};

    WebRowSet sender = new WebRowSetImpl();  
    sender.setUsername("root");
    sender.setPassword("root"); 
    sender.setUrl("jdbc:mysql://localhost:3306/jdbc");
    sender.setCommand("select * from bank");
    sender.setKeyColumns(keyCols);
    int size1 = sender.size();
    System.out.println(size1);
    sender.execute();

    FileWriter fw=new FileWriter("bank.xml");
    sender.writeXml(fw); 
    fw.flush(); 
    fw.close();

    WebRowSet receiver = new WebRowSetImpl(); 
    receiver.setUsername("root");
    receiver.setPassword("root"); 
    receiver.setUrl("jdbc:mysql://localhost:3306/jdbc");

    FileReader fr=new FileReader("bank.xml");
    receiver.readXml(fr); 
    int size2 = receiver.size();
    System.out.println(size2);
    if(size1 == size2) 
    { 
        System.out.print("WebRowSet serialized and "); 
        System.out.println("deserialized properly");
    }
    else 
    { 
        System.out.print("Error....serializing/");
        System.out.println("deserializing the WebRowSet"); 
    }

I'm gettting the error message of 
"Error....serializing/"
"deserializing the WebRowSet" 
The reason for this error message is that the value of size1 is 0 and size2 is 17. Number of rows in my table "bank" is 17 so I understand the value for size2, but why does I am getting "0" for size1.
Another question is that I have not created any file named "bank.xml" so why I am not getting any error saying "no such file exist"?

You're calling int size1 = sender.size(); before you're calling sender.execute(), so that's why size1 equals zero.
When you call FileWriter fw=new FileWriter("bank.xml");, that's creating the file if it doesn't already exist.
