This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes java.lang.UnsupportedOperationException while getting data from database in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "java.lang.UnsupportedOperationException while getting data from database in JSF" Watch "java.lang.UnsupportedOperationException while getting data from database in JSF" New topic
Author

java.lang.UnsupportedOperationException while getting data from database in JSF

shree lk
Greenhorn

Joined: Mar 16, 2011
Posts: 14

Hi all.

I am getting java.lang.UnsupportedOperationException while storing the data into arraylist from database.

My code is....




public List displayNotice() throws SQLException, ClassNotFoundException
{

Class.forName("com.mysql.jdbc.Driver");
Connection con1=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase","root","root");

Statement st=con1.createStatement();
ResultSet rs=st.executeQuery("select noticedate, notice from mytable");
while(rs.next())
{
Notice note = new Notice();
note.setToday(rs.getString(1));
note.setEditor(rs.getString(2));



try
{
arrList.add(note);


}catch(Exception e)
{
e.printStackTrace();
}
return arrList;

}



It showing the above exception for add() fuction, due to which I am not able to get the data from database.

Help Please...
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
So what is your List object it doesn't support the "add" method?
Where are you getting the value of arrList from?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.UnsupportedOperationException while getting data from database in JSF
 
Similar Threads
select and update using the same statement object
Resultset
Adding a record to a database-new to JDBC
Geting an SQL Exception while passing the resultset to a bean
Getting NPE !