File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes database help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "database help" Watch "database help" New topic

database help

prats evik

Joined: Apr 04, 2012
Posts: 6
i am unable to display all the data present in the database in a table form.only the first row is displayed .the remaining four are not displayed.
here is the code

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""
<h:dataTable value="#{productBean.result}" var="item" cellpadding="10px" cellspacing="0">
<h:selectOneRadio id="radioButton#{}">
<f:selectItem itemValue="b1" itemLabel="" />

<f:facet name="header">Product name</f:facet>
<f:facet name="header">Product link</f:facet>

<h:commandButton value="submit" action=""></h:commandButton>

* To change this template, choose Tools | Templates
* and open the template in the editor.
package Product;

import java.awt.Container;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.annotation.Resource;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.sql.DataSource;
import javax.sql.rowset.CachedRowSet;
import javax.swing.JButton;
import test.NewWebService;

* @author ppk5032
public class ProductBean implements Serializable

private String product;
private String image;
DataSource dataSource;

public String getImage() {
return image;

public void setImage(String image) {
this.image = image;

public String getProduct() {
return product;

public void setProduct(String product) {
this.product = product;

public ResultSet getResult() throws SQLException
System.out.println("******* in get result");

if (dataSource == null)
{System.out.println("******* inside datasource");
throw new SQLException("Unable to obtain DataSource");
System.out.println("******* out get result");
Connection connection = dataSource.getConnection();

if (connection == null)
{System.out.println("*no datasource connection");
throw new SQLException("Unable to connect to the DataSource");
try {
System.out.println("inside try");

PreparedStatement statment = connection.prepareStatement("SELECT Products, Image_links FROM website");

ResultSet rs = statment.executeQuery();

CachedRowSet rowSet = new com.sun.rowset.CachedRowSetImpl();


return rowSet;

} finally {


can any one tell me what is the problem here?thanks..!

I agree. Here's the link:
subject: database help
It's not a secret anymore!