com.mysql.cj.exceptions.WrongArgumentException Java Examples
The following examples show how to use
com.mysql.cj.exceptions.WrongArgumentException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultPropertySet.java From lams with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public <T> ModifiableProperty<T> getModifiableProperty(String name) { RuntimeProperty<?> prop = this.PROPERTY_NAME_TO_RUNTIME_PROPERTY.get(name); if (prop != null) { if (ModifiableProperty.class.isAssignableFrom(prop.getClass())) { try { return (ModifiableProperty<T>) this.PROPERTY_NAME_TO_RUNTIME_PROPERTY.get(name); } catch (ClassCastException ex) { // TODO improve message throw ExceptionFactory.createException(WrongArgumentException.class, ex.getMessage(), ex); } } throw ExceptionFactory.createException(PropertyNotModifiableException.class, Messages.getString("ConnectionProperties.dynamicChangeIsNotAllowed", new Object[] { "'" + prop.getPropertyDefinition().getName() + "'" })); } throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ConnectionProperties.notFound", new Object[] { name })); }
Example #2
Source File: ServerPreparedQuery.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Sends stream-type data parameters to the server. * * <pre> * Long data handling: * * - Server gets the long data in pieces with command type 'COM_LONG_DATA'. * - The packet received will have the format: * [COM_LONG_DATA: 1][STMT_ID:4][parameter_number:2][type:2][data] * - Checks if the type is specified by client, and if yes reads the type, * and stores the data in that format. * - It is up to the client to check for read data ended. The server does not * care; and also server does not notify to the client that it got the * data or not; if there is any error; then during execute; the error * will be returned * </pre> * * @param parameterIndex * @param longData * */ private void serverLongData(int parameterIndex, ServerPreparedQueryBindValue longData) { synchronized (this) { NativePacketPayload packet = this.session.getSharedSendPacket(); Object value = longData.value; if (value instanceof byte[]) { this.session.sendCommand(this.commandBuilder.buildComStmtSendLongData(packet, this.serverStatementId, parameterIndex, (byte[]) value), true, 0); } else if (value instanceof InputStream) { storeStream(parameterIndex, packet, (InputStream) value); } else if (value instanceof java.sql.Blob) { try { storeStream(parameterIndex, packet, ((java.sql.Blob) value).getBinaryStream()); } catch (Throwable t) { throw ExceptionFactory.createException(t.getMessage(), this.session.getExceptionInterceptor()); } } else if (value instanceof Reader) { storeReader(parameterIndex, packet, (Reader) value); } else { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ServerPreparedStatement.18") + value.getClass().getName() + "'", this.session.getExceptionInterceptor()); } } }
Example #3
Source File: ExprParser.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Parse a JSON-style document path, like WL#7909, but prefix by @. instead of $. * * @return list of {@link DocumentPathItem} objects */ public List<DocumentPathItem> documentPath() { List<DocumentPathItem> items = new ArrayList<>(); while (true) { if (currentTokenTypeEquals(TokenType.DOT)) { items.add(docPathMember()); } else if (currentTokenTypeEquals(TokenType.DOTSTAR)) { consumeToken(TokenType.DOTSTAR); items.add(DocumentPathItem.newBuilder().setType(DocumentPathItem.Type.MEMBER_ASTERISK).build()); } else if (currentTokenTypeEquals(TokenType.LSQBRACKET)) { items.add(docPathArrayLoc()); } else if (currentTokenTypeEquals(TokenType.DOUBLESTAR)) { consumeToken(TokenType.DOUBLESTAR); items.add(DocumentPathItem.newBuilder().setType(DocumentPathItem.Type.DOUBLE_ASTERISK).build()); } else { break; } } if (items.size() > 0 && items.get(items.size() - 1).getType() == DocumentPathItem.Type.DOUBLE_ASTERISK) { throw new WrongArgumentException("JSON path may not end in '**' at " + this.tokenPos); } return items; }
Example #4
Source File: Util.java From lams with GNU General Public License v2.0 | 6 votes |
public static <T> List<T> loadClasses(String extensionClassNames, String errorMessageKey, ExceptionInterceptor exceptionInterceptor) { List<T> instances = new LinkedList<>(); List<String> interceptorsToCreate = StringUtils.split(extensionClassNames, ",", true); String className = null; try { for (int i = 0, s = interceptorsToCreate.size(); i < s; i++) { className = interceptorsToCreate.get(i); @SuppressWarnings("unchecked") T instance = (T) Class.forName(className).newInstance(); instances.add(instance); } } catch (Throwable t) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString(errorMessageKey, new Object[] { className }), t, exceptionInterceptor); } return instances; }
Example #5
Source File: NativePacketPayload.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Read len bytes from internal buffer starting from current position decoding them into String using the specified character encoding. * * @param type * @param encoding * if null then platform default encoding is used * @param len * @return */ public String readString(StringLengthDataType type, String encoding, int len) { String res = null; switch (type) { case STRING_FIXED: case STRING_VAR: if ((this.position + len) > this.payloadLength) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("Buffer.1")); } res = StringUtils.toString(this.byteBuffer, this.position, len, encoding); this.position += len; break; } return res; }
Example #6
Source File: ResultSetFactory.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public ResultSetImpl createFromProtocolEntity(ProtocolEntity protocolEntity) { try { if (protocolEntity instanceof OkPacket) { return new ResultSetImpl((OkPacket) protocolEntity, this.conn, this.stmt); } else if (protocolEntity instanceof ResultsetRows) { int resultSetConcurrency = getResultSetConcurrency().getIntValue(); int resultSetType = getResultSetType().getIntValue(); return createFromResultsetRows(resultSetConcurrency, resultSetType, (ResultsetRows) protocolEntity); } throw ExceptionFactory.createException(WrongArgumentException.class, "Unknown ProtocolEntity class " + protocolEntity); } catch (SQLException ex) { throw ExceptionFactory.createException(ex.getMessage(), ex); } }
Example #7
Source File: AbstractQueryBindings.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Sets the value for the placeholder as a serialized Java object (used by various forms of setObject() * * @param parameterIndex * @param parameterObj */ protected final void setSerializableObject(int parameterIndex, Object parameterObj) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut); objectOut.writeObject(parameterObj); objectOut.flush(); objectOut.close(); bytesOut.flush(); bytesOut.close(); byte[] buf = bytesOut.toByteArray(); ByteArrayInputStream bytesIn = new ByteArrayInputStream(buf); setBinaryStream(parameterIndex, bytesIn, buf.length); this.bindValues[parameterIndex].setMysqlType(MysqlType.BINARY); } catch (Exception ex) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("PreparedStatement.54") + ex.getClass().getName(), ex, this.session.getExceptionInterceptor()); } }
Example #8
Source File: ExprParser.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Parse a document path array index. * * @return {@link DocumentPathItem} */ DocumentPathItem docPathArrayLoc() { DocumentPathItem.Builder builder = DocumentPathItem.newBuilder(); consumeToken(TokenType.LSQBRACKET); if (currentTokenTypeEquals(TokenType.STAR)) { consumeToken(TokenType.STAR); consumeToken(TokenType.RSQBRACKET); return builder.setType(DocumentPathItem.Type.ARRAY_INDEX_ASTERISK).build(); } else if (currentTokenTypeEquals(TokenType.LNUM_INT)) { Integer v = Integer.valueOf(this.tokens.get(this.tokenPos).value); if (v < 0) { throw new WrongArgumentException("Array index cannot be negative at " + this.tokenPos); } consumeToken(TokenType.LNUM_INT); consumeToken(TokenType.RSQBRACKET); return builder.setType(DocumentPathItem.Type.ARRAY_INDEX).setIndex(v).build(); } else { throw new WrongArgumentException("Expected token type STAR or LNUM_INT in JSON path array index at token pos " + this.tokenPos); } }
Example #9
Source File: StringUtils.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Returns the byte[] representation of subset of the given char[] using the given encoding. * * @param value * chars * @param offset * offset * @param length * length * @param encoding * java encoding * @return bytes */ public static byte[] getBytes(char[] value, int offset, int length, String encoding) { Charset cs; try { if (encoding == null) { cs = Charset.defaultCharset(); } else { cs = Charset.forName(encoding); } } catch (UnsupportedCharsetException ex) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("StringUtils.0", new Object[] { encoding }), ex); } ByteBuffer buf = cs.encode(CharBuffer.wrap(value, offset, length)); // can't simply .array() this to get the bytes especially with variable-length charsets the buffer is sometimes larger than the actual encoded data int encodedLen = buf.limit(); byte[] asBytes = new byte[encodedLen]; buf.get(asBytes, 0, encodedLen); return asBytes; }
Example #10
Source File: NativeAuthenticationProvider.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Get authentication plugin instance from authentication plugins map by * pluginName key. If such plugin is found it's {@link AuthenticationPlugin#isReusable()} method * is checked, when it's false this method returns a new instance of plugin * and the same instance otherwise. * * If plugin is not found method returns null, in such case the subsequent behavior * of handshake process depends on type of last packet received from server: * if it was Auth Challenge Packet then handshake will proceed with default plugin, * if it was Auth Method Switch Request Packet then handshake will be interrupted with exception. * * @param pluginName * mysql protocol plugin names, for example "mysql_native_password" and "mysql_old_password" for built-in plugins * @return null if plugin is not found or authentication plugin instance initialized with current connection properties */ @SuppressWarnings("unchecked") private AuthenticationPlugin<NativePacketPayload> getAuthenticationPlugin(String pluginName) { AuthenticationPlugin<NativePacketPayload> plugin = this.authenticationPlugins.get(pluginName); if (plugin != null && !plugin.isReusable()) { try { plugin = plugin.getClass().newInstance(); plugin.init(this.protocol); } catch (Throwable t) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("AuthenticationProvider.BadAuthenticationPlugin", new Object[] { plugin.getClass().getName() }), t, getExceptionInterceptor()); } } return plugin; }
Example #11
Source File: NativeAuthenticationProvider.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Add plugin to authentication plugins map if it is not disabled by * "disabledAuthenticationPlugins" property, check is it a default plugin. * * @param plugin * Instance of AuthenticationPlugin * @return True if plugin is default, false if plugin is not default. * @throws WrongArgumentException * if plugin is default but disabled. */ private boolean addAuthenticationPlugin(AuthenticationPlugin<NativePacketPayload> plugin) { boolean isDefault = false; String pluginClassName = plugin.getClass().getName(); String pluginProtocolName = plugin.getProtocolPluginName(); boolean disabledByClassName = this.disabledAuthenticationPlugins != null && this.disabledAuthenticationPlugins.contains(pluginClassName); boolean disabledByMechanism = this.disabledAuthenticationPlugins != null && this.disabledAuthenticationPlugins.contains(pluginProtocolName); if (disabledByClassName || disabledByMechanism) { // if disabled then check is it default if (this.clientDefaultAuthenticationPlugin.equals(pluginClassName)) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("AuthenticationProvider.BadDisabledAuthenticationPlugin", new Object[] { disabledByClassName ? pluginClassName : pluginProtocolName }), getExceptionInterceptor()); } } else { this.authenticationPlugins.put(pluginProtocolName, plugin); if (this.clientDefaultAuthenticationPlugin.equals(pluginClassName)) { this.clientDefaultAuthenticationPluginName = pluginProtocolName; isDefault = true; } } return isDefault; }
Example #12
Source File: ExprParser.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Parse a document path member. * * @return {@link DocumentPathItem} */ DocumentPathItem docPathMember() { consumeToken(TokenType.DOT); Token t = this.tokens.get(this.tokenPos); String memberName; if (currentTokenTypeEquals(TokenType.IDENT)) { // this shouldn't be allowed to be quoted with backticks, but the lexer allows it if (!t.value.equals(ExprUnparser.quoteIdentifier(t.value))) { throw new WrongArgumentException("'" + t.value + "' is not a valid JSON/ECMAScript identifier"); } consumeToken(TokenType.IDENT); memberName = t.value; } else if (currentTokenTypeEquals(TokenType.LSTRING)) { consumeToken(TokenType.LSTRING); memberName = t.value; } else { throw new WrongArgumentException("Expected token type IDENT or LSTRING in JSON path at token pos " + this.tokenPos); } DocumentPathItem.Builder item = DocumentPathItem.newBuilder(); item.setType(DocumentPathItem.Type.MEMBER); item.setValue(memberName); return item.build(); }
Example #13
Source File: StatementExecuteOkMessageListener.java From lams with GNU General Public License v2.0 | 6 votes |
public Boolean createFromMessage(XMessage message) { //GeneratedMessage msg = (GeneratedMessage) message.getMessage(); @SuppressWarnings("unchecked") Class<? extends GeneratedMessage> msgClass = (Class<? extends GeneratedMessage>) message.getMessage().getClass(); if (Frame.class.equals(msgClass)) { this.builder.addNotice(this.noticeFactory.createFromMessage(message)); return false; /* done reading? */ } else if (StmtExecuteOk.class.equals(msgClass)) { this.future.complete(this.builder.build()); return true; /* done reading? */ } else if (Error.class.equals(msgClass)) { this.future.completeExceptionally(new XProtocolError(Error.class.cast(message.getMessage()))); return true; /* done reading? */ } else if (FetchDone.class.equals(msgClass)) { return false; /* done reading? */ } this.future.completeExceptionally(new WrongArgumentException("Unhandled msg class (" + msgClass + ") + msg=" + message.getMessage())); return true; /* done reading? */ }
Example #14
Source File: XProtocol.java From lams with GNU General Public License v2.0 | 6 votes |
public void readAuthenticateOk() { try { XMessageHeader header; while ((header = this.reader.readHeader()).getMessageType() == ServerMessages.Type.NOTICE_VALUE) { Notice notice = this.noticeFactory.createFromMessage(this.reader.readMessage(null, header)); if (notice.getType() == Notice.XProtocolNoticeFrameType_SESS_STATE_CHANGED) { switch (notice.getParamType()) { case Notice.SessionStateChanged_CLIENT_ID_ASSIGNED: this.getServerSession().setThreadId(notice.getValue().getVUnsignedInt()); break; case Notice.SessionStateChanged_ACCOUNT_EXPIRED: // TODO default: throw new WrongArgumentException("Unknown SessionStateChanged notice received during authentication: " + notice.getParamType()); } } else { throw new WrongArgumentException("Unknown notice received during authentication: " + notice); } } this.reader.readMessage(null, ServerMessages.Type.SESS_AUTHENTICATE_OK_VALUE); } catch (IOException e) { throw new XProtocolError(e.getMessage(), e); } }
Example #15
Source File: SyncMessageReader.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public XMessage readMessage(Optional<XMessage> reuse, int expectedType) throws IOException { try { Class<? extends GeneratedMessage> messageClass = MessageConstants.getMessageClassForType(readHeader().getMessageType()); Class<? extends GeneratedMessage> expectedClass = MessageConstants.getMessageClassForType(expectedType); // ensure that parsed message class matches incoming tag if (expectedClass != messageClass) { throw new WrongArgumentException("Unexpected message class. Expected '" + expectedClass.getSimpleName() + "' but actually received '" + messageClass.getSimpleName() + "'"); } return new XMessage(readAndParse(messageClass)); } catch (IOException e) { throw new XProtocolError(e.getMessage(), e); } }
Example #16
Source File: NoticeFactory.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public Notice createFromMessage(XMessage message) { Frame notice = (Frame) message.getMessage(); switch (notice.getType()) { case Notice.XProtocolNoticeFrameType_WARNING: com.mysql.cj.x.protobuf.MysqlxNotice.Warning warn = parseNotice((notice).getPayload(), com.mysql.cj.x.protobuf.MysqlxNotice.Warning.class); return new Notice(warn.getLevel().getNumber(), Integer.toUnsignedLong(warn.getCode()), warn.getMsg()); case Notice.XProtocolNoticeFrameType_SESS_VAR_CHANGED: SessionVariableChanged svmsg = parseNotice(notice.getPayload(), SessionVariableChanged.class); return new Notice(svmsg.getParam(), svmsg.getValue()); case Notice.XProtocolNoticeFrameType_SESS_STATE_CHANGED: SessionStateChanged ssmsg = parseNotice(notice.getPayload(), SessionStateChanged.class); return new Notice(ssmsg.getParam().getNumber(), ssmsg.getValueList()); default: // TODO log error normally instead of sysout new WrongArgumentException("Got an unknown notice: " + notice).printStackTrace(); break; } return null; }
Example #17
Source File: ConnectionUrlParser.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Parses a host:port pair and returns the two elements in a {@link Pair} * * @param hostInfo * the host:pair to parse * @return a {@link Pair} containing the host and port information or null if the host information can't be parsed */ public static Pair<String, Integer> parseHostPortPair(String hostInfo) { if (isNullOrEmpty(hostInfo)) { return null; } Matcher matcher = GENERIC_HOST_PTRN.matcher(hostInfo); if (matcher.matches()) { String host = matcher.group("host"); String portAsString = decode(safeTrim(matcher.group("port"))); Integer portAsInteger = -1; if (!isNullOrEmpty(portAsString)) { try { portAsInteger = Integer.parseInt(portAsString); } catch (NumberFormatException e) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ConnectionString.3", new Object[] { hostInfo }), e); } } return new Pair<>(host, portAsInteger); } throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ConnectionString.3", new Object[] { hostInfo })); }
Example #18
Source File: ConnectionUrlParser.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Takes a two-matching-groups (respectively named "key" and "value") pattern which is successively tested against the given string and produces a key/value * map with the matched values. The given pattern must ensure that there are no leftovers between successive tests, i.e., the end of the previous match must * coincide with the beginning of the next. * * @param pattern * the regular expression pattern to match against to * @param input * the input string * @return a key/value map containing the matched values */ private Map<String, String> processKeyValuePattern(Pattern pattern, String input) { Matcher matcher = pattern.matcher(input); int p = 0; Map<String, String> kvMap = new HashMap<>(); while (matcher.find()) { if (matcher.start() != p) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ConnectionString.4", new Object[] { input.substring(p) })); } String key = decode(safeTrim(matcher.group("key"))); String value = decode(safeTrim(matcher.group("value"))); if (!isNullOrEmpty(key)) { kvMap.put(key, value); } else if (!isNullOrEmpty(value)) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ConnectionString.4", new Object[] { input.substring(p) })); } p = matcher.end(); } if (p != input.length()) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("ConnectionString.4", new Object[] { input.substring(p) })); } return kvMap; }
Example #19
Source File: ModifiableMemorySizeProperty.java From lams with GNU General Public License v2.0 | 6 votes |
void setValue(int intValue, String valueAsString, ExceptionInterceptor exceptionInterceptor) { if (getPropertyDefinition().isRangeBased()) { if ((intValue < getPropertyDefinition().getLowerBound()) || (intValue > getPropertyDefinition().getUpperBound())) { throw ExceptionFactory.createException(WrongArgumentException.class, "The connection property '" + getPropertyDefinition().getName() + "' only accepts integer values in the range of " + getPropertyDefinition().getLowerBound() + " - " + getPropertyDefinition().getUpperBound() + ", the value '" + (valueAsString == null ? intValue : valueAsString) + "' exceeds this range.", exceptionInterceptor); } } this.value = Integer.valueOf(intValue); this.valueAsString = valueAsString == null ? String.valueOf(intValue) : valueAsString; this.wasExplicitlySet = true; invokeListeners(); }
Example #20
Source File: ExprUtil.java From lams with GNU General Public License v2.0 | 5 votes |
public static Scalar argObjectToScalar(Object value) { Expr e = argObjectToExpr(value, false); if (!e.hasLiteral()) { throw new WrongArgumentException("No literal interpretation of argument: " + value); } return e.getLiteral(); }
Example #21
Source File: JsonParser.java From lams with GNU General Public License v2.0 | 5 votes |
private static String nextKey(StringReader reader) throws IOException { reader.mark(1); JsonString val = parseString(reader); if (val == null) { reader.reset(); } // find delimiter int intch; char ch = ' '; while ((intch = reader.read()) != -1) { ch = (char) intch; if (ch == StructuralToken.COLON.CHAR) { // key/value delimiter found break; } else if (ch == StructuralToken.RCRBRACKET.CHAR) { // end of document break; } else if (!whitespaceChars.contains(ch)) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("JsonParser.1", new Character[] { ch })); } } if (ch != StructuralToken.COLON.CHAR && val != null && val.getString().length() > 0) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("JsonParser.4", new String[] { val.getString() })); } return val != null ? val.getString() : null; }
Example #22
Source File: LongPropertyDefinition.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Long parseObject(String value, ExceptionInterceptor exceptionInterceptor) { try { // Parse decimals, too return Double.valueOf(value).longValue(); } catch (NumberFormatException nfe) { throw ExceptionFactory.createException(WrongArgumentException.class, "The connection property '" + getName() + "' only accepts long integer values. The value '" + value + "' can not be converted to a long integer.", exceptionInterceptor); } }
Example #23
Source File: AbstractDataResult.java From lams with GNU General Public License v2.0 | 5 votes |
public List<T> fetchAll() { if (this.position > -1) { throw new WrongArgumentException("Cannot fetchAll() after starting iteration"); } if (this.all == null) { this.all = new ArrayList<>((int) count()); this.rows.forEachRemaining(r -> this.all.add(this.rowToData.createFromProtocolEntity(r))); this.all = Collections.unmodifiableList(this.all); } return this.all; }
Example #24
Source File: AbstractDataResult.java From lams with GNU General Public License v2.0 | 5 votes |
public T next() { if (this.all != null) { throw new WrongArgumentException("Cannot iterate after fetchAll()"); } Row r = this.rows.next(); if (r == null) { throw new NoSuchElementException(); } this.position++; return this.rowToData.createFromProtocolEntity(r); }
Example #25
Source File: FilterParams.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Verify that all arguments are bound. * * @throws WrongArgumentException * if any placeholder argument is not bound */ public void verifyAllArgsBound() { if (this.args != null) { IntStream.range(0, this.args.length) // find unbound params .filter(i -> this.args[i] == null) // get the parameter name from the map .mapToObj(i -> this.placeholderNameToPosition.entrySet().stream().filter(e -> e.getValue() == i).map(Map.Entry::getKey).findFirst().get()) .forEach(name -> { throw new WrongArgumentException("Placeholder '" + name + "' is not bound"); }); } }
Example #26
Source File: FilterParams.java From lams with GNU General Public License v2.0 | 5 votes |
public void addArg(String name, Object value) { if (this.args == null) { throw new WrongArgumentException("No placeholders"); } if (this.placeholderNameToPosition.get(name) == null) { throw new WrongArgumentException("Unknown placeholder: " + name); } this.args[this.placeholderNameToPosition.get(name)] = ExprUtil.argObjectToScalar(value); }
Example #27
Source File: SchemaImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public Table getTable(String tableName, boolean requireExists) { TableImpl table = new TableImpl(this.mysqlxSession, this, tableName); if (requireExists && table.existsInDatabase() != DbObjectStatus.EXISTS) { throw new WrongArgumentException(table.toString() + " doesn't exist"); } return table; }
Example #28
Source File: DefaultPropertySet.java From lams with GNU General Public License v2.0 | 5 votes |
public void initializeProperties(Properties props) { if (props != null) { Properties infoCopy = (Properties) props.clone(); // TODO do we need to remove next properties (as it was before)? infoCopy.remove(PropertyDefinitions.HOST_PROPERTY_KEY); infoCopy.remove(PropertyDefinitions.PNAME_user); infoCopy.remove(PropertyDefinitions.PNAME_password); infoCopy.remove(PropertyDefinitions.DBNAME_PROPERTY_KEY); infoCopy.remove(PropertyDefinitions.PORT_PROPERTY_KEY); for (String propName : PropertyDefinitions.PROPERTY_NAME_TO_PROPERTY_DEFINITION.keySet()) { try { ReadableProperty<?> propToSet = getReadableProperty(propName); propToSet.initializeFrom(infoCopy, null); } catch (CJException e) { throw ExceptionFactory.createException(WrongArgumentException.class, e.getMessage(), e); } } // add user-defined properties for (Object key : infoCopy.keySet()) { String val = infoCopy.getProperty((String) key); PropertyDefinition<String> def = new StringPropertyDefinition((String) key, null, val, PropertyDefinitions.RUNTIME_MODIFIABLE, Messages.getString("ConnectionProperties.unknown"), "8.0.10", PropertyDefinitions.CATEGORY_USER_DEFINED, Integer.MIN_VALUE); RuntimeProperty<String> p = new ModifiableStringProperty(def); addProperty(p); } postInitialization(); } }
Example #29
Source File: JsonParser.java From lams with GNU General Public License v2.0 | 5 votes |
private static void appendChar(StringBuilder sb, char ch) { if (sb == null) { if (!whitespaceChars.contains(ch)) { throw ExceptionFactory.createException(WrongArgumentException.class, Messages.getString("JsonParser.6", new Character[] { ch })); } } else { sb.append(ch); } }
Example #30
Source File: StatementExecuteOkBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
public void addNotice(Notice notice) { if (notice.getType() == Notice.XProtocolNoticeFrameType_WARNING) { this.warnings.add(notice); } else if (notice.getType() == Notice.XProtocolNoticeFrameType_SESS_STATE_CHANGED) { switch (notice.getParamType()) { case Notice.SessionStateChanged_GENERATED_INSERT_ID: // TODO: handle > 2^63-1? this.lastInsertId = notice.getValue().getVUnsignedInt(); break; case Notice.SessionStateChanged_ROWS_AFFECTED: // TODO: handle > 2^63-1? this.rowsAffected = notice.getValue().getVUnsignedInt(); break; case Notice.SessionStateChanged_PRODUCED_MESSAGE: // TODO do something with notices. expose them to client //System.err.println("Ignoring NOTICE message: " + msg.getValue().getVString().getValue().toStringUtf8()); break; case Notice.SessionStateChanged_GENERATED_DOCUMENT_IDS: this.generatedIds = notice.getValueList().stream().map(v -> v.getVOctets().getValue().toStringUtf8()).collect(Collectors.toList()); break; case Notice.SessionStateChanged_CURRENT_SCHEMA: case Notice.SessionStateChanged_ACCOUNT_EXPIRED: case Notice.SessionStateChanged_ROWS_FOUND: case Notice.SessionStateChanged_ROWS_MATCHED: case Notice.SessionStateChanged_TRX_COMMITTED: case Notice.SessionStateChanged_TRX_ROLLEDBACK: // TODO: propagate state default: // TODO: log warning normally instead of sysout new WrongArgumentException("unhandled SessionStateChanged notice! " + notice).printStackTrace(); } } else { // TODO log error normally instead of sysout new WrongArgumentException("Got an unknown notice: " + notice).printStackTrace(); } }