Examples of PGSQLExceptionInfo


Examples of com.impossibl.postgres.api.jdbc.PGSQLExceptionInfo

    try {
      stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, 1)");
      fail("Should have thrown a duplicate key exception.");
    }
    catch (SQLException e) {
      PGSQLExceptionInfo sqle = (PGSQLExceptionInfo) e;
      assertEquals("public", sqle.getSchema());
      assertEquals("testerr", sqle.getTable());
      assertEquals("testerr_pk", sqle.getConstraint());
      assertNull(sqle.getDatatype());
      assertNull(sqle.getColumn());
    }

    stmt.close();
  }
View Full Code Here

Examples of com.impossibl.postgres.api.jdbc.PGSQLExceptionInfo

    try {
      stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, NULL)");
      fail("Should have thrown a not null constraint violation.");
    }
    catch (SQLException e) {
      PGSQLExceptionInfo sqle = (PGSQLExceptionInfo) e;
      assertEquals("public", sqle.getSchema());
      assertEquals("testerr", sqle.getTable());
      assertEquals("val", sqle.getColumn());
      assertNull(sqle.getDatatype());
      assertNull(sqle.getConstraint());
    }

    stmt.close();
  }
View Full Code Here

Examples of com.impossibl.postgres.api.jdbc.PGSQLExceptionInfo

    try {
      stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, 20)");
      fail("Should have thrown a constraint violation.");
    }
    catch (SQLException e) {
      PGSQLExceptionInfo sqle = (PGSQLExceptionInfo) e;
      assertEquals("public", sqle.getSchema());
      assertEquals("testdom", sqle.getDatatype());
      assertEquals("testdom_check", sqle.getConstraint());
    }

    stmt.close();
  }
View Full Code Here

Examples of com.impossibl.postgres.api.jdbc.PGSQLExceptionInfo

   *          Notice to convert
   * @return SQLException
   */
  public static SQLException makeSQLException(String message, Notice notice) {

    PGSQLExceptionInfo e;

    String code = notice.getCode();

    if (code.startsWith("23")) {

      e = new PGSQLIntegrityConstraintViolationException(message + nullToEmpty(notice.getMessage()), notice.getCode());

    }
    else {

      e = new PGSQLSimpleException(message + nullToEmpty(notice.getMessage()), notice.getCode());

    }

    //Copy extended error information (9.3+)
    e.setSchema(notice.getSchema());
    e.setTable(notice.getTable());
    e.setColumn(notice.getColumn());
    e.setDatatype(notice.getDatatype());
    e.setConstraint(notice.getConstraint());

    return (SQLException) e;
  }
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.