Codota Logo
jodd.db
Code IndexAdd Codota to your IDE (free)

How to use jodd.db

Best Java code snippets using jodd.db (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: oblac/jodd

void storeNamedParameter(final String name, final int position) {
  DbQueryNamedParameter p = lookupNamedParameter(name);
  if (p == null) {
    p = new DbQueryNamedParameter(name);
    p.indices = new int[] {position};
    p.next = rootNP;
    rootNP = p;
  }
  else {
    p.add(position);
  }
}
origin: oblac/jodd

/**
 * {@inheritDoc}
 */
@Override
public Q autoClose() {
  super.autoClose();
  return _this();
}
origin: oblac/jodd

/**
 * Closes current session and remove the association from current thread.
 * @see jodd.db.DbSession#closeSession()
 */
@Override
public void closeSession() {
  ThreadDbSessionHolder.remove();
  super.closeSession();
}
origin: oblac/jodd

protected DbQueryBase(final DbOom dbOom) {
  this.dbOom = dbOom;
  this.forcePreparedStatement = dbOom.queryConfig().isForcePreparedStatement();
  this.type = dbOom.queryConfig().getType();
  this.concurrencyType = dbOom.queryConfig().getConcurrencyType();
  this.holdability = dbOom.queryConfig().getHoldability();
  this.debug = dbOom.queryConfig().isDebug();
  this.fetchSize = dbOom.queryConfig().getFetchSize();
  this.maxRows = dbOom.queryConfig().getMaxRows();
}
origin: oblac/jodd

/**
 * Creates new db session and assigns it to the current thread.
 * Closes already assigned session, if any exist. 
 * @param connectionProvider connection provider
 */
public DbThreadSession(final ConnectionProvider connectionProvider) {
  super(connectionProvider);
  final DbSession session = ThreadDbSessionHolder.get();
  if (session != null) {
    session.closeSession();
  }
  ThreadDbSessionHolder.set(this);
}
origin: oblac/jodd

/**
 * @see #setObject(String, Object, Class, int) 
 */
public Q setObject(final String param, final Object value, final Class<? extends SqlType> sqlTypeClass, final int dbSqlType) {
  init();
  final int[] positions = query.getNamedParameterIndices(param);
  for (final int position : positions) {
    setObject(position, value, sqlTypeClass, dbSqlType);
  }
  return _this();
}
origin: oblac/jodd

/**
 * Sets sql parameters from two arrays: names and values.
 */
public Q setObjects(final String[] names, final Object[] values) {
  init();
  if (names.length != values.length) {
    throw new DbSqlException(this, "Different number of parameter names and values");
  }
  for (int i = 0; i < names.length; i++) {
    setObject(names[i], values[i]);
  }
  return _this();
}
origin: oblac/jodd

public Q setNull(final String param, final int value, final String typeName) {
  initPrepared();
  final int[] positions = query.getNamedParameterIndices(param);
  try {
    for (final int position : positions) {
      preparedStatement.setNull(position, value, typeName);
    }
  } catch (SQLException sex) {
    throw new DbSqlException(this, "Failed to set null to parameter: " + param, sex);
  }
  return _this();
}
origin: oblac/jodd

/**
 * Closes the query and all created results sets and detaches itself from the session.
 */
@Override
@SuppressWarnings({"ClassReferencesSubclass"})
public void close() {
  final SQLException sqlException = closeQuery();
  connection = null;
  if (this.session != null) {
    this.session.detachQuery(this);
  }
  if (sqlException != null) {
    throw new DbSqlException("Close query error", sqlException);
  }
}
origin: oblac/jodd

/**
 * Closes all result sets created by this query. Query remains active.
 */
public Q closeAllResultSets() {
  final SQLException sex = closeQueryResultSets();
  if (sex != null) {
    throw new DbSqlException("Close associated ResultSets error", sex);
  }
  return _this();
}
origin: oblac/jodd

/**
 * Returns existing thread session, or new one if already not exist. If session doesn't exist, it will be created
 * using default connection provider.
 */
public static DbThreadSession getThreadSession() {
  DbThreadSession session = (DbThreadSession) ThreadDbSessionHolder.get();
  if (session == null) {
    session = new DbThreadSession();
  }
  return session;
}
origin: oblac/jodd

/**
 * Closes thread session.
 */
public static void closeThreadSession() {
  DbThreadSession session = (DbThreadSession) ThreadDbSessionHolder.get();
  if (session != null) {
    session.closeSession();
  }
}
origin: oblac/jodd

private void initPrepared() {
  init();
  if (preparedStatement == null) {
    throw new DbSqlException("Prepared statement not initialized.");
  }
}
private void initCallable() {
origin: oblac/jodd

  protected void assertTxIsActive() {
    assertSessionIsOpen();
    if (!txActive) {
      throw new DbSqlException("TX not available for this session");
    }
  }
}
origin: oblac/jodd

int[] getNamedParameterIndices(final String name) {
  final DbQueryNamedParameter p = lookupNamedParameter(name);
  if (p == null) {
    throw new DbSqlException("Named parameter not found: " + name + "\nQuery: " + sql);
  }
  return p.indices;
}
origin: oblac/jodd

/**
 * Creates a new query from {@link DbSession}.
 */
public DbQuery(final DbOom dbOom, final DbSession session, final String sqlString) {
  super(dbOom);
  initSession(session);
  this.session.attachQuery(this);
  this.sqlString = sqlString;
}
origin: oblac/jodd

/**
 * Initializes session. When not specified (i.e. is <code>null</code>),
 * session is fetched from session provider.
 */
protected void initSession(final DbSession session) {
  if (session != null) {
    this.session = session;
    return;
  }
  final DbSessionProvider dbSessionProvider = dbOom.sessionProvider();
  this.session = dbSessionProvider.getDbSession();
}
origin: oblac/jodd

public Q setNull(final String param, final int type) {
  initPrepared();
  final int[] positions = query.getNamedParameterIndices(param);
  try {
    for (final int position : positions) {
      preparedStatement.setNull(position, type);
    }
  } catch (SQLException sex) {
    throw new DbSqlException(this, "Failed to set null to parameter: " + param, sex);
  }
  return _this();
}
origin: oblac/jodd

private void initCallable() {
  init();
  if (callableStatement == null) {
    throw new DbSqlException("Callable statement not initialized.");
  }
}
origin: oblac/jodd

protected void assertTxIsClosed() {
  assertSessionIsOpen();
  if (txActive) {
    throw new DbSqlException("TX already started for this session");
  }
}
jodd.db

Most used classes

  • CoreConnectionPool
    A class for pre-allocating, recycling, and managing JDBC connections. It uses threads for opening a
  • DbOom
    Starting class that all DBOOM starts from. It encapsulate the database and works like a factory for
  • DbJtxTransactionManager
    jodd.jtx.JtxTransactionManager that uses only one JTX db resource type. Usually, applications have o
  • DbEntityDescriptor
    Holds all information about some entity type, such as table name and DbEntityColumnDescriptor.
  • DbOomQuery
    A simple ORM extension for DbQuery. OOM extension may map results to objects in two ways: * auto mod
  • DbOom$Builder,
  • DbQuery,
  • DbSession,
  • ConnectionProvider,
  • DbEntityManager,
  • DbColumn,
  • DbId,
  • DbTable,
  • DbPropsQueryMap,
  • DbQueryParser,
  • DbThreadSession,
  • DbTransactionMode,
  • ThreadDbSessionHolder,
  • ThreadDbSessionProvider
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now