public static byte[] utf8Encode(String s) throws SQLException { try { // TODO UTF8: String.getBytes("UTF-8") only returns 1 byte for // 0xd800-0xdfff return s.getBytes(Constants.UTF8); } catch (UnsupportedEncodingException e) { throw Message.convert(e); } }
private int read() throws SQLException { try { return reader.read(); } catch (IOException e) { throw Message.convertIOException(e, null); } }
private static byte[] getKeyStoreBytes(KeyStore store, String password) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { store.store(bout, KEYSTORE_PASSWORD.toCharArray()); } catch (Exception e) { throw Message.convertToIOException(e); } return bout.toByteArray(); }
public long getFilePointer() throws SQLException { if (SysProperties.CHECK2) { try { if (file.getFilePointer() != filePos) { throw Message.getInternalError(); } } catch (IOException e) { throw Message.convertIOException(e, name); } } return filePos; }
private ValueDecimal(BigDecimal value) { if (value == null) { throw new IllegalArgumentException(); } else if (!SysProperties.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) { SQLException e = Message.getSQLException(ErrorCode.INVALID_CLASS_2, new String[] { BigDecimal.class.getName(), value.getClass().getName() }); throw Message.convertToInternal(e); } this.value = value; }
private void checkHoldability(int resultSetHoldability) throws SQLException { // TODO compatibility / correctness: DBPool uses // ResultSet.HOLD_CURSORS_OVER_COMMIT //## Java 1.4 begin ## if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT && resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) { throw Message.getInvalidValueException("" + resultSetHoldability, "resultSetHoldability"); } //## Java 1.4 end ## }
public String getState() { switch(state) { case IN_DOUBT: return "IN_DOUBT"; case COMMIT: return "COMMIT"; case ROLLBACK: return "ROLLBACK"; default: throw Message.getInternalError("state="+state); } }
/** * [Not supported] */ public int getInt(int parameterIndex) throws SQLException { throw Message.getUnsupportedException(); }
public static String utf8Decode(byte[] bytes, int offset, int length) { try { return new String(bytes, offset, length, Constants.UTF8); } catch (UnsupportedEncodingException e) { throw Message.convertToInternal(e); } }
private void checkRunOver(int i, int len, String sql) throws SQLException { if (i >= len) { throw Message.getSyntaxError(sql, i); } }
public SQLException getFormatException() { String format = Constants.URL_FORMAT; return Message.getSQLException(ErrorCode.URL_FORMAT_ERROR_2, new String[] { format, url }); } }
int j = sql.indexOf('\'', i + 1); if (j < 0) { throw Message.getSyntaxError(sql, i); int j = sql.indexOf('"', i + 1); if (j < 0) { throw Message.getSyntaxError(sql, i); throw Message.getSyntaxError(sql, i); throw Message.getInternalError("c=" + c);
public String getString() { int len = precision > Integer.MAX_VALUE || precision == 0 ? Integer.MAX_VALUE : (int) precision; try { if (type == Value.CLOB) { if (small != null) { return StringUtils.utf8Decode(small); } return IOUtils.readStringAndClose(getReader(), len); } else { byte[] buff; if (small != null) { buff = small; } else { buff = IOUtils.readBytesAndClose(getInputStream(), len); } return ByteUtils.convertBytesToString(buff); } } catch (IOException e) { throw Message.convertToInternal(Message.convertIOException(e, fileName)); } catch (SQLException e) { throw Message.convertToInternal(e); } }
private Prepared parse(String sql) throws SQLException { Prepared p; try { // first, try the fast variant p = parse(sql, false); } catch (SQLException e) { if (e.getErrorCode() == ErrorCode.SYNTAX_ERROR_1) { // now, get the detailed exception p = parse(sql, true); } else { throw Message.addSQL(e, sql); } } p.setPrepareAlways(recompileAlways); p.setParameterList(parameters); return p; }
public static BigDecimal setScale(BigDecimal bd, int scale) throws SQLException { if (scale > Constants.BIG_DECIMAL_SCALE_MAX) { throw Message.getInvalidValueException("" + scale, "scale"); } else if (scale < 0) { throw Message.getInvalidValueException("" + scale, "scale"); } return bd.setScale(scale, BigDecimal.ROUND_HALF_UP); }
public void setPos(int pos) { if (SysProperties.CHECK && (previous != null || next != null || chained != null)) { throw Message.getInternalError("setPos too late"); } this.pos = pos; }
/** * [Not supported] * */ public URL getURL(String parameterName) throws SQLException { throw Message.getUnsupportedException(); }
public static String utf8Decode(byte[] utf8) { try { return new String(utf8, Constants.UTF8); } catch (UnsupportedEncodingException e) { throw Message.convertToInternal(e); } }
private String readColumnIdentifier() throws SQLException { if (currentTokenType != IDENTIFIER) { throw Message.getSyntaxError(sqlCommand, parseIndex, "identifier"); } String s = currentToken; read(); return s; }