Ejemplo n.º 1
0
 @ChromeDevtoolsMethod
 public JsonRpcResult executeSQL(JsonRpcPeer peer, JSONObject params) {
   ExecuteSQLRequest request = mObjectMapper.convertValue(params, ExecuteSQLRequest.class);
   try {
     return mDatabasePeerManager.executeSQL(
         request.databaseId,
         request.query,
         new DatabasePeerManager.ExecuteResultHandler<ExecuteSQLResponse>() {
           @Override
           public ExecuteSQLResponse handleResult(Cursor result) throws SQLiteException {
             ExecuteSQLResponse response = new ExecuteSQLResponse();
             response.columnNames = Arrays.asList(result.getColumnNames());
             response.values = flattenRows(result, MAX_EXECUTE_RESULTS);
             return response;
           }
         });
   } catch (SQLiteException e) {
     Error error = new Error();
     error.code = 0;
     error.message = e.getMessage();
     ExecuteSQLResponse response = new ExecuteSQLResponse();
     response.sqlError = error;
     return response;
   }
 }
Ejemplo n.º 2
0
 @ChromeDevtoolsMethod
 public JsonRpcResult getDatabaseTableNames(JsonRpcPeer peer, JSONObject params) {
   GetDatabaseTableNamesRequest request =
       mObjectMapper.convertValue(params, GetDatabaseTableNamesRequest.class);
   GetDatabaseTableNamesResponse response = new GetDatabaseTableNamesResponse();
   response.tableNames = mDatabasePeerManager.getDatabaseTableNames(request.databaseId);
   return response;
 }