Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to show database table values using dataTable
    primarykey
    data
    text
    <p>I'm having a bean class employee having attributes id,name along with public getters and setters.</p> <p>I'm using following bean for db connection and getting values from database table.</p> <p><strong>TableBean.java:</strong></p> <pre><code> public class TableBean{ public Connection getVConnection() throws Exception{ String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@localhost:1521:globldb3"; String username = "scott"; String password = "tiger"; Class.forName(driver); Connection conn = DriverManager.getConnection(url, username, password); return conn; } public List&lt;Employee&gt; getPerInfoAll() { int i = 0; Connection conn = null; PreparedStatement pstmt = null; List&lt;Employee&gt; perInfoAll = new ArrayList(); try { conn = getVConnection(); String query = "select * from employee where e_id&gt;5400"; pstmt = conn.prepareStatement(query); rs = pstmt.executeQuery(); while(rs.next()){ System.out.println(rs.getString(1)); perInfoAll.add(i,newEmployee(rs.getInt(1),rs.getString(2))); i++; } pstmt.close(); rs.close(); conn.close(); }catch (Exception e){ e.printStackTrace(); } return perInfoAll; } </code></pre> <p><strong>Following is jsf page:</strong> </p> <pre><code> &lt;h:dataTable value="#{TableBean.perInfoAll}" var="e"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Employee id&lt;/f:facet&gt; &lt;h:outputText value="#{e.id}"&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Employee name&lt;/f:facet&gt; &lt;h:outputText value="#{e.name}"&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; </code></pre> <p>Kindly reply. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload