dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11643
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3376: Minor alteration to DataBrowserUtils. Use commons logging for debugging/error statements.
------------------------------------------------------------
revno: 3376
committer: Jason P. Pickering <jason.p.pickering@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-04-13 06:23:59 +0200
message:
Minor alteration to DataBrowserUtils. Use commons logging for debugging/error statements.
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/util/DataBrowserUtils.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/util/DataBrowserUtils.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/util/DataBrowserUtils.java 2011-04-12 13:46:30 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/databrowser/util/DataBrowserUtils.java 2011-04-13 04:23:59 +0000
@@ -27,9 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
+
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -39,6 +37,8 @@
import org.amplecode.quick.StatementHolder;
import org.amplecode.quick.StatementManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.GridHeader;
import org.hisp.dhis.databrowser.MetaValue;
@@ -48,7 +48,7 @@
* @version $Id$
*/
public class DataBrowserUtils
-{
+{ protected static final Log log = LogFactory.getLog( DataBrowserUtils.class );
public static void setMetaStructure( Grid grid, StringBuffer sqlsb, List<Integer> metaIds,
StatementManager statementManager )
{
@@ -70,8 +70,8 @@
}
}
catch ( SQLException e )
- {
- throw new RuntimeException( "Failed to add meta value\n" + sqlsb.toString(), e );
+ { log.error( "Failed to add meta value\n" + sqlsb.toString());
+ throw new RuntimeException( "Failed to add meta value\n" , e );
}
catch ( Exception e )
{
@@ -111,7 +111,7 @@
}
}
catch ( SQLException e )
- {
+ {
throw new RuntimeException( "Failed to add header\n", e );
}
catch ( Exception e )
@@ -140,7 +140,8 @@
}
catch ( SQLException e )
{
- throw new RuntimeException( "Failed to get aggregated data value\n" + sqlsb.toString(), e );
+ log.error( "Error executing" + sqlsb.toString());
+ throw new RuntimeException( "Failed to get aggregated data value\n" , e );
}
catch ( Exception e )
{
@@ -190,7 +191,9 @@
}
catch ( SQLException e )
{
+ log.error( "Error executing" + sqlsb.toString());
throw new RuntimeException( "Failed to get aggregated data value\n", e );
+
}
catch ( Exception e )
{
@@ -204,22 +207,7 @@
return countRows;
}
- @SuppressWarnings( "unused" )
- private static void writeToFile( StringBuffer sqlsb )
- {
- try
- {
- FileWriter stream = new FileWriter( "D:/drilldown.sql" );
- BufferedWriter out = new BufferedWriter( stream );
- out.write( sqlsb.toString() );
- out.close();
- }
- catch ( IOException e )
- {
- throw new RuntimeException( "Error while writing file : " + e );
- }
- }
// -------------------------------------------------------------------------
// Supportive methods
@@ -239,7 +227,7 @@
Connection con = holder.getConnection();
Statement stm = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
stm.execute( sql );
-
+ log.debug( sql );
return stm.getResultSet();
}