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!!!

[3581 byte] By [Sonecaa] at [2007-10-2 14:07:16]
# 1
Instead of someone trying to understand your code, wouldn't it be better if you posted the error message too?
aniseeda at 2007-7-13 12:18:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

If there's an error message of conversion, are you sure that the 1st and 2nd columns returned in the result set are of type string & integer respectively (try getObject, then see what it's an instanceof)? Just guessing, maybe the actual database fields don't match the types you're expecting.

And why don't you try ex.printStackTrace() to see what the actual error is in the getOb method?

radtad82a at 2007-7-13 12:18:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
the gtOb method returns a ObjetctPage object where there's the data from the database (str) the method get name of ObjetctPage returnsa string ob.getName() , that's what i want and there's an error.
Sonecaa at 2007-7-13 12:18:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...