java课程设计----图书馆管理系统
}
}
}
lineForTable[i]=lineForDB[i];
else if(dataType[i]==ng.Integer.class){ }
lineForTable[i]=null;
lineForTable[i]=lineForDB[i];
if(((Integer)lineForDB[i]).doubleValue()==Integer.MIN_VALUE) else
return lineForTable;
//清空表格中所有的数据
public static void clearAllRowsInTable(CustomTableModel model){ }
//从数据库读取数据到表格, dataType指明表格中每一列的数据类型 //当前只考虑了String, Double ,Integer,Boolean ,Timestamp类型. public static void readDBToTable(Connection con,String readSql,
CustomTableModel model, Class []dataType){
clearAllRowsInTable(model); PreparedStatement query=null; try{
query= con.prepareStatement(readSql); query.clearParameters();
ResultSet rs=query.executeQuery(); while(rs.next()){
int column=model.getColumnCount(); Object []line=new Object[column]; for(int i=0;i<column;i++){
}
else if(dataType[i]==ng.Integer.class){
if(rs.getInt(i+1)==Integer.MIN_VALUE) line[i]=null; else
line[i]=new Integer(rs.getInt(i+1));
if(dataType[i]==ng.String.class)
line[i]=rs.getString(i+1).trim();
if(rs.getDouble(i+1)==Double.NEGATIVE_INFINITY) line[i]=null; else
line[i]=new Double(rs.getDouble(i+1)); else if(dataType[i]==ng.Double.class){
while(model.getRowCount()>0)
model.removeRow(0);