import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.util.ArrayList;
//import java.util.Iterator;
public class ClassDetails {
public ArrayList<MYBean> getDetails(
String aa){
Connection conn = null;
ResultSet rst =null;
PreparedStatement preparedStatement = null;
ArrayList<MYBean> MYList = new ArrayList<MYBean>();
try {
final String CONNECTION_STRING = "";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(CONNECTION_STRING);
String strQuery = "SELECT * FROM XXX where xxx.yy = " +aa;
preparedStatement = conn.prepareStatement(strQuery);
rst = preparedStatement.executeQuery();
while (rst.next()) {
MYBean MyDetails = new MYBean();
MYList .add(MyDetails);
}
conn.close();
rst.close();
preparedStatement.close();
}
catch (ClassNotFoundException cnfex) {
cnfex.printStackTrace();
} catch (SQLException sqlex) {
sqlex.printStackTrace();
} catch (Exception excp) {
excp.printStackTrace();
}
return MYList ;
}
}
MYBean has about 6 fielda along with getter and setter methods.
MYlist is an array list of Mybean that has to be returned to another program.
How can I print the results that is returned by this program in another
java program.
In other words how can i print the contents of this arraylist.