首先关闭id,注意当有一行信息时有效,但当出于某种原因有很多时不起作用......这就是我的问题所在......由于代码是体面长,我将它张贴在片:使用JList通过JDBC将表数据保存到数据库通过JDBC
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.
唐诺什么德问题是在这里
为更好地帮助更快张贴[SSCCE](http://sscce.org/ ) – mKorbel 2012-07-10 14:28:22