> [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