Package org.postgresql.util

Examples of org.postgresql.util.ServerErrorMessage


        // so, append messages to a string buffer and keep processing
        // check at the bottom to see if we need to throw an exception

        int elen = pgStream.ReceiveInteger4();
        String totalMessage = pgStream.ReceiveString(elen - 4);
        ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage, logger.getLogLevel());

        if (logger.logDebug())
            logger.debug(" <=BE ErrorMessage(" + errorMsg.toString() + ")");

        return new PSQLException(errorMsg);
    }
View Full Code Here


        return new PSQLException(errorMsg);
    }

    private SQLWarning receiveNoticeResponse() throws IOException {
        int nlen = pgStream.ReceiveInteger4();
        ServerErrorMessage warnMsg = new ServerErrorMessage(pgStream.ReceiveString(nlen - 4), logger.getLogLevel());

        if (logger.logDebug())
            logger.debug(" <=BE NoticeResponse(" + warnMsg.toString() + ")");

        return new PSQLWarning(warnMsg);
    }
View Full Code Here

                    // if the error length is > than 30000 we assume this is really a v2 protocol
                    // server, so trigger fallback.
                    throw new UnsupportedProtocolException();
                }

                ServerErrorMessage errorMsg = new ServerErrorMessage(pgStream.ReceiveString(l_elen - 4), logger.getLogLevel());
                if (logger.logDebug())
                    logger.debug(" <=BE ErrorMessage(" + errorMsg + ")");
                throw new PSQLException(errorMsg);

            case 'R':
View Full Code Here

                break;

            case 'E':
                // Error
                int l_elen = pgStream.ReceiveInteger4();
                ServerErrorMessage l_errorMsg = new ServerErrorMessage(pgStream.ReceiveString(l_elen - 4), logger.getLogLevel());

                if (logger.logDebug())
                    logger.debug(" <=BE ErrorMessage(" + l_errorMsg + ")");

                throw new PSQLException(l_errorMsg);

            case 'N':
                // Warning
                int l_nlen = pgStream.ReceiveInteger4();
                ServerErrorMessage l_warnMsg = new ServerErrorMessage(pgStream.ReceiveString(l_nlen - 4), logger.getLogLevel());

                if (logger.logDebug())
                    logger.debug(" <=BE NoticeResponse(" + l_warnMsg + ")");

                protoConnection.addWarning(new PSQLWarning(l_warnMsg));
View Full Code Here

        // so, append messages to a string buffer and keep processing
        // check at the bottom to see if we need to throw an exception

        int elen = pgStream.ReceiveInteger4();
        String totalMessage = pgStream.ReceiveString(elen - 4);
        ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage, logger.getLogLevel());

        if (logger.logDebug())
            logger.debug(" <=BE ErrorMessage(" + errorMsg.toString() + ")");

        return new PSQLException(errorMsg);
    }
View Full Code Here

        return new PSQLException(errorMsg);
    }

    private SQLWarning receiveNoticeResponse() throws IOException {
        int nlen = pgStream.ReceiveInteger4();
        ServerErrorMessage warnMsg = new ServerErrorMessage(pgStream.ReceiveString(nlen - 4), logger.getLogLevel());

        if (logger.logDebug())
            logger.debug(" <=BE NoticeResponse(" + warnMsg.toString() + ")");

        return new PSQLWarning(warnMsg);
    }
View Full Code Here

        stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, 1)");
        try {
            stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, 1)");
            fail("Should have thrown a duplicate key exception.");
        } catch (SQLException sqle) {
            ServerErrorMessage err = ((PSQLException)sqle).getServerErrorMessage();
            assertEquals("public", err.getSchema());
            assertEquals("testerr", err.getTable());
            assertEquals("testerr_pk", err.getConstraint());
            assertNull(err.getDatatype());
            assertNull(err.getColumn());
        }
        stmt.close();
    }
View Full Code Here

        Statement stmt = con.createStatement();
        try {
            stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, NULL)");
            fail("Should have thrown a not null constraint violation.");
        } catch (SQLException sqle) {
            ServerErrorMessage err = ((PSQLException)sqle).getServerErrorMessage();
            assertEquals("public", err.getSchema());
            assertEquals("testerr", err.getTable());
            assertEquals("val", err.getColumn());
            assertNull(err.getDatatype());
            assertNull(err.getConstraint());
        }
        stmt.close();
    }
View Full Code Here

        Statement stmt = con.createStatement();
        try {
            stmt.executeUpdate("INSERT INTO testerr (id, val) VALUES (1, 20)");
            fail("Should have thrown a constraint violation.");
        } catch (SQLException sqle) {
            ServerErrorMessage err = ((PSQLException)sqle).getServerErrorMessage();
            assertEquals("public", err.getSchema());
            assertEquals("testdom", err.getDatatype());
            assertEquals("testdom_check", err.getConstraint());
        }
        stmt.close();
    }
View Full Code Here

        // so, append messages to a string buffer and keep processing
        // check at the bottom to see if we need to throw an exception

        int elen = pgStream.ReceiveInteger4();
        String totalMessage = pgStream.ReceiveString(elen - 4);
        ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage, logger.getLogLevel());

        if (logger.logDebug())
            logger.debug(" <=BE ErrorMessage(" + errorMsg.toString() + ")");

        return new PSQLException(errorMsg);
    }
View Full Code Here

TOP

Related Classes of org.postgresql.util.ServerErrorMessage

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.