comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java @ 271:8aad9d098b08

Integrated Patch of issue57 to get some Memoryusage-improvements geo-backend/trunk@248 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 20 Oct 2009 09:57:52 +0000
parents 56655046194f
children 3cbf11c67fdc
comparison
equal deleted inserted replaced
270:1fe93e3c80c0 271:8aad9d098b08
53 protected Collection<Result> createResultCollection(ResultSet resultSet) throws SQLException{ 53 protected Collection<Result> createResultCollection(ResultSet resultSet) throws SQLException{
54 Collection<Result> returnValue = new ArrayList<Result>(); 54 Collection<Result> returnValue = new ArrayList<Result>();
55 55
56 ResultDescriptor resultDescriptor = null; 56 ResultDescriptor resultDescriptor = null;
57 int columns = -1; 57 int columns = -1;
58
58 List<String> columnNames = null; 59 List<String> columnNames = null;
60
59 while (resultSet.next()){ 61 while (resultSet.next()){
60 if (resultDescriptor == null){ 62 if (resultDescriptor == null){
61 resultDescriptor = new DefaultResultDescriptor(); 63 resultDescriptor = new DefaultResultDescriptor();
62 ResultSetMetaData rsmd = resultSet.getMetaData(); 64 ResultSetMetaData rsmd = resultSet.getMetaData();
63 columns = rsmd.getColumnCount(); 65 columns = rsmd.getColumnCount();
64 columnNames = new ArrayList<String>(columns); 66
65 for (int i = 1; i <= columns; i++){ 67 for (int i = 1; i <= columns; i++){
66 resultDescriptor.addColumn(rsmd.getColumnName(i), rsmd.getColumnClassName(i)); 68 resultDescriptor.addColumn(rsmd.getColumnName(i), rsmd.getColumnClassName(i));
67 columnNames.add(rsmd.getColumnName(i));
68 } 69 }
69 } 70 }
70 71
71 Result result = convertResult(resultSet, resultDescriptor,columnNames); 72 Result result = convertResult(resultSet, resultDescriptor);
72 73
73 returnValue.add(result); 74 returnValue.add(result);
74 } 75 }
75 return returnValue; 76 return returnValue;
76 } 77 }
77 78
78 /** 79 /**
79 * This Method converts one Singel ResultSetEntry into an Result-Object 80 * This Method converts one Singel ResultSetEntry into an Result-Object
80 * @param resultSet the ResultSet where the Entry should be took from. 81 * @param resultSet the ResultSet where the Entry should be took from.
81 * @param resultDescriptor the ResultsetDescriptor which describes the Entry 82 * @param resultDescriptor the ResultsetDescriptor which describes the Entry
82 * @param columnNames the Name of the Columns which Values should be fetched.
83 * @return an new Result-Objects containing the Values of the ResultSet-Entry 83 * @return an new Result-Objects containing the Values of the ResultSet-Entry
84 * @throws SQLException 84 * @throws SQLException
85 */ 85 */
86 private Result convertResult(ResultSet resultSet, 86 private Result convertResult(ResultSet resultSet, ResultDescriptor resultDescriptor)
87 ResultDescriptor resultDescriptor, List<String> columnNames) 87 throws SQLException {
88 throws SQLException { 88
89 Result result = new DefaultResult(resultDescriptor); 89 Result result = new DefaultResult(resultDescriptor);
90 for (int i = 0; i < columnNames.size(); i++){ 90
91 String columnName = columnNames.get(i); 91 for (int i = 0, N = resultDescriptor.getColumnCount(); i < N; i++) {
92 result.addColumnValue(columnName, resultSet.getObject(columnName)); 92 result.addColumnValue(i, resultSet.getObject(i+1));
93 } 93 }
94 return result; 94 return result;
95 } 95 }
96 96
97 } 97 }

http://dive4elements.wald.intevation.org