getting data from mysql!! please could someone help me?
Hello people!!
I can't get data from a Mysql database through a jsp page, there's a error message of conversion,
here's my classes:
package teste;
publicclass GetDB{
String str;
Connection con;
ObjectPage ob;
public GetDB()throws Exception{
try{
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/Loja?user=root&password=131283");
}catch (Exception ex){
thrownew Exception("Banco de dados n鉶 encontrado" +
ex.getMessage());
}
}
public ObjectPage getOb(){
try{
String selectStatement ="select * from teste";
PreparedStatement prepStmt = con.prepareStatement(selectStatement);
ResultSet rs = prepStmt.executeQuery();
while (rs.next()){
str = rs.getString(1)+" "+rs.getInt(2);
}
prepStmt.close();
ob =new ObjectPage(str);
}catch (SQLException ex){
}
return ob;
}
publicvoid setOb(ObjectPage ob){
this.ob = ob;
}
}
and this:
package teste;
publicclass ObjectPage{
String name;
public ObjectPage(String nome){
name = nome;
}
public String getName(){
return name;
}
}
and this is myjsp page:
<jsp:useBean id="dado" class="teste.GetDB" scope="page" >
<jsp:setProperty name="dado" property="ob" value="{$name}"/>
</jsp:useBean>
<%--<jsp:getProperty name="dado" property="propName"/> --%>
<b><h1><font color="orange">${dado.ob.name}</font></h1></b>
so what's wrong? could you give me some tips? what should i do ?
Thanks a lot!!!

