Witam aplikacja wyciąga dane z bazy i wyświetla je w tabelce na stronie:
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
response.setContentType("text/html; charset=ISO-8859-2");
PrintWriter out = response.getWriter();
//-------------------------------------------------------------------------
String DB_USER = "apw_user";
String DB_PASSWORD = "apw_user";
String DB_CONNECTION_STRING = "jdbc:firebirdsql://localhost:3050/C:\\KS\\APW\\AP\\wapteka.fdb";
String STEROWNIK ="org.firebirdsql.jdbc.FBDriver";
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
System.out.println("Zainstalowano sterownik");
}
catch (ClassNotFoundException ex) {Logger.getLogger(Zapytanie_1.class.getName()).log(Level.SEVERE, null, ex);}
try {
Connection polaczenie = DriverManager.getConnection(DB_CONNECTION_STRING, DB_PASSWORD, DB_USER);
System.out.println("Nawiazano polaczenei z baza danych");
Statement stmt = polaczenie.createStatement();
zapytanie ="select d.idfirm,d.datsp, d.nrkln, d.kwota,w.nazwa, d.wskus from dokp d,dedp w where d.nrkln>0 and d.idfirm=d.idfirm and d.iddedp=w.id";
wyniki = DatabaseUtilities.getQueryResults(STEROWNIK, DB_CONNECTION_STRING, DB_USER, DB_PASSWORD, zapytanie, true);
polaczenie.close();
}
catch (SQLException ex) {Logger.getLogger(Zapytanie_1.class.getName()).log(Level.SEVERE, null, ex);}
response.getWriter().println("<html>");
response.getWriter().println("<head>");
response.getWriter().println("<title>Odpowiedz z serwera: </title>");
response.getWriter().println("</head>");
response.getWriter().println("<body>");
response.getWriter().println("<br><br>"+"Zapytanie: "+zapytanie);
response.getWriter().print("<br><br>"+wyniki.toHTMLTable("CYAN"));
response.getWriter().println("</body>");
response.getWriter().println("</html>");
}
Metoda tworząca tabele do html:
public String toHTMLTable(String headingColor)
{
StringBuffer buffer =new StringBuffer("<TABLE BORDER=1>\n");
if (headingColor != null)
{buffer.append(" <TR BGCOLOR=#FDF5E6\"" + headingColor + "\">\n "); }
else {buffer.append(" <TR>\n "); }
for(int col=0; col<getColumnCount(); col++)
{
buffer.append("<TH>" + columnNames[col]);
}
for(int row=0; row<getRowCount(); row++)
{
buffer.append("\n <TR>\n ");
String[] rowData = getRow(row);
for(int col=0; col<getColumnCount(); col++)
{
buffer.append("<TD> " + rowData[col]+" "+"</TD>");
}
}
buffer.append("\n</TABLE>");
return(buffer.toString());
}
Wszystko działa, jest to moja pierwsza aplikacja w webie i pierwszy raz spotykam sie z problemem typu:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.OutOfMemoryError: GC overhead limit exceeded
note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.
Koniec pamięci. jakiej? i jak sobie z tym poradzić. Problem pojawia sie gdy danych rekordów do wyświetlenia jest wiece niż 3 tysiąca ;/ Proszę o rade