private static void checkByte(int ch, int pos, int len) throws IOException { if ((ch & 0xc0) != 0x80) { throw new IOException( GT.tr("Illegal UTF-8 sequence: byte {0} of {1} byte sequence is not 10xxxxxx: {2}", pos, len, ch)); } }
private void checkClosed() throws IOException { if (op == null) { throw new IOException(GT.tr("This copy stream is closed.")); } }
private void checkClosed() throws IOException { if (op == null) { throw new IOException(GT.tr("This copy stream is closed.")); } }
private void checkClosed() throws IOException { if (op == null) { throw new IOException(GT.tr("This copy stream is closed.")); } }
public ServerErrorMessage(EncodingPredictor.DecodeResult serverError) { this(serverError.result); if (serverError.encoding != null) { m_mesgParts.put(MESSAGE, m_mesgParts.get(MESSAGE) + GT.tr(" (pgjdbc: autodetected server-encoding to be {0}, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf)", serverError.encoding) ); } }
public void handleCommandStatus(String status) throws PSQLException { if (status.startsWith("COPY")) { int i = status.lastIndexOf(' '); handledRowCount = i > 3 ? Long.parseLong(status.substring(i + 1)) : -1; } else { throw new PSQLException(GT.tr("CommandComplete expected COPY but got: " + status), PSQLState.COMMUNICATION_ERROR); } }
private static PSQLException cannotCastException(final String fromType, final String toType, final Exception cause) { return new PSQLException( GT.tr("Cannot convert an instance of {0} to type {1}", fromType, toType), PSQLState.INVALID_PARAMETER_TYPE, cause); }
public static double toDouble(String s) throws SQLException { if (s != null) { try { s = s.trim(); return Double.parseDouble(s); } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Bad value for type {0} : {1}", "double", s), PSQLState.NUMERIC_VALUE_OUT_OF_RANGE); } } return 0; // SQL NULL }
/** * Does nothing, since we don't do heuristics. */ @Override public void forget(Xid xid) throws XAException { throw new PGXAException(GT.tr("Heuristic commit/rollback not supported. forget xid={0}", xid), XAException.XAER_NOTA); }
public String getSavepointName() throws SQLException { if (!_isValid) { throw new PSQLException(GT.tr("Cannot reference a savepoint after it has been released."), PSQLState.INVALID_SAVEPOINT_SPECIFICATION); } if (!_isNamed) { throw new PSQLException(GT.tr("Cannot retrieve the name of an unnamed savepoint."), PSQLState.WRONG_OBJECT_TYPE); } return _name; }
private void checkFreed() throws SQLException { if (_freed) { throw new PSQLException(GT.tr("This SQLXML object has already been freed."), PSQLState.OBJECT_NOT_IN_STATE); } }
private void initialize() throws SQLException { if (_initialized) { throw new PSQLException( GT.tr( "This SQLXML object has already been initialized, so you cannot manipulate it further."), PSQLState.OBJECT_NOT_IN_STATE); } _initialized = true; }
public java.sql.ResultSet executeQuery(String p_sql) throws SQLException { throw new PSQLException( GT.tr("Can''t use query methods that take a query string on a PreparedStatement."), PSQLState.WRONG_OBJECT_TYPE); }
private static String twoArgumentsFunctionCall(String call, String functionName, List<?> parsedArgs) throws PSQLException { if (parsedArgs.size() != 2) { throw new PSQLException(GT.tr("{0} function takes two and only two arguments.", functionName), PSQLState.SYNTAX_ERROR); } StringBuilder buf = new StringBuilder(); buf.append(call); buf.append(parsedArgs.get(0)).append(',').append(parsedArgs.get(1)); return buf.append(')').toString(); } }
@Override public void registerOutParameter(int index, int sqlType) throws SQLException { if (index < 1 || index > paramValues.length) { throw new PSQLException( GT.tr("The column index is out of range: {0}, number of columns: {1}.", index, paramValues.length), PSQLState.INVALID_PARAMETER_VALUE); } flags[index - 1] |= OUT; }
protected void handleCopydata(byte[] data) throws PSQLException { throw new PSQLException(GT.tr("CopyIn copy direction can't receive data"), PSQLState.PROTOCOL_VIOLATION); } }
public int executeUpdate(String p_sql) throws SQLException { throw new PSQLException( GT.tr("Can''t use query methods that take a query string on a PreparedStatement."), PSQLState.WRONG_OBJECT_TYPE); }
protected void checkColumnIndex(int column) throws SQLException { if (column < 1 || column > fields.length) { throw new PSQLException( GT.tr("The column index is out of range: {0}, number of columns: {1}.", column, fields.length), PSQLState.INVALID_PARAMETER_VALUE); } }
public static BigDecimal toBigDecimal(String s) throws SQLException { if (s == null) { return null; } try { s = s.trim(); return new BigDecimal(s); } catch (NumberFormatException e) { throw new PSQLException(GT.tr("Bad value for type {0} : {1}", "BigDecimal", s), PSQLState.NUMERIC_VALUE_OUT_OF_RANGE); } }
private BigDecimal scaleBigDecimal(BigDecimal val, int scale) throws PSQLException { if (scale == -1) { return val; } try { return val.setScale(scale); } catch (ArithmeticException e) { throw new PSQLException( GT.tr("Bad value for type {0} : {1}", "BigDecimal", val), PSQLState.NUMERIC_VALUE_OUT_OF_RANGE); } }