Java 8 StatementEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StatementEvent class.

This code example shows how to use the following methods:
 
    /** 
     * @tests serialization/deserialization compatibility with RI. 
     */ 
    public void testSerializationCompatibility() throws Exception { 
        StatementEvent st3 = new StatementEvent(pc, null, new SQLException(
                "test message")); 
        SerializationTest.verifyGolden(this, st3, STATEMENTEVENT_COMPARATOR);
    } 
 
    private static final SerializableAssert STATEMENTEVENT_COMPARATOR = new SerializableAssert() {
 
        public void assertDeserialized(Serializable initial, 
                Serializable deserialized) { 
            StatementEvent iniSt = (StatementEvent) initial; 
            StatementEvent dserSt = (StatementEvent) deserialized; 
            if (null != iniSt.getSQLException()) { 
                assertEquals(iniSt.getSQLException().getMessage(), dserSt 
                        .getSQLException().getMessage()); 
            } 
4
CodeRank
This code example shows how to use the following methods:getSQLException, getStatement
 
        testSubject.addStatementEventListener(new StatementEventListener() {
            @Override 
            public void statementClosed(StatementEvent event) {
                statementClosedEventOccured[0] = true;
                statementClosedEventException[0] = event.getSQLException();
                statementClosedEventStatement[0] = event.getStatement();
            } 
 
            @Override 
            public void statementErrorOccurred(StatementEvent event) {
                statementErrorEventOccured[0] = true;
                statementErrorEventException[0] = event.getSQLException();
                statementErrorEventStatement[0] = event.getStatement();
            } 
        }); 
 
        assertEquals(false, connectionClosedEventOccured[0]);
        assertEquals(false, connection.isClosed());
 
4
CodeRank
This code example shows how to use the following methods:getSQLException, getStatement
This code example shows how to use the following methods:
 
  protected StatementEvent createStatementEvent(PreparedStatement ps, SQLException sqle) {
    if (sqle == null)
      return new StatementEvent(this, ps);
    else 
      return new StatementEvent(this, ps, sqle);
  } 
 
  /** 
   * Used to fire a statement closed event to all listeners. 
   */ 
  void fireStatementClosed(PreparedStatement ps) {
    StatementEvent evt = null;
    // Copy the listener list so the listener can remove itself during this method call 
    StatementEventListener[] local = (StatementEventListener[]) statementListeners.toArray(new StatementEventListener[statementListeners.size()]);
    for (int i = 0; i < local.length; i++) {
      StatementEventListener listener = local[i];
      if (evt == null) {
        evt = createStatementEvent(ps, null);
      } 
3
CodeRank
See Code Examples for Java 8 StatementEvent Methods: