public class DatabaseHandler extends AbstractWranglerHandler
| Modifier and Type | Class and Description |
|---|---|
static interface |
DatabaseHandler.Executor
Executes something using a SQL connection.
|
AbstractWranglerHandler.NamespacedResponder<T>| Constructor and Description |
|---|
DatabaseHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
initialize(io.cdap.cdap.api.service.http.SystemHttpServiceContext context) |
void |
listAvailableDrivers(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace)
List all the possible drivers supported.
|
void |
listDatabases(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace)
Lists all databases.
|
void |
listDrivers(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace)
Lists all the JDBC drivers installed.
|
void |
listTables(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace,
String id)
Lists all the tables within a database.
|
void |
read(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace,
String id,
String table,
int lines,
String scope)
Reads a table into workspace.
|
void |
specification(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace,
String id,
String table)
Specification for the source.
|
void |
testConnection(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
String namespace) |
getConnection, getValidatedConnection, getValidatedConnection, getWorkspace, respond, respond, shouldCopyHeadercreateTableconfigure, configure, destroy, getConfigurer, getContext, setPropertiesusePlugin, usePlugin, usePluginClass, usePluginClasspublic void initialize(io.cdap.cdap.api.service.http.SystemHttpServiceContext context)
throws Exception
initialize in interface io.cdap.cdap.api.ProgramLifecycle<io.cdap.cdap.api.service.http.SystemHttpServiceContext>initialize in interface io.cdap.cdap.api.service.http.HttpServiceHandler<io.cdap.cdap.api.service.http.SystemHttpServiceContext,io.cdap.cdap.api.service.http.SystemHttpServiceConfigurer>initialize in class io.cdap.cdap.api.service.http.AbstractHttpServiceHandler<io.cdap.cdap.api.service.http.SystemHttpServiceContext,io.cdap.cdap.api.service.http.SystemHttpServiceConfigurer>Exception@GET
@Path(value="contexts/{context}/jdbc/drivers")
public void listDrivers(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace)
Following is JSON Response { "count": 1, "message": "Success", "status": 200, "values": [ { "label": "MySQL", "version": "5.1.39" "url": "jdbc:mysql://${hostname}:${port}/${database}?user=${username}&password=${password}" "default.port" : "3306", "properties": { "class": "com.mysql.jdbc.Driver", "name": "mysql", "type": "jdbc", }, "required" : [ "hostname", "port", "database", "username", "password", "url" ] } ] }
request - HTTP request handler.responder - HTTP response handler.@GET
@Path(value="contexts/{context}/jdbc/allowed")
public void listAvailableDrivers(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace)
request - HTTP request handler.responder - HTTP response handler.@POST
@Path(value="contexts/{context}/connections/jdbc/test")
public void testConnection(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace)
@POST
@Path(value="contexts/{context}/connections/databases")
public void listDatabases(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace)
request - HTTP requests handler.responder - HTTP response handler.@GET
@Path(value="contexts/{context}/connections/{id}/tables")
public void listTables(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace,
@PathParam(value="id")
String id)
request - HTTP requests handler.responder - HTTP response handler.id - Connection id for which the tables need to be listed from database.@GET
@Path(value="contexts/{context}/connections/{id}/tables/{table}/read")
public void read(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace,
@PathParam(value="id")
String id,
@PathParam(value="table")
String table,
@QueryParam(value="lines")
int lines,
@QueryParam(value="scope") @DefaultValue(value="default")
String scope)
request - HTTP requests handler.responder - HTTP response handler.id - Connection id for which the tables need to be listed from database.table - Name of the database table.lines - No of lines to be read from RDBMS table.scope - Group the workspace should be created in.@GET
@Path(value="contexts/{context}/connections/{id}/tables/{table}/specification")
public void specification(io.cdap.cdap.api.service.http.HttpServiceRequest request,
io.cdap.cdap.api.service.http.HttpServiceResponder responder,
@PathParam(value="context")
String namespace,
@PathParam(value="id")
String id,
@PathParam(value="table")
String table)
request - HTTP request handler.responder - HTTP response handler.id - of the connection.table - in the database.Copyright © 2020 CDAP Licensed under the Apache License, Version 2.0.