Improved: Logging: change all System.out/.err/.. println to Debug.log... in the code base (OFBIZ-10045)

Thanks Michael Brohl and Kyra Pritzel-Hentley for your contribution

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1819124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Deepak Dixit
2017-12-23 09:08:04 +00:00
parent b30481ffab
commit fb77a3c477
17 changed files with 65 additions and 42 deletions
@@ -23,9 +23,14 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
import org.apache.ofbiz.base.util.Debug;
import com.healthmarketscience.jackcess.util.CustomLinkResolver;
public class CursorConnection extends AbstractCursorHandler {
public static final String module = CursorConnection.class.getName();
public static Connection newCursorConnection(Connection con, String cursorName, int pageSize) throws Exception {
return newHandler(new CursorConnection(con, cursorName, pageSize), Connection.class);
}
@@ -39,12 +44,12 @@ public class CursorConnection extends AbstractCursorHandler {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("prepareStatement".equals(method.getName())) {
System.err.println("prepareStatement");
Debug.logInfo("prepareStatement", module);
args[0] = "DECLARE " + cursorName + " CURSOR FOR " + args[0];
PreparedStatement pstmt = (PreparedStatement) method.invoke(con, args);
return CursorStatement.newCursorPreparedStatement(pstmt, cursorName, fetchSize);
} else if ("createStatement".equals(method.getName())) {
System.err.println("createStatement");
Debug.logInfo("createStatement", module);
Statement stmt = (Statement) method.invoke(con, args);
return CursorStatement.newCursorStatement(stmt, cursorName, fetchSize);
}
@@ -23,9 +23,12 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.ofbiz.base.util.Debug;
public class CursorResultSet extends AbstractCursorHandler {
public static final String module = CursorResultSet.class.getName();
protected ResultSet rs;
protected Statement stmt;
protected String query;
@@ -34,7 +37,7 @@ public class CursorResultSet extends AbstractCursorHandler {
super(cursorName, fetchSize);
this.stmt = stmt;
query = "FETCH FORWARD " + fetchSize + " IN " + cursorName;
System.err.println("executing page fetch(1)");
Debug.logInfo("executing page fetch(1)", module);
rs = stmt.executeQuery(query);
}
@@ -50,7 +53,7 @@ public class CursorResultSet extends AbstractCursorHandler {
protected boolean next() throws SQLException {
if (rs.next()) return true;
System.err.println("executing page fetch(2)");
Debug.logInfo("executing page fetch(2)", module);
rs = stmt.executeQuery(query);
return rs.next();
}
@@ -24,12 +24,14 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.entity.transaction.GenericTransactionException;
import org.apache.ofbiz.entity.transaction.TransactionUtil;
public class CursorStatement extends AbstractCursorHandler {
public static final String module = CursorStatement.class.getName();
protected ResultSet currentResultSet;
protected Statement stmt;
protected boolean beganTransaction;
@@ -41,7 +43,7 @@ public class CursorStatement extends AbstractCursorHandler {
beganTransaction = TransactionUtil.begin();
autoCommit = stmt.getConnection().getAutoCommit();
stmt.getConnection().setAutoCommit(false);
System.err.println("beganTransaction=" + beganTransaction + ", autoCommit=" + autoCommit);
Debug.logInfo("beganTransaction=" + beganTransaction + ", autoCommit=" + autoCommit, module);
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@@ -58,7 +60,7 @@ public class CursorStatement extends AbstractCursorHandler {
return currentResultSet;
} else if ("executeQuery".equals(method.getName()) && args != null) {
args[0] = "DECLARE " + cursorName + " CURSOR FOR " + args[0];
System.err.println("query=" + args[0]);
Debug.logInfo("query=" + args[0], module);
if (stmt.execute((String) args[0])) {
throw new SQLException("DECLARE returned a ResultSet");
}