首先,我想指出,当有 1 行信息时这有效,但由于某种原因有很多信息时无效...这就是我的问题...由于代码相当长,我将其分段发布:
int count = jTable1.getRowCount();
for(int i=0;i<count;i++){
//uusi muodostus//
SET0listm.add(i, txtTestiNIMI1.getText());
System.out.println("SET0"+SET0listm);
...
SAVED8listm.addElement(jTable1.getModel().getValueAt(i,7));
System.out.println("SAVED8"+SAVED8listm);
}
像这样移动到字符串并删除所有额外的部分:
String SET0listmtostring = SET0listm.toString();
SET0listmtostring = removeChar(SET0listmtostring, ']');
SET0listmtostring = removeChar(SET0listmtostring, '[');
String sqla1 = "INSERT INTO MIT(MTY_KOD,MTY_TYY,MTY_ALU,MTY_PAR1,MTY_PAR2,MTY_TOL,MTY_KAN,MTY_DATE) "+"VALUES (?,?,?,?,?,?,?,?)";
try{
pst = conn.prepareStatement(sqla1);
pst.setString(1, SET0listmtostring);
pst.setString(2, SET2listmtostring);
pst.setString(3, SET1listmtostring);
pst.setString(4, SAVEDlistmtostring);
pst.setString(5, SAVED3listmmtostring);
pst.setString(6, SAVED5listmmtostring);
pst.setString(7, SET3listmtostring);
pst.setString(8, SET2listmtostring);
pst.executeUpdate();}
catch (Exception e) {
System.out.println("MITCLAUSE "+e);
}
最后一部分抓住了
MITCLAUSE com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
Donno 这里有什么问题