Package siena

Examples of siena.SienaException


            try {
              out = new ObjectOutputStream(bos);
              out.writeObject(value);
              out.close();
            } catch (IOException e) {
              throw new SienaException(e);
            }  
           
            value = bos.toByteArray();
          }
          else if(Enum.class.isAssignableFrom(type)){
View Full Code Here


   
    if(jndi == null) {
      try {
        Class.forName(driver);
      } catch (ClassNotFoundException e) {
        throw new SienaException("Error while loading JDBC driver", e);
      }
    } else {
      try {
        InitialContext ctx = new InitialContext();
        dataSource = (DataSource) ctx.lookup(jndi);
      } catch (Exception e) {
        throw new SienaException("Error while looking up for JNDI resource: "+jndi, e);
      }
    }
  }
View Full Code Here

  public Connection getConnection() {
    if(dataSource != null) {
      try {
        return dataSource.getConnection();
      } catch (SQLException e) {
        throw new SienaException(e);
      }
    } else {
      Connection c = currentConnection.get();
      if(c == null) {
        try {
          c = DriverManager.getConnection(url, user, pass);
        } catch (SQLException e) {
          throw new SienaException(e);
        }
        currentConnection.set(c);
      }
      return c;
    }
View Full Code Here

      if(c != null) {
        currentConnection.remove();
        c.close();
      }
    } catch (SQLException e) {
      throw new SienaException(e);
    }
  }
View Full Code Here

      String cm = p.getProperty("transactions");
      if(cm != null) {
        try {
          connectionManager = (ConnectionManager) Class.forName(cm).newInstance();
        } catch (Exception e) {
          throw new SienaException(e);
        }
      } else {
        connectionManager = new ThreadedConnectionManager();
      }
    }
View Full Code Here

    try {
      ps = getConnection().prepareStatement(classInfo.deleteSQL);
      addParameters(obj, classInfo.keys, ps, 1);
      int n = ps.executeUpdate();
      if(n == 0) {
        throw new SienaException("No updated rows");
      }
      if(n > 1) {
        throw new SienaException(n+" rows deleted");
      }
    } catch(SQLException e) {
      throw new SienaException(e);
    } finally {
      JdbcDBUtils.closeStatementAndConnection(this, ps);
    }
  }
View Full Code Here

      addParameters(obj, classInfo.keys, ps, 1);
      rs = ps.executeQuery();
      if(rs.next()) {
        JdbcMappingUtils.mapObject(obj, rs, null, null);
      } else {
        throw new SienaException("No such object");
      }
    } catch(SQLException e) {
      throw new SienaException(e);
    } finally {
      JdbcDBUtils.closeResultSet(rs);
      JdbcDBUtils.closeStatementAndConnection(this, ps);
    }
  }
View Full Code Here

        ps.executeUpdate();
      }
    } catch (SienaException e) {
      throw e;
    } catch (Exception e) {
      throw new SienaException(e);
    } finally {
      JdbcDBUtils.closeStatementAndConnection(this, ps);
    }
  }
View Full Code Here

      int i = 1;
      i = addParameters(obj, classInfo.updateFields, ps, i);
      addParameters(obj, classInfo.keys, ps, i);
      ps.executeUpdate();
    } catch(SQLException e) {
      throw new SienaException(e);
    } finally {
      JdbcDBUtils.closeStatementAndConnection(this, ps);
    }
  }
View Full Code Here

      ps.executeUpdate();     
     
      if (idVal == null && !classInfo.generatedKeys.isEmpty()) {
        ResultSet gk = ps.getGeneratedKeys();
        if (!gk.next())
          throw new SienaException("No such generated keys");
        i = 1;
        for (Field field : classInfo.generatedKeys) {
          field.setAccessible(true);
          JdbcMappingUtils.setFromObject(obj, field, gk.getObject(i));
          // field.set(obj, gk.getObject(i));
          i++;
        }
      }
    } catch (SienaException e) {
      throw e;
    } catch (Exception e) {
      throw new SienaException(e);
    } finally {
      JdbcDBUtils.closeStatementAndConnection(this, ps);
    }
  }
View Full Code Here

TOP

Related Classes of siena.SienaException

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.