首先關閉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