- bug fixed in class ConnectionManager for the submitquery operation modified in order to manage the data geometry recovering the related value as a sequence of hexadecimal characters and not as a parsed multipolygon value. executeQueryJDBC method modified.

- bug fixed in class DatabaseManagement for the submitquery operation in order to truncate column values of the result to 255 character in convertToJavaType method

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-access/DatabasesResourcesManager@101053 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-10-28 10:00:50 +00:00
parent b7eba1b58f
commit 530a00d536
2 changed files with 22 additions and 2 deletions

View File

@ -55,8 +55,10 @@ public class ConnectionManager {
.initDBConnection(defaultDatabaseFile, config); .initDBConnection(defaultDatabaseFile, config);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("ERROR IN DB INITIALIZATION : " // System.out.println("ERROR IN DB INITIALIZATION : "
+ e.getLocalizedMessage()); // + e.getLocalizedMessage());
AnalysisLogger.getLogger().debug(
"In ConnectionManager-> ERROR IN DB INITIALIZATION : " + e.getLocalizedMessage());
// e.printStackTrace(); // e.printStackTrace();
// AnalysisLogger.getLogger().trace(e); // AnalysisLogger.getLogger().trace(e);
} }
@ -135,6 +137,9 @@ public class ConnectionManager {
// Get a statement from the connection // Get a statement from the connection
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
AnalysisLogger.getLogger().debug(
"In ConnectionManager-> executing query: " + query);
// Execute the query // Execute the query
ResultSet rs = stmt.executeQuery(query); ResultSet rs = stmt.executeQuery(query);
@ -147,7 +152,17 @@ public class ConnectionManager {
for (int i = 1; i < colNum + 1; i++) { for (int i = 1; i < colNum + 1; i++) {
String columnName = rs.getMetaData().getColumnLabel(i); String columnName = rs.getMetaData().getColumnLabel(i);
// System.out.println("column Name: "+columnName); // System.out.println("column Name: "+columnName);
String columnType = rs.getMetaData().getColumnTypeName(i);
Object columnValue = rs.getObject(i); Object columnValue = rs.getObject(i);
//to manage the data geometry
if(columnType.equals("geometry")){
columnValue = rs.getString(i);
//truncate value to 255 characters if it exceeds 255 characters
// if((rs.getString(i).length())>255){
// columnValue =(Object) (rs.getString(i).substring(0, 254));
//// System.out.println("elem geometry truncated");
// }
}
// System.out.println("value: "+columnValue); // System.out.println("value: "+columnValue);
int j = 1; int j = 1;
String newcolumnName = columnName; String newcolumnName = columnName;

View File

@ -201,6 +201,11 @@ public class DatabaseManagement {
} }
//truncate value to 255 characters if it exceeds 255 characters
if(valConverted.length()>255){
valConverted = valConverted.substring(0, 255);
// System.out.println("elem geometry truncated");
}
return valConverted; return valConverted;
} }