if (commit) { conn.commit(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Commit of the " + database.getId()); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Rolback of the " + database.getId()); LOGGER.log(Level.SEVERE, errMessage + database, e); throw new IllegalStateException(errMessage + database, e);
/** Return a transaction object for the current transaction state. */ @Override @Nonnull protected Object doGetTransaction() throws TransactionException { LOGGER.log(UjoLogger.TRACE, "GetTransaction is running"); return dummy; }
public JdbcStatement(final PreparedStatement ps, final OrmHandler handler) { this.ps = ps; this.typeService = handler.getParameters().getConverter(null); logValues = LOGGER.isLoggable(Level.INFO); if (logValues) { values = new StringBuilder(); } }
@Override protected Object doGetTransaction() throws TransactionException { LOGGER.log(UjoLogger.INFO, "getTransaction returning new Object"); //can not return null because it will not call commit return new Object(); }
/** Constructor for a PreparedStatement */ public JdbcStatement(@Nonnull final PreparedStatement ps, @Nonnull final OrmHandler handler) { this.ps = ps; this.typeService = handler.getParameters().getConverter(null); logValues = LOGGER.isLoggable(UjoLogger.INFO); logValueLengthLimit = Math.max(10, MetaParams.LOG_VALUE_LENGTH_LIMIT.of(handler.getParameters())); if (logValues) { values = new StringBuilder(); } }
/** Begin a new transaction with semantics according to the given transaction */ protected void doEnd(final boolean commit, @Nonnull final Session localSession) throws TransactionException { if (localSession.isClosed()) { final String msg = "Transaction is closed, can't be " + (commit ? "commited" : "rollbacked"); throw new TransactionException(msg) { private static final long serialVersionUID = 1L; }; } try { if (LOGGER.isLoggable(UjoLogger.TRACE)) { LOGGER.log(UjoLogger.TRACE , "Transaction is finished on the " + (commit ? "Commit" : "Rollback")); } if (commit) { localSession.commitTransaction(); } else try { localSession.rollbackTransaction(); } catch (Exception e) { // The rollback exception must not be thrown, because the original one could be overlapped. LOGGER.log(UjoLogger.ERROR, "Rollback failed", e); } } finally { if (localSession.getTransaction() == null) { session.remove(); localSession.close(); } } }
private void logColumn(final ResultSet columns) throws SQLException { LOGGER.log(INFO, "DB column: {}.{}.{}.{}" , columns.getString("TABLE_CAT") , columns.getString("TABLE_SCHEM") , columns.getString("TABLE_NAME") , columns.getString("COLUMN_NAME")); }
sql = db.getDialect().printSequenceNextValue(this, out).toString(); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, sql + "; ["+tableName+']'); } statement = connection.prepareStatement(sql); statement.setString(1, tableName); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, sql + "; ["+tableName+']'); } statement = connection.prepareStatement(sql); statement.setString(1, tableName); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, sql + "; ["+tableName+']'); } statement = connection.prepareStatement(sql); statement.setString(1, tableName); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, sql + "; [" + tableName + ']'); + " (Long.MAX_VALUE-step)" LOGGER.log(Level.WARNING, msg); connection.rollback(); } catch (SQLException ex) { LOGGER.log(Level.WARNING, "Rollback fails");
/** Forces to reload sequence from db on next call for nextValue. */ public synchronized void reset() { sequence = 0; seqLimit = 0; maxValue = 0; LOGGER.log(UjoLogger.INFO , "{}: reset the sequencer for the table {}" , getClass().getSimpleName() , getTableName()); }
sql = db.getDialect().printSequenceNextValue(this, out).toString(); if (LOGGER.isLoggable(UjoLogger.TRACE)) { LOGGER.log(UjoLogger.TRACE, "{}; [{}]", sql, tableName); if (LOGGER.isLoggable(UjoLogger.TRACE)) { LOGGER.log(UjoLogger.TRACE, "{}; [{}]", sql, tableName); sequence = seqLimit - step + 1; // Get the last assigned number + 1; if (LOGGER.isLoggable(UjoLogger.INFO)) { final String msg = getClass().getSimpleName() + ": tableName=" + tableName + ", maxValue=" + maxValue + ", sequence=" + sequence; LOGGER.log(UjoLogger.INFO, msg); if (LOGGER.isLoggable(UjoLogger.INFO)) { LOGGER.log(UjoLogger.INFO, "{}; [{}]", sql, tableName); + " (Long.MAX_VALUE-step)" LOGGER.log(UjoLogger.WARN, msg); connection.rollback(); } catch (SQLException ex) { LOGGER.log(UjoLogger.WARN, "Rollback fails");
@Override public void writeValue(UjoProperty property, Object value) { // Sequence validation: if (SEQUENCE_CACHE==property) { int val = (Integer) value; if (val<1) { value = 1; final String msg = "The smallest possible value of property '"+property+"' is 1, not " + val; LOGGER.log(Level.WARNING, msg); } } super.writeValue(property, value); }
if (LOGGER.isLoggable(UjoLogger.INFO)) { final String msg = getClass().getSimpleName() + ": " + toString(); LOGGER.log(UjoLogger.INFO, msg);
protected void beginTransaction() { LOGGER.log(UjoLogger.TRACE, "Auto transaction registred/started"); ujoSessionFactory.setAutoTransaction(true); }
if (LOGGER.isLoggable(Level.INFO)) { final String msg = getClass().getSimpleName() + ": " + toString(); LOGGER.log(Level.INFO, msg);
@Override public void writeValue(Key key, Object value) { // Sequence validation: if (SEQUENCE_CACHE==key) { int val = (Integer) value; if (val<1) { value = 1; final String msg = "The smallest possible value of key '"+key+"' is 1, not " + val; LOGGER.log(UjoLogger.WARN, msg); } } super.writeValue(key, value); }
while(rs.next()) { items.add(rs.getString("COLUMN_NAME").toUpperCase()); if (false && LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "New DB column: " + mc.getFullName()); newColumns.add(mc); LOGGER.log(Level.INFO, "New DB table: " + MetaTable.NAME.of(table)); newTables.add(table); boolean exists = items.contains(MetaIndex.NAME.of(index).toUpperCase()); if (!exists) { LOGGER.log(Level.INFO, "New DB index: " + index); newIndexes.add(index);
private static UjoLogger newUjoLoggerBridge2Slf4j(Class name) { UjoLogger result; try { result = new UjoLoggerBridge2Slf4j(name); if (showLog) { showLog = false; result.log(Level.INFO, "Ujorm logging is switched to the SLF4J."); } } catch (Throwable e) { slf4jSupport = false; result = new UjoLoggerFactory(name); result.log(Level.INFO, "Ujorm logging is switched to the JUL."); } return result; }
if (LOGGER.isLoggable(fineLevel)) { LOGGER.log(fineLevel, "{}{}", commitRequest, database.getId()); conn.rollback(); if (LOGGER.isLoggable(fineLevel)) { LOGGER.log(fineLevel, "Rolback of the {}", database.getId()); LOGGER.log(UjoLogger.ERROR, "{}{}", errMessage, database, e); throw new IllegalUjormException(errMessage + database, e);
private static UjoLogger newUjoLoggerBridge2Slf4j(@Nonnull Class name) { UjoLogger result; try { result = new UjoLoggerBridge2Slf4j(name); if (showLog) { showLog = false; result.log(Level.FINEST, "Ujorm logging is switched to the SLF4J."); } } catch (RuntimeException | NoClassDefFoundError | OutOfMemoryError e) { slf4jSupport = false; result = new UjoLoggerFactory(name); result.log(Level.INFO, "Ujorm logging is switched to the JUL."); } return result; }
final String schemaOrig = schemas.getString(isCatalog ? 2 : 1); final String schemaUpper = toUpperCase(schemaOrig); if (LOGGER.isLoggable(levelTrace)) { LOGGER.log(levelTrace, "DB schema: {}.{} by catalog: {}" , schemas.getString(2) , schemas.getString(1) LOGGER.log(levelTrace, "The db schema '{}' already exists", schemaOrig); requiredSchemas.remove(schemaUpper);