public class

CartoSQLService

extends Object
java.lang.Object
   ↳ com.carto.services.CartoSQLService

Class Overview

A high-level interface for Carto SQL Service.
The service can be used to query data from Carto databases
using explicit SQL queries.

Summary

Public Constructors
CartoSQLService()
Constructs a new CartoSQLService service instance with default settings.
Public Methods
synchronized void delete()
boolean equals(Object obj)
Checks if this object is equal to the specified object.
String getAPIKey()
Returns the API key used when accessing the online service.
String getAPITemplate()
Returns the API endpoint template of the online service.
String getUsername()
Returns the user account name used when accessing the online service.
int hashCode()
Returns the hash value of this object.
Variant queryData(String sql)
Connects to the online service and performs the specified query,
The resulting JSON is deserialized into a Variant that is returned.
FeatureCollection queryFeatures(String sql, Projection proj)
Connects to the online service and performs the specified query.
void setAPIKey(String apiKey)
Sets the optional API key used when accessing the online service.
void setAPITemplate(String apiTemplate)
Sets the API endpoint template of the online service.
void setUsername(String username)
Sets the user account name used when accessing the online service.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CartoSQLService ()

Constructs a new CartoSQLService service instance with default settings.

Public Methods

public synchronized void delete ()

public boolean equals (Object obj)

Checks if this object is equal to the specified object.

Parameters
obj The reference object.
Returns
  • True when objects are equal, false otherwise.

public String getAPIKey ()

Returns the API key used when accessing the online service.

Returns
  • The API key used when accessing the online service.

public String getAPITemplate ()

Returns the API endpoint template of the online service.

Returns
  • The API endpoint template of the online service.

public String getUsername ()

Returns the user account name used when accessing the online service.

Returns
  • The user account name used when accessing the online service.

public int hashCode ()

Returns the hash value of this object.

Returns
  • The hash value of this object.

public Variant queryData (String sql)

Connects to the online service and performs the specified query,
The resulting JSON is deserialized into a Variant that is returned.

Parameters
sql The SQL query to use.
Returns
  • The query result. If query fails, null variant is returned.
Throws
Exception If IO error occured during the operation.
IOException

public FeatureCollection queryFeatures (String sql, Projection proj)

Connects to the online service and performs the specified query.
The resulting JSON is deserialized into a FeatureCollection that is returned.

Parameters
sql The SQL query to use.
proj The projection to use for transforming feature coordinates. Can be null for WGS84 coordinates.
Returns
  • The query result as feature collection. If query fails, null feature collection is returned.
Throws
Exception If IO error occured during the operation.
IOException

public void setAPIKey (String apiKey)

Sets the optional API key used when accessing the online service.
Usually this is not needed and can be left blank.

Parameters
apiKey The optional API key used when accessing the online service.

public void setAPITemplate (String apiTemplate)

Sets the API endpoint template of the online service.
By default cartodb.com endpoint is used. This needs to be redefined only for on-premise services.

Parameters
apiTemplate The API endpoint template of the online service. For example, "https://{user}.cartodb.com"

public void setUsername (String username)

Sets the user account name used when accessing the online service.

Parameters
username The user account name used when accessing the online service.