private void logDatabaseInfo() throws ServletException {
   SessionHelper helper = RetsServer.createHelper();
   try {
     Session session = helper.beginSession();
     Connection connection = session.connection();
     DatabaseMetaData metaData = connection.getMetaData();
     LOGGER.info(
         "JDBC Driver info: "
             + metaData.getDriverName()
             + " version "
             + metaData.getDriverVersion());
     LOGGER.info(
         "JDBC DB info: "
             + metaData.getDatabaseProductName()
             + " version "
             + metaData.getDatabaseProductVersion());
   } catch (SQLException e) {
     throw new ServletException("Caught", e);
   } catch (HibernateException e) {
     throw new ServletException("Caught", e);
   } finally {
     try {
       helper.close();
     } catch (HibernateException e) {
       throw new ServletException(e);
     }
   }
 }
Ejemplo n.º 2
0
 protected void doRets(RetsServletRequest request, RetsServletResponse response)
     throws RetsServerException, IOException {
   GetObjectParameters parameters = new GetObjectParameters(request.getParameterMap());
   GetObjectTransaction transaction = new GetObjectTransaction(parameters);
   RetsConfig retsConfig = RetsServer.getRetsConfiguration();
   transaction.setRootDirectory(retsConfig.getGetObjectRoot());
   transaction.setPhotoPattern(retsConfig.getPhotoPattern());
   transaction.setObjectSetPattern(retsConfig.getObjectSetPattern());
   StringBuffer location = ServletUtils.getContextPath(request);
   location.append("/objects/");
   transaction.setBaseLocationUrl(location.toString());
   transaction.execute(new Response(response));
 }
  private void createData() throws RetsServerException, SQLException {

    PreparedStatement ps = null;
    ConnectionHelper helper = RetsServer.createHelper();
    try {
      Connection con = helper.getConnectionTransaction();
      ps =
          con.prepareStatement(
              "INSERT INTO "
                  + "rets_property_res(id,r_lp,r_broker,r_agent_id,r_ln,"
                  + "                  r_zip_code,r_ld,r_sqft,r_e_school,"
                  + "                  r_m_school,r_h_school,r_stname,r_url,"
                  + "                  r_ltyp, r_stnum, r_vew, r_ar,r_status,"
                  + "                  r_owner)"
                  + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
      for (int i = 0; i < mNumProperties; i++) {
        // todo: LookupMulti EF needs to be added.
        // todo: LookupMulti IF needs to be added.
        mCount += mRandom.nextInt(10);
        ps.setInt(1, i);
        ps.setInt(2, mRandom.nextInt(1000000));

        ps.setString(3, getNextBroker());
        ps.setString(4, getNextAgent());

        ps.setString(5, "LN" + Long.toHexString(i));

        ps.setInt(6, mRandom.nextInt(99999));
        ps.setDate(7, getNextDate());

        ps.setString(8, Long.toString(mRandom.nextInt(7000)));
        ps.setInt(9, getNextSchool());
        ps.setInt(10, getNextSchool());
        ps.setInt(11, getNextSchool());

        ps.setString(12, getNextStreet());
        ps.setString(13, getNextURL());
        ps.setString(14, getNextListingType());
        ps.setString(15, Long.toString(mRandom.nextInt(9999999)));
        ps.setInt(16, mRandom.nextInt(2048));
        ps.setString(17, getNextLocation());
        ps.setString(18, getNextStatus());
        ps.setString(19, getNextOwner());
        ps.execute();
      }
      ps.close();
      helper.commit();
    } finally {
      helper.close(LOG);
    }
  }
  private void dropData() throws RetsServerException, SQLException {
    ConnectionHelper helper = RetsServer.createHelper();
    Connection connection = null;
    Statement statement = null;
    try {
      connection = helper.getConnection();
      statement = connection.createStatement();

      statement.execute("delete from rets_property_res");
      helper.commit();
    } finally {
      if (statement != null) statement.close();
      helper.close(LOG);
    }
  }