Meaningless Drivel is fun!*
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
Author

database help

prats evik
Greenhorn

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Example</title>
</h:head>
<h:body>
<h:dataTable value="#{productBean.result}" var="item" cellpadding="10px" cellspacing="0">
<h:column>
<h:selectOneRadio id="radioButton#{product.id}">
<f:selectItem itemValue="b1" itemLabel="" />

</h:selectOneRadio>
</h:column>
<h:column>
<f:facet name="header">Product name</f:facet>
#{item.Products}
</h:column>
<h:column>
<f:facet name="header">Product link</f:facet>
#{item.Image_links}
</h:column>

</h:dataTable>
<h:commandButton value="submit" action=""></h:commandButton>
</h:body>
</html>




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

import java.awt.Container;
import java.io.Serializable;
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
*/
@ManagedBean(name="productBean")
@RequestScoped
public class ProductBean implements Serializable
{

private String product;
private String image;
@Resource(name="jdbc/addressbook")
DataSource dataSource;

public String getImage() {
return image;
}

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

public String getProduct() {
System.out.println("fggf");
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();

rowSet.populate(statment.executeQuery());

return rowSet;

} finally {
connection.close();
}

}}

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: database help