Skip to content

Commit

Permalink
IGNITE-15188 JDBC driver for 3.0: Database metadata (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladErmakov07 authored Sep 17, 2021
1 parent 83fcbbd commit 1f1ca6c
Show file tree
Hide file tree
Showing 29 changed files with 4,488 additions and 310 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@

import org.apache.ignite.client.proto.query.event.BatchExecuteRequest;
import org.apache.ignite.client.proto.query.event.BatchExecuteResult;
import org.apache.ignite.client.proto.query.event.JdbcMetaColumnsRequest;
import org.apache.ignite.client.proto.query.event.JdbcMetaColumnsResult;
import org.apache.ignite.client.proto.query.event.JdbcMetaPrimaryKeysRequest;
import org.apache.ignite.client.proto.query.event.JdbcMetaPrimaryKeysResult;
import org.apache.ignite.client.proto.query.event.JdbcMetaSchemasRequest;
import org.apache.ignite.client.proto.query.event.JdbcMetaSchemasResult;
import org.apache.ignite.client.proto.query.event.JdbcMetaTablesRequest;
import org.apache.ignite.client.proto.query.event.JdbcMetaTablesResult;
import org.apache.ignite.client.proto.query.event.QueryCloseRequest;
import org.apache.ignite.client.proto.query.event.QueryCloseResult;
import org.apache.ignite.client.proto.query.event.QueryExecuteRequest;
Expand Down Expand Up @@ -61,4 +69,36 @@ public interface JdbcQueryEventHandler {
* @return Result.
*/
QueryCloseResult close(QueryCloseRequest req);

/**
* {@link JdbcMetaTablesRequest} command handler.
*
* @param req Jdbc tables metadata request.
* @return Result.
*/
JdbcMetaTablesResult tablesMeta(JdbcMetaTablesRequest req);

/**
* {@link JdbcMetaColumnsRequest} command handler.
*
* @param req Jdbc columns metadata request.
* @return Result.
*/
JdbcMetaColumnsResult columnsMeta(JdbcMetaColumnsRequest req);

/**
* {@link JdbcMetaSchemasRequest} command handler.
*
* @param req Jdbc schemas metadata request.
* @return Result.
*/
JdbcMetaSchemasResult schemasMeta(JdbcMetaSchemasRequest req);

/**
* {@link JdbcMetaPrimaryKeysRequest} command handler.
*
* @param req Jdbc primary keys metadata request.
* @return Result.
*/
JdbcMetaPrimaryKeysResult primaryKeysMeta(JdbcMetaPrimaryKeysRequest req);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.client.proto.query.event;

import org.apache.ignite.internal.client.proto.ClientMessagePacker;
import org.apache.ignite.internal.client.proto.ClientMessageUnpacker;

/**
* Client message utils class.
*/
public class ClientMessageUtils {
/**
* Packs a string or null if string is null.
*
* @param packer Message packer.
* @param str String to serialize.
*/
public static void writeStringNullable(ClientMessagePacker packer, String str) {
if (str == null)
packer.packNil();
else
packer.packString(str);
}

/**
* Unpack a string or null if no string is presented.
*
* @param unpacker Message unpacker.
* @return String or null.
*/
public static String readStringNullable(ClientMessageUnpacker unpacker) {
if (!unpacker.tryUnpackNil())
return unpacker.unpackString();

return null;
}
}
Loading

0 comments on commit 1f1ca6c

Please sign in to comment.