diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java | 96 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java | 85 |
2 files changed, 84 insertions, 97 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java index e1caf19470..0e4d26e9b4 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java @@ -28,16 +28,13 @@ import org.eclipse.net4j.db.IDBAdapter; import org.eclipse.net4j.db.IDBConnectionProvider; import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; -import java.sql.Connection; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -201,99 +198,6 @@ public final class CDODBUtil } /** - * For debugging purposes ONLY! - * - * @deprecated Should only be used when debugging. - * @since 2.0 - */ - @Deprecated - public static void sqlDump(Connection conn, String sql) - { - ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDODBUtil.class); - ResultSet rs = null; - try - { - TRACER.format("Dumping output of {0}", sql); //$NON-NLS-1$ - rs = conn.createStatement().executeQuery(sql); - int numCol = rs.getMetaData().getColumnCount(); - - StringBuilder row = new StringBuilder(); - for (int c = 1; c <= numCol; c++) - { - row.append(String.format("%10s | ", rs.getMetaData().getColumnLabel(c))); //$NON-NLS-1$ - } - - TRACER.trace(row.toString()); - - row = new StringBuilder(); - for (int c = 1; c <= numCol; c++) - { - row.append("-----------+--"); //$NON-NLS-1$ - } - - TRACER.trace(row.toString()); - - while (rs.next()) - { - row = new StringBuilder(); - for (int c = 1; c <= numCol; c++) - { - row.append(String.format("%10s | ", rs.getString(c))); //$NON-NLS-1$ - } - - TRACER.trace(row.toString()); - } - - row = new StringBuilder(); - for (int c = 1; c <= numCol; c++) - { - row.append("-----------+-"); //$NON-NLS-1$ - } - - TRACER.trace(row.toString()); - } - catch (SQLException ex) - { - // NOP - } - finally - { - if (rs != null) - { - try - { - rs.close(); - } - catch (SQLException ex) - { - // NOP - } - } - } - } - - /** - * For debugging purposes ONLY! - * - * @deprecated Should only be used when debugging. - * @since 2.0 - */ - @Deprecated - public static void sqlDump(IDBConnectionProvider connectionProvider, String sql) - { - Connection connection = connectionProvider.getConnection(); - - try - { - sqlDump(connection, sql); - } - finally - { - DBUtil.close(connection); - } - } - - /** * Creates a prepared statement cache with the {@link CDODBUtil#DEFAULT_STATEMENT_CACHE_CAPACITY default capacity}. * * @since 2.0 diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java index bcedc47b3a..fe73d4dcaa 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation */ @@ -44,6 +44,89 @@ public final class DBUtil { } + /** + * For debugging purposes ONLY! + * + * @deprecated Should only be used when debugging. + * @since 3.0 + */ + @Deprecated + public static void sqlDump(Connection conn, String sql) + { + ResultSet rs = null; + + try + { + TRACER.format("Dumping output of {0}", sql); //$NON-NLS-1$ + rs = conn.createStatement().executeQuery(sql); + int numCol = rs.getMetaData().getColumnCount(); + + StringBuilder row = new StringBuilder(); + for (int c = 1; c <= numCol; c++) + { + row.append(String.format("%10s | ", rs.getMetaData().getColumnLabel(c))); //$NON-NLS-1$ + } + + TRACER.trace(row.toString()); + + row = new StringBuilder(); + for (int c = 1; c <= numCol; c++) + { + row.append("-----------+--"); //$NON-NLS-1$ + } + + TRACER.trace(row.toString()); + + while (rs.next()) + { + row = new StringBuilder(); + for (int c = 1; c <= numCol; c++) + { + row.append(String.format("%10s | ", rs.getString(c))); //$NON-NLS-1$ + } + + TRACER.trace(row.toString()); + } + + row = new StringBuilder(); + for (int c = 1; c <= numCol; c++) + { + row.append("-----------+-"); //$NON-NLS-1$ + } + + TRACER.trace(row.toString()); + } + catch (SQLException ex) + { + // Do nothing + } + finally + { + close(rs); + } + } + + /** + * For debugging purposes ONLY! + * + * @deprecated Should only be used when debugging. + * @since 3.0 + */ + @Deprecated + public static void sqlDump(IDBConnectionProvider connectionProvider, String sql) + { + Connection connection = connectionProvider.getConnection(); + + try + { + sqlDump(connection, sql); + } + finally + { + close(connection); + } + } + public static IDBSchema createSchema(String name) { return new DBSchema(name); |