这是我用来将数据保存到DB中的代码:
print(format(a + b, nsmall = 1), quote = FALSE)
# [1] 8.0
## using digits
print(format(a1 + a2, nsmall = 1, digits = 1), quote = FALSE)
# [1] 4.2
print(format(1001.12321, nsmall = 1, digits = 1), quote = FALSE)
# [1] 1001.1
## using round
print(format(round(1001.12321, 1), nsmall = 1), quote = FALSE)
# [1] 1001.1
print(format(round(a1 + a2, 1), nsmall = 1), quote = FALSE)
# [1] 4.2
callSubSetJson.get(i)类似于:[{number:015100,name:something,id:2909,date:14366039104 ...等等〜长度~45
我不知道我在这里失踪了什么;如果我public class MyClass extends JFrame implements ActionListener{
private JButton button = new JButton("Button");
private JPanel panel = new JPanel();
public static void main(String args[]) {
new MyClass();
}
public MyClass() {
setSize(300, 300);
button.addActionListener(this);
panel.add(button);
add(panel);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
this.dispose();
}
}
工作正常。
当我尝试将对象保存到DB时,我收到此错误:
for (int i = 0; i < callSubSetJson.size(); i++) {
CallDto c = new CallDto();
c.setCallsJ(callSubSetJson.get(i).replace("\"", ""));
_callRepository.save(c);
}
对于映射我使用这个类:
setCallsJ("test")
答案 0 :(得分:1)
基于错误&#34;字符串数据,右截断&#34; 我想你要插入的字符串的长度超过DB中的长度限制。 检查模式的定义,您在此列上定义了多长的长度?你要插入的长度是多少?
答案 1 :(得分:1)
我认为,您没有为列添加长度,并且长度设置为默认值,恰好比您要插入的字符串短。尝试类似......
@Column(length = <insert appropriate length here>, name = "callsJ")
private String callsJ;