probleme de temp d'affichage d'une table
bonjour, pour mon stage j'ai besoin de réaliser une application avec struts, tout se passe bien seulement j'ai un souci avec une table qui met un temps énorme à s'afficher (~1mn) voir même fait planter l'appli.
voila le code ma jsp :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
<%--
Document : displayTable2
Created on : 13 févr. 2012, 17:17:05
Author :
--%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="actionForm.DisplayTableForm"%>
<%@page contentType="text/html" pageEncoding="UTF-8" session="false"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>affichage Table</title>
<link href="<c:url value="/css/styles.css" />" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<c:url value="/js/index.js" />"></script>
<script type="text/javascript" src="<c:url value="/jquery/jquery-1.7.1.js"/> "></script>
<script type="text/javascript" src="<c:url value="/jquery/jquery.tablesorter.min.js"/> "></script>
<script type="text/javascript" src="<c:url value="/jquery/jquery.tablesorter.pager.js"/> "></script>
<script type="text/javascript">
$(document).ready(function() {
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} ).tablesorterPager({container: $("#pager")}); } );
</script>
</head>
<body >
<h1>${nomTable}</h1>
<div id="link" >
<div id="indexDisTable2" class="indexBack" ><html:link action="/actionModifTable.do">retour au choix de Table</html:link></div>
<div id="displayTableBack" class="indexBack" ><html:link action="/actionIndex.do">retour à l'index</html:link></div>
</div>
<div id="conteneurDisplayT2">
<table id="myTable" class="tablesorter">
<!-- *************************** le nom de mes colonne **************************** -->
<thead>
<c:forEach var="col" begin="0" end="${form.nbrCol}" step="1"
varStatus="Col">
<th id="colName${Col.index}" class="col${Col.index}">${form.colName[Col.index]}</th>
</c:forEach>
</thead>
<!-- ***************************** affichage de ma table ******************************* -->
<tbody>
<c:forEach var="row" begin="0" end="${form.nbrRow}" step="1" varStatus="Row">
<tr>
<c:forEach var="col" begin="0" end="${form.nbrCol}" step="1"
varStatus="Col2">
<c:if test="${form.tableName[Row.index][Col2.index] != '00000'}">
<td class="col${Col2.index}">${form.tableName[Row.index][Col2.index]}</td>
</c:if>
<c:if test="${form.tableName[Row.index][Col2.index] == '00000'}">
<td id="btnChange${Row.index}${Col2.index}">
<form action="#">
<div class="btnChange">
<div class="colWarn${Col2.index}"> ${form.tableName[Row.index][Col2.index]}</div>
<div class="btnAjax" > <input id="btn${Row.index}${Col2.index}" type="button" name="Envoyer" onclick="callPop('${nomTable}','${form.colName[Col2.index]}','${Row.index}${Col2.index}');" value="" /> </div>
</div>
</form>
</td>
</c:if>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html> |
mon DAO :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
public ArrayList<ArrayList<String>> populateTable(String table,int nbrCol) throws SQLException{
//String[][] populateTable = null;
ArrayList<String> nomCol = null;
Connection cx = null;
Statement stm = null;
ResultSet rslt = null;
//ResultSetMetaData = null;
String sql = null;
myTab = new ArrayList<>();
try {
sql = "[dbo].[RS_populate_table_display] @tableName = N'"+table+"'";
//"call RS_populate_table_display ('"+table+"')";
System.out.println("SQL************ 4 **************");
//--------------------------------------> WHERE [DWH].[dbo].["+table+"].[CD_CENTRE]= '0001'
cx = JdbcUtilSS.getConnection();
System.out.println("cx ="+ cx);
stm = cx.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
System.out.println("stm ="+ stm);
//*******************
// ********************************************************ResultSet. CONCUR_UPDATABLE
System.out.println("SQL************ 4 **************"+ sql);
rslt = stm.executeQuery(sql);
nomCol = this.colName(table);
//System.out.println("*************************Nombre de Row populate Table"+ nbrRow);
System.out.println("*************************Nombre de col populate Table"+ nbrCol);
rslt.beforeFirst();
while(rslt.next()){
oneLine = new ArrayList<>();
for(int j=0 ; j<nbrCol ; j++ ){
oneLine.add(rslt.getString(nomCol.get(j)));
System.out.println(rslt.getString(nomCol.get(j))+"*************************valeur de j = "+ j);
}
myTab.add(oneLine);
}
} catch (SQLException e) {
System.err.println(e);
}finally{
rslt.close();
stm.close();
cx.close();
}
return myTab;
} |
mon action :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
if (action.equals("displayTable.do")) {
// on instancie le bean Form
DisplayTableForm dtf = (DisplayTableForm) form;
// on instancie la Data Access Object
TableDaoSS tds = new TableDaoSS();
// on recupere la valeur de la list dans la pages JSP displayTable
nomTable = request.getParameter("tabletype");
// on creer la valeur "nomTable" pour l'affichage dans la pages JSP displayTable2
request.setAttribute("nomTable", nomTable);
try {
// on peuple l'arrayList colNameDTF a partir de la fonction colName() de la DAO
ArrayList<String> colNameTDS = tds.colName(nomTable);
// on recupere la taille de l'arrayList
int nbrCol = colNameTDS.size();
System.out.println("DTF nombre de col = " + nbrCol);
// on peuple le bean Form Colname a partir de l'arrayList colNameDTF
dtf.setColName(colNameTDS);
// operation identique pour peupler populateTableDTF
ArrayList<ArrayList<String>> populateTableDTF = tds.populateTable(nomTable, nbrCol);
int nbrRow = populateTableDTF.size();
dtf.setTableName(populateTableDTF);
// on soustrait la valeur 0 de la table
dtf.setNbrCol(nbrCol);
System.out.println("dtf.setNbrCol(nbrCol);"+nbrCol);
dtf.setNbrRow(nbrRow);
System.out.println("dtf.setNbrCol(nbrRow);"+nbrRow);
// setter pour l'affichage dans la pages JSP
request.setAttribute("form", dtf);
System.out.println("request.setAttribute(\"form\", dtf);");
// System.out.println("***************request.setAttribute(\"form, dtf); ");
} catch (SQLException e) {
// TODO Auto-generated catch block
}
// redirection
return mapping.findForward("succes");
} |
voila je pense avoir mis le necéssaire pour la compréhension du problème .
je souhaite regler le problème, j'ai l'impression qu'il y un flux trop important de données ( il y a 1500 lignes * 14 colonnes )
, puisque ça marche avec d'autre table moins volumineuse .
merci a tous ceux qui prendront le temp de me lire et de m'aider :ccool: