日期:2014-05-20 浏览次数:20812 次
private static DatabaseManager dbm = new DatabaseManager("codetable", 1000, "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/codetable", "root", "root"); public static void method2() { try { List<CustTable> list = new ArrayList<CustTable>(); List<CustTable> cutList = (List<CustTable>) dbm.executeQuery(list, "select * from custtable"); for (int i = 0; i < cutList.size(); i++) { System.out.println(cutList.get(i).getCustId());//异常产生地方 // System.out.println(cutList.get(i).getClass()); } dbm.close(); } catch (DatabaseException e) { e.printStackTrace(); } } package com.mainClass; public class CustTable { private String custId; private String value; private String codeNum; private String valueId; public CustTable() { } public CustTable(String custId) { this.custId = custId; } public CustTable(String custId, String value, String codeNum, String valueId) { this.custId = custId; this.value = value; this.codeNum = codeNum; this.valueId = valueId; } public String getCustId() { return custId; } public void setCustId(String custId) { this.custId = custId; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String getCodeNum() { return codeNum; } public void setCodeNum(String codeNum) { this.codeNum = codeNum; } public String getValueId() { return valueId; } public void setValueId(String valueId) { this.valueId = valueId; } public String toString() { return custId + ", " + value + ", " + codeNum + ", " + valueId; } }