-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathDB2ConnectionImpl.java
More file actions
61 lines (55 loc) · 2.11 KB
/
Copy pathDB2ConnectionImpl.java
File metadata and controls
61 lines (55 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (C) 2019,2020 IBM Corporation
*
* Licensed 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 io.vertx.db2client.impl;
import io.vertx.core.Context;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.internal.ContextInternal;
import io.vertx.db2client.DB2ConnectOptions;
import io.vertx.db2client.DB2Connection;
import io.vertx.db2client.impl.command.PingCommand;
import io.vertx.db2client.spi.DB2Driver;
import io.vertx.sqlclient.spi.connection.Connection;
import io.vertx.sqlclient.internal.SqlConnectionBase;
import io.vertx.sqlclient.spi.connection.ConnectionFactory;
public class DB2ConnectionImpl extends SqlConnectionBase<DB2ConnectionImpl> implements DB2Connection {
public static Future<DB2Connection> connect(Vertx vertx, DB2ConnectOptions options) {
ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext();
DB2ConnectionFactory client;
try {
client = new DB2ConnectionFactory(ctx.owner());
} catch (Exception e) {
return ctx.failedFuture(e);
}
return client.connect((Context)ctx, options).map(conn -> {
DB2ConnectionImpl impl = new DB2ConnectionImpl(ctx, client, conn);
conn.init(impl);
prepareForClose(ctx, impl);
return impl;
});
}
public DB2ConnectionImpl(ContextInternal context, ConnectionFactory factory, Connection conn) {
super(context, factory, conn, DB2Driver.INSTANCE);
}
@Override
public Future<Void> ping() {
return schedule(context, new PingCommand());
}
@Override
public Future<Void> debug() {
throw new UnsupportedOperationException("Debug command not implemented");
}
}