Forums Register Login

database help

+Pie Number of slices to send: Send
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..!

Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 986 times.
Similar Threads
commandLink not working in datatable+jsf2.0
Form calling a session scoped backing bean constructor twice
Does action attribute not work with function call having parameters?
Action does not work inside rich:popupPanel
JEE example with EJB, JSF is not working
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:21:08.