> [i want to add all combobox items in MSAccess database]
我想这样做 我想将一个组合框的每个项目添加到MSAccess数据库中,例如我想要 要做到这一点我的组合有4个字段一,二,三,四和数据库有四个字段route1,route2,route3,route4 ...我想设置为route1 = one,route2 = two ....等。
if(e.getSource()==btn_save)
{
try{
Connection con;
DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:dsnproj","","");
Statement s1 = con.createStatement();
String q1="insert dest,route1,route2,route3,route4 into trans_dest values(
'"+cmb_dest.getSelectedItem()+"',
'"+cmb_route.getItem(1)+"',
'"+cmb_route.getItem(2)+"',
'"+cmb_route.getItem(3)+"',
'"+cmb_route.getItem(4)+"')";
s1.execute(q1);
}
catch(Exception ae)
{
System.out.println(ae);
}
}
}
[我收到错误] java.lang.ArrayIndexOutOfBoundsException:4> = 4