publicstaticArrayListgetAccessConnection()throwsException{connAccess.conn1();con=connAccess.con;PreparedStatementps5;customercu1=newcustomer();Stringsql="select*fromcusto...
public static ArrayList getAccessConnection() throws Exception
{
connAccess.conn1();
con=connAccess.con;
PreparedStatement ps5;
customer cu1=new customer();
String sql="select * from customer where cuName=?";
String cuName="cuName";
/*String ur1="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Users/Administrator/workspace/prj/database/customer.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(ur1);*/
ps5=con.prepareStatement(sql);
ps5.setObject(1,cu1.getcu);
rs=ps5.executeQuery();
ArrayList al2=new ArrayList();
while(rs.next())
{
cu1.setCuId(rs.getInt("cuId"));
cu1.setCuName(rs.getString("cuName"));
cu1.setCuAddress(rs.getString("cuAddress"));
cu1.setCuContact(rs.getString("cuContact"));
cu1.setCuMobile(rs.getString("cuMobile"));
cu1.setCuTel(rs.getString("cuTel"));
al2.add(cu1);
//System.out.println(al2);
}
return al2;
}
ps5.setObject(index,value)是重点,关键是不知道VALUE写什么
编辑:我说的是具体的VALUE应该写什么,代码贴上来,不要说大概
展开