• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

database help

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..!

reply
    Bookmark Topic Watch Topic
  • New Topic