problem in linking and displaying database data in datatable in jsf
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   deepa_chandnani
Posted On:   Friday, December 29, 2006 05:04 AM

hi, i m finding difficulty in linking database data to datatable. somehow its not getting linked. sometimes it gives error of error setting property,sometimes null pls help me. i don't know whats going wrong. here is the code ____________________ EmpData.java package dst; import javax.faces.component.UIData; import javax.faces.*; import java.util.*; import java.sql.*; /** * * @author muskanc */ public class EmpData { private List ls=null; String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String url = "jdbc:odbc:mydsn"; String user ="muskan"; String pwd   More>>

hi,
i m finding difficulty in linking database data to datatable. somehow its not getting linked. sometimes it gives error of error setting property,sometimes null pls help me. i don't know whats going wrong.

here is the code
____________________
EmpData.java

package dst;
import javax.faces.component.UIData;
import javax.faces.*;
import java.util.*;
import java.sql.*;
/**
*
* @author muskanc
*/
public class EmpData {

private List ls=null;


String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:mydsn";
String user ="muskan";
String pwd ="vakratunda";
Connection con = null;
PreparedStatement pst= null;
ResultSet rs = null;
Statement stmt=null;



/** Creates a new instance of EmpData */
public EmpData() {
}

public UIData getData() {
return data;
}

public void setData(UIData data) {
this.data = data;
}

public List getLs() {
Connection con = null;
PreparedStatement pst= null;
ResultSet rs = null;
Statement stmt=null;
System.out.println("connect called");

try {
Class.forName(driver);
System.out.println("Loading Driver");
}catch (Exception e) {
System.out.println("Cannot load Driver..."+e);
}
try {
con = DriverManager.getConnection(url,user,pwd);
System.out.println("connecting.......");

}catch (Exception e) {
System.out.println("Cannot connect to mysql..."+e);
}

System.out.println("connected....");


try
{
stmt=con.createStatement();
rs=stmt.executeQuery("select ename from emp");

while(rs.next())
{
ls.add(rs.getString(1));
//dataTable.setValue(ls);
System.out.println("----");
}
}catch(Exception e){

System.out.println("---problem fetching data");
}

return ls;
}

public void setLs(List ls) {
this.ls = ls;
}

}

____________________________________

showgrid.jsp


"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>





Tabular Summary























_________________________________

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>



"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">





emp
dst.EmpData
request




/showgrid.jsp




__________________________

pls reply asap.

deepa

   <<Less

Re: problem in linking and displaying database data in datatable in jsf

Posted By:   Tammy_E  
Posted On:   Wednesday, January 31, 2007 03:48 PM

Usually if it says error setting property, that means you are missing a getter/setter in your bean.

Hope that helps.

By the way, in your EmpData.java you've got a getData and a setData, but you are missing a this.data.

Re: problem in linking and displaying database data in datatable in jsf

Posted By:   Simon_Ablett  
Posted On:   Wednesday, January 3, 2007 12:09 PM

Please repost with the code inside
 and 
 so that it is readable.

Thanks.
About | Sitemap | Contact