当前位置:网站首页>[in depth understanding of tcallusdb technology] insert data example code - [generic table]
[in depth understanding of tcallusdb technology] insert data example code - [generic table]
2022-04-22 15:14:00 【Database master】
Preparation of this paper
See Chapter : preparation .
Sample code
Sample code
import com.tencent.tcaplus.client.Client;
import com.tencent.tcaplus.client.ClientFactory;
import com.tencent.tcaplus.client.Record;
import com.tencent.tcaplus.client.Request;
import com.tencent.tcaplus.client.Response;
import com.tencent.tdr.tcaplus_protocol_cs.TcaplusProtocolCsConstants;
import java.util.ArrayList;
import java.util.List;
public class Example {
public static void main(String[] arguments) {
// 1. Prepare environmental information
// 1.1. Directory service address list
List<String> dirList = new ArrayList<String>();
dirList.add("tcp://x.x.x.x:9999");
dirList.add("tcp://y.y.y.y:9999");
// 1.2. Business ID
int appId = 1;
// 1.3. Business password
String appPassword = "****************";
// 1.4. Table group ID
int tableGroupId = 1;
// 1.5. Table name
String tableName = "test";
// 2. Create client
Client client = ClientFactory.createClient(appId, tableGroupId, appPassword, dirList);
try {
// 3. Construct a request to insert data
// 3.1. Get request object . In order to improve SDK performance ,Request Objects are reusable
Request request = client.acquireRequest();
// 3.2. Set request type and target table name
request.setCmd(TcaplusProtocolCsConstants.TCAPLUS_CMD_INSERT_REQ);
request.setTableName(tableName);
// 3.3. Set the value of each data field , Pay attention here Key Fields and Value Field , Different methods are used to set field values
Record record = request.addRecord();
record.setKeyInt("gameid", 1);
record.setKeyInt("itemid", 1);
record.setKeyString("name", "test");
record.setValueByte("typeid", (byte) 1);
record.setValueByte("Data", (byte) 1);
record.setValueString("uname", "test");
// 4. Send a request , And get the results
Response response = client.poll(request);
// 5. Processing results
if (response.getResult() == 0) {
// Insert data succeeded
// TODO You can add the subsequent processing code of successful data insertion here
} else {
// Insert data failed
// TODO You can add the subsequent processing code of data insertion failure here
}
} finally {
// 6. Destroy client objects
ClientFactory.destroyClient(client);
}
}
}

TcaplusDB It's a distributed product of Tencent NoSQL database , The code for storage and scheduling is completely self-developed . With cache + Landing fusion architecture 、PB Levels of storage 、 Millisecond delay 、 Lossless horizontal expansion and complex data structure . At the same time, it has rich ecological environment 、 Easy migration 、 Extremely low operation and maintenance costs and five nine high availability features . Customer coverage game 、 Internet 、 government affairs 、 Finance 、 Manufacturing and the Internet of things .
版权声明
本文为[Database master]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221501394724.html
边栏推荐
- ArcGIS calls the worldwayback historical image and exports the animation
- E. 2-Letter Strings
- 【时序】DeepGLO:可以学习全局依赖和局部信息的多时间序列预测模型
- 「译文」使用 Prometheus 和 Grafana 实现 SLO
- 【深入理解TcaplusDB技术】插入数据示例代码——[Generic表]
- 小心间谍出没!维护国家安全,你我共同守护
- [deeply understand tcallusdb technology] insert data into the specified location of the list interface description - [list table]
- Pat class a 1012: the best rank (25)
- 跨域处理的几种方案
- Installation and use of distributed task scheduling platform xxl-job
猜你喜欢

2022年化工自动化控制仪表考试题库及在线模拟考试

【模型】状态空间平均法建模-降压

Development trend of C in 2022
![【深入理解TcaplusDB技术】批量删除列表指定位置数据接口说明——[List表]](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
【深入理解TcaplusDB技术】批量删除列表指定位置数据接口说明——[List表]

Tcallusdb Jun · industry news collection (4)

Android UI - zoomcontrols zoom in and out pictures, Android interview resume template

人脸识别 (5) 基于MCTNN人脸检测(Pytorch)

WxWidgets learning notes (I): Interpretation of code:: blocks template project source code

wxWidgets学习笔记(一):解读Code::Blocks模板工程源代码
![【深入理解TcaplusDB技术】读取列表所有数据示例代码——[List表]](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
【深入理解TcaplusDB技术】读取列表所有数据示例代码——[List表]
随机推荐
How to measure small current with oscilloscope and current probe
Android的UI---ZoomControls放大缩小图片,android面试简历模板
【深入理解TcaplusDB技术】插入数据示例代码——[Generic表]
Introduction to development using Hal library, stm32cubemx and keil 5 (I): turn on an LED light (nucleo-f411re)
【深入理解TcaplusDB技术】删除数据示例代码——[Generic表]
The GNU build system体验教程:Hello world example with Autoconf and Automake
[in depth understanding of tcallusdb technology] data interface description for reading the specified location in the list - [list table]
WxWidgets learning notes (I): Interpretation of code:: blocks template project source code
TcaplusDB君 · 行业新闻汇编(四)
How to select current clamp or current probe
[in depth understanding of tcallusdb technology] description of data interface of designated location in replacement list - [list table]
Redis的线程模型
【写作】论文写作技巧
[in depth understanding of tcallusdb technology] example code - data batch return
Tencent cloud im integration (so easy)
When there is only input and output in flinksql, it will be merged into a subtask. In this case, the amount of input and output data cannot be displayed?
[C language] learn file operation in 10 minutes
2022 tea artist (intermediate) examination questions and answers
WireGuard 系列文章(五):Netmaker 简介-创建和管理 WireGuard 网络的平台
redis 获取 list 中的所有元素