Package java.sql

Examples of java.sql.SQLException


        } else if (e instanceof IOException) {
            message = "IO exception";
        } else {
            message = "General exception";
        }
        SQLException e2 = new SQLException(message + ": " + e.toString());
        e2.initCause(e);
        return e2;
    }
View Full Code Here


            if (e instanceof OutOfMemoryError) {
                e.fillInStackTrace();
            }
            if (traceSystem != null) {
                if (e instanceof SQLException) {
                    SQLException e2 = (SQLException) e;
                    if (e2.getErrorCode() != ErrorCode.DATABASE_ALREADY_OPEN_1) {
                        // only write if the database is not already in use
                        trace.error(e, "opening {0}", databaseName);
                    }
                }
                traceSystem.close();
View Full Code Here

                    i++;
                }
                try {
                    m.invoke(rs, params);
                } catch (InvocationTargetException e) {
                    SQLException e2 = (SQLException) e.getTargetException();
                    assertEquals(ErrorCode.FEATURE_NOT_SUPPORTED_1, e2.getErrorCode());
                }
            }
        }
        assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
        assertEquals(0, rs.getFetchSize());
View Full Code Here

                }
            };
            t.execute();
            Thread.sleep(100);
            conn.close();
            SQLException e = (SQLException) t.getException();
            if (e != null) {
                if (ErrorCode.OBJECT_CLOSED != e.getErrorCode() &&
                        ErrorCode.STATEMENT_WAS_CANCELED != e.getErrorCode()) {
                    throw e;
                }
            }
        }
    }
View Full Code Here

            }
        };
        t.execute();
        Thread.sleep(100);
        prep.cancel();
        SQLException e = (SQLException) t.getException();
        assertTrue(e != null);
        assertEquals(ErrorCode.STATEMENT_WAS_CANCELED, e.getErrorCode());
        prep.setInt(1, 1);
        prep.setInt(2, 1);
        ResultSet rs = prep.executeQuery();
        assertTrue(rs.next());
        assertEquals(0, rs.getInt(1));
View Full Code Here

    private void checkDeadlock() throws SQLException {
        assertTrue(lastException != null);
        assertKnownException(lastException);
        assertEquals(ErrorCode.DEADLOCK_1, lastException.getErrorCode());
        SQLException e2 = lastException.getNextException();
        if (e2 != null) {
            // we have two exception, but there should only be one
            SQLException e3 = new SQLException("Expected one exception, got multiple");
            e3.initCause(e2);
            throw e3;
        }
    }
View Full Code Here

        }
    }

    private void execute(String sql) throws SQLException {
        String expected = null;
        SQLException e = null;
        for (Statement s : dbs) {
            try {
                boolean result = s.execute(sql);
                if (result) {
                    String data = getResult(s.getResultSet());
View Full Code Here

        rs.next();
        int count = rs.getInt(1);
        System.out.println("count: " + count);
        if (count % 2 != 0) {
            traceOperation("row count: " + count);
            throw new SQLException("Unexpected odd row count: " + count);
        }
    }
View Full Code Here

        execute(sql);
    }

    private void execute(String sql) throws SQLException {
        String expected = null;
        SQLException e = null;
        for (Statement s : dbs) {
            try {
                boolean result = s.execute(sql);
                if (result) {
                    String data = getResult(s.getResultSet());
                    if (expected == null) {
                        expected = data;
                    } else {
                        assertEquals(sql, expected, data);
                    }
                }
            } catch (AssertionError e2) {
                e = new SQLException(e2.getMessage());
            } catch (SQLException e2) {
                // ignore now, throw at the end
                e = e2;
            }
        }
View Full Code Here

    if (message != null) StringUtils.splitUp(buf, message, MAX_MESSAGE_WIDTH);
    if (t != null) {
  if (message != null) buf.append("\n");
  StringUtils.splitUp(buf, t.toString(), MAX_MESSAGE_WIDTH);
  if (t instanceof SQLException) {
      SQLException ex = (SQLException)t;
      ex = ex.getNextException();
      while (ex != null) {
    buf.append("\n");
    StringUtils.splitUp(buf, ex.toString(), MAX_MESSAGE_WIDTH);
    ex = ex.getNextException();
      }
  }
    }
    String errorMessage = buf.toString();
View Full Code Here

TOP

Related Classes of java.sql.SQLException

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.