Package ch.inftec.ju.db

Examples of ch.inftec.ju.db.JuDbException


    } else {
      try {
        // Export whole DB
        return conn.createDataSet();
      } catch (Exception ex) {
        throw new JuDbException("Couldn't export whole DB");
      }
    }
  }
View Full Code Here


          }
        }
       
        dataSet.addTable(actualTableName, this.query);
      } catch (AmbiguousTableNameException ex) {
        throw new JuDbException(String.format("Couldn't add table %s to QueryDataSet: %s", this.tableName, this.query), ex);
      }
    }
View Full Code Here

        this.schemaName = this.connUtil.getMetaDataInfo().getUserName();
      }
      dataTypeFactory = new Oracle10DataTypeFactory();
      break;
    default:
      throw new JuDbException("Unsupported DB: " + this.connUtil.getDbType());
    }
   
    this.setConfigProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, dataTypeFactory);
    this.setConfigProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, metadataHandler);
  }
View Full Code Here

    Connection unwrappedConn = null;
    if (this.connUtil.getDbType() == DbType.ORACLE && connection instanceof Proxy) {
      try {
        unwrappedConn = connection.unwrap(Connection.class);
      } catch (Exception ex) {
        throw new JuDbException("Couldn't unwrap Connection", ex);
      }
    }
    final Connection realConn = unwrappedConn != null
        ? unwrappedConn
        : connection;
   
    try {
      // Check if we get the same connection. If so, we'll recycle the DatabaseConnection to avoid
      // requerying of all the DB meta data
      if (this.dbConn == null || this.dbConn.getConnection() != connection) {
        this.dbConn = new DatabaseConnection(realConn, this.schemaName);
       
        for (String key : this.configProperties.keySet()) {
          this.dbConn.getConfig().setProperty(key, this.configProperties.get(key));
        }
        logger.debug("Created DatabaseConnection: {}", this.dbConn);
      } else {
        // Use existing DatabaseConnection
        logger.info("Reusing DatabaseConnection {}", this.dbConn.getConnection());
      }
      work.execute(this.dbConn);
    } catch (Exception ex) {
      throw new JuDbException("Couldn't execute DbUnitWork", ex);
    }
  }
View Full Code Here

     
      updateQry.addText(" WHERE " + this.getPrimaryKeyValue().getColumnName() + "=?");
      changedVals[i] = this.getPrimaryKeyValue().getOriginalValue();
     
      int res = this.getDbConnection().getQueryRunner().update(updateQry.toString(), changedVals);
      if (res != 1) throw new JuDbException("Execution of query returned " + res + ", expected 1: " + updateQry);
    } catch (Exception ex) {
      throw new JuRuntimeException("Failed to execute update: " + updateQry, ex);
    }
  }
View Full Code Here

    XString deleteQry = null;
    try {
      deleteQry = new XString("DELETE FROM " + this.getTableName() + " WHERE " + this.getPrimaryKeyValue().getColumnName() + "=?");

      int res = this.getDbConnection().getQueryRunner().update(deleteQry.toString(), this.getPrimaryKeyValue().getOriginalValue());
      if (res != 1) throw new JuDbException("Execution of query returned " + res + ", expected 1: " + deleteQry);
    } catch (Exception ex) {
      throw new JuRuntimeException("Failed to execute delete: " + deleteQry, ex);
    }
  }
View Full Code Here

      insertQry.addText(") ");
      insertQry.addText(valuesQry);
      insertQry.addText(")");
           
      int res = this.getDbConnection().getQueryRunner().update(insertQry.toString(), (Object[])values.toArray(new Object[0]));
      if (res != 1) throw new JuDbException("Execution of query returned " + res + ", expected 1: " + insertQry);
    } catch (Exception ex) {
      throw new JuRuntimeException("Failed to execute insert: " + insertQry, ex);
    }
  }
View Full Code Here

   */
  public AuthUser addUser(String userName, String password) {
    // Make sure the user doesn't exist yet
    // TODO: Use AssertUtil
    if (this.getUser(userName) != null) {
      throw new JuDbException("User already exists: " + userName);
    }
    if (password == null) {
      throw new JuRuntimeException("Password must not be null");
    }
   
View Full Code Here

TOP

Related Classes of ch.inftec.ju.db.JuDbException

Copyright © 2018 www.massapicom. 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.