Changeset 21303 for main/trunk/greenstone3
- Timestamp:
- 2009-12-09T13:07:34+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/sql/derby/DerbyDBWrapper.java
r19636 r21303 101 101 //the database hasn't been correct yet 102 102 ArrayList results = new ArrayList(); 103 try{ 104 105 if (statement == null){ 103 ResultSet rs = null; 104 try{ 105 106 if (statement == null){ 106 107 logger.info("the database hasn't been correct yet"); 107 108 return new ArrayList(); 108 } 109 110 ResultSet rs = statement.executeQuery(query_statement); 111 ResultSetMetaData rsmd = rs.getMetaData(); 112 int numOfColumns = rsmd.getColumnCount(); 113 while(rs.next()){ 114 HashMap arow = new HashMap(); 115 for(int i = 1; i <= numOfColumns ; i++){ 116 arow.put(rsmd.getColumnName(i).toLowerCase(), rs.getObject(i)); 117 } 118 results.add(arow); 119 } 109 } 110 111 rs = statement.executeQuery(query_statement); 112 ResultSetMetaData rsmd = rs.getMetaData(); 113 int numOfColumns = rsmd.getColumnCount(); 114 while(rs.next()){ 115 HashMap arow = new HashMap(); 116 for(int i = 1; i <= numOfColumns ; i++){ 117 arow.put(rsmd.getColumnName(i).toLowerCase(), rs.getObject(i)); 118 } 119 results.add(arow); 120 } 121 122 rs.close(); 123 120 124 } 121 125 catch(SQLException sqle){ … … 124 128 } 125 129 catch(Exception e){ 126 127 130 logger.debug(e); 131 return null; 128 132 } 129 133 return results; … … 143 147 logger.debug(stat); 144 148 rs = statement.executeQuery(stat); 145 146 logger.info("sql stat="+stat+ " result="+rs); 149 logger.info("sql stat="+stat+ " result="+rs); 147 150 } 148 151 catch(SQLException sqle){ … … 169 172 170 173 rs = statement.execute(stat); 171 // connection.commit(); 174 statement.close(); 175 // connection.commit(); 172 176 } 173 177 catch(SQLException sqle){ … … 194 198 //either the row count of INSERT, UPDATE OR DELETE statement, or 0 if the statement returns nothing 195 199 rs = statement.executeUpdate(stat); 200 statement.close(); 196 201 // connection.commit(); 197 202 logger.debug("sql stat="+stat+ " result="+rs); 198 203 } 199 204 catch(SQLException sqle){ … … 214 219 public void check4Table(String stat) throws SQLException { 215 220 statement.executeQuery(stat); 221 statement.close(); 216 222 } 217 223 218 224 public void closeConnection(String databasepath){ 219 sqlServer.disconnect(databasepath); 225 try{ 226 statement.close(); 227 connection.close(); 228 sqlServer.disconnect(databasepath); 229 } 230 catch(SQLException sqle){ 231 logger.debug("Database Error occured when close connection " + databasepath, sqle); 232 } 220 233 } 221 234
Note:
See TracChangeset
for help on using the changeset viewer.