Examples of DatabaseConnection


Examples of com.j256.ormlite.support.DatabaseConnection

     */
    return getReadWriteConnection();
  }

  public DatabaseConnection getReadWriteConnection() throws SQLException {
    DatabaseConnection conn = getSavedConnection();
    if (conn != null) {
      return conn;
    }
    if (connection == null) {
      connection = new AndroidDatabaseConnection(helper.getWritableDatabase(), true);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

    /*
     * The method is called by Android database helper's get-database calls when Android detects that we need to
     * create or update the database. So we have to use the database argument and save a connection to it on the
     * AndroidConnectionSource, otherwise it will go recursive if the subclass calls getConnectionSource().
     */
    DatabaseConnection conn = cs.getSpecialConnection();
    boolean clearSpecial = false;
    if (conn == null) {
      conn = new AndroidDatabaseConnection(db, true);
      try {
        cs.saveSpecialConnection(conn);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

    /*
     * The method is called by Android database helper's get-database calls when Android detects that we need to
     * create or update the database. So we have to use the database argument and save a connection to it on the
     * AndroidConnectionSource, otherwise it will go recursive if the subclass calls getConnectionSource().
     */
    DatabaseConnection conn = cs.getSpecialConnection();
    boolean clearSpecial = false;
    if (conn == null) {
      conn = new AndroidDatabaseConnection(db, true);
      try {
        cs.saveSpecialConnection(conn);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

        foreignIdField.assignField(foreignObject, val);
      } else {
        levelCounters.autoRefreshlevel++;
        try {
          // do we need to auto-refresh the field?
          DatabaseConnection databaseConnection = connectionSource.getReadOnlyConnection();
          try {
            foreignObject = mappedQueryForId.execute(databaseConnection, val);
          } finally {
            connectionSource.releaseConnection(databaseConnection);
          }
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

   * Same as {@link #callInTransaction(Callable)} except as a static method with a connection source.
   */
  public static <T> T callInTransaction(final ConnectionSource connectionSource, final Callable<T> callable)
      throws SQLException {

    DatabaseConnection connection = connectionSource.getReadWriteConnection();
    try {
      boolean saved = connectionSource.saveSpecialConnection(connection);
      return callInTransaction(connection, saved, connectionSource.getDatabaseType(), callable);
    } finally {
      // we should clear aggressively
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

  /**
   * Return a list of all of the data in the table that matches the {@link PreparedStmt}. Should be used carefully if
   * the table is large. Consider using the {@link Dao#iterator} if this is the case.
   */
  public RawResults queryForAllRawOld(ConnectionSource connectionSource, String query) throws SQLException {
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      String[] columnNames = extractColumnNames(compiledStatement);
      RawResultsWrapper rawResults =
          new RawResultsWrapper(connectionSource, connection, query, compiledStatement, columnNames, this);
      compiledStatement = null;
      connection = null;
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

  /**
   * Create and return an {@link SelectIterator} for the class using a prepared statement.
   */
  public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
      PreparedStmt<T> preparedStmt) throws SQLException {
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = preparedStmt.compile(connection);
      SelectIterator<T, ID> iterator =
          new SelectIterator<T, ID>(tableInfo.getDataClass(), classDao, preparedStmt, connectionSource,
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

  /**
   * Return on old RawResults object associated with an internal iterator that matches the query argument.
   */
  public RawResults buildOldIterator(ConnectionSource connectionSource, String query) throws SQLException {
    logger.debug("executing raw results iterator for: {}", query);
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      String[] columnNames = extractColumnNames(compiledStatement);
      RawResultsWrapper rawResults =
          new RawResultsWrapper(connectionSource, connection, query, compiledStatement, columnNames, this);
      compiledStatement = null;
      connection = null;
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

    logger.debug("executing raw query for: {}", query);
    if (arguments.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("query arguments: {}", (Object) arguments);
    }
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      assignStatementArguments(compiledStatement, arguments);
      String[] columnNames = extractColumnNames(compiledStatement);
      GenericRawResults<String[]> rawResults =
          new RawResultsImpl<String[]>(connectionSource, connection, query, String[].class,
              compiledStatement, columnNames, this);
View Full Code Here

Examples of com.j256.ormlite.support.DatabaseConnection

    logger.debug("executing raw query for: {}", query);
    if (arguments.length > 0) {
      // need to do the (Object) cast to force args to be a single object
      logger.trace("query arguments: {}", (Object) arguments);
    }
    DatabaseConnection connection = connectionSource.getReadOnlyConnection();
    CompiledStatement compiledStatement = null;
    try {
      compiledStatement = connection.compileStatement(query, StatementType.SELECT, noFieldTypes);
      assignStatementArguments(compiledStatement, arguments);
      String[] columnNames = extractColumnNames(compiledStatement);
      RawResultsImpl<UO> rawResults =
          new RawResultsImpl<UO>(connectionSource, connection, query, String[].class, compiledStatement,
              columnNames, new UserObjectRowMapper<UO>(rowMapper, columnNames, this));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.