Hi, I'm currently working on concerning a student record with guardians/parents... im using the java ee framework.. I'm having problems on retrieving the data on our database(MySQL).. Here is what i did.. i have created a class to retrieve those data from the database..
my problem is that whenever i retrieve that data in my jsp page, it only shows this Ljava.lang.String@123EGa something similar to this..


package com;
//this class is the one that i used to retrieve the data..
import java.io.*;
import java.sql.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class Parents {

public String[] lastname;
public String[] firstname;
public String[] middlename;
public String[] relation;

private Connection connection = null;
private Statement statement = null;
private ResultSet rs = null;
Connect con = new Connect();
int count = 0;

public Parents(){}

public Parents(int idno) {
int i = 0;
try {
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/sis",con.user,con.password);
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM guardians WHERE studidno='" + idno + "'");

if (rs.last()) {
count = rs.getRow();

lastname = new String[count];
firstname = new String[count];
middlename = new String[count];
relation = new String[count];

while (rs.next()){
lastname[i] = rs.getString("lastname");
firstname[i] = rs.getString("firstname");
middlename[i] = rs.getString("middlename");
relation[i] = rs.getString("relation");

} catch (Exception e) {

//setters in here..

public String[] getLastname(){return lastname;}

public String[] getFirstname () {return firstname;}

public String[] getMiddlename () {return middlename;}

public String[] getRelation () {return relation;}


and this is what i placed in my jsp page..
Parents p = new Parents(info.getIdno());
for (int i = 0; i < p.getFirstname().length; i++ ) {

<%= p.getLastname() %>


<%= p.getFirstname() %>

"according to what i have read on some searches, the best way to do it is by using data access objects..".. can anybody just an idea on how to do this using data access objects or give some sample codes for me to do this.. Im asking for an idea.. or any sample codes will do.. i have been working on this for about 2 days now, I've done so many researches and i haven't quite find any answer to my problem..

Don't use scriptlets; use JSP's only for view purposes. Use JSTL along with servlet.

> whenever i retrieve that data in my jsp page, it only shows this
> Ljava.lang.String@123EGa something similar to this..

This is because you are trying to print a String array and the above just happens to how toString of an array looks like.

Here you can find some sample J2EE applications along with the J2EE design patterns free book which you can use to read more about Data Access Object pattern.