个位大侠来看看这段代码错误在哪?如何改正?
这是程序代码:package test;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.
import org.springframework.
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowCountCallbackHandler;
public class Test {
public static void main(String[] args){
Resource resource = new ClassPathResource("myspring.xml"); //这里好像有错 按照提示
BeanFactory factory = new XmlBeanFactory(resource);
JdbcTemplate jt = (JdbcTemplate) factory.getBean("dbtest");
jt.execute(SqlStatement.createSql);
jt.execute(SqlStatement.insertData1);
jt.execute(SqlStatement.insertData2);
jt.execute(SqlStatement.insertData3);
RowCountCallbackHandler rcch = new RowCountCallbackHandler();
jt.query(SqlStatement.selectSql,rcch);
System.out.println("结果集中的列数量:" + rcch.getColumnCount());
System.out.println("结果集中的行数量:" + rcch.getRowCount());
System.out.println("结果集中的结果: ");
String[] str = rcch.getColumnNames();
for (int i = 0;i<str.length;i++){
System.out.print(str[i] + " ");
}
final ArrayList list = new ArrayList();
jt.query(SqlStatement.selectSql,new RowCallbackHandler(){
public void processRow(ResultSet rs) throws SQLException {
SpringtoResultSetInfo sri = new SpringtoResultSetInfo();
sri.setId(rs.getInt(1));
sri.setTemplatename(rs.getString(2));
list.add(sri);
}
}
);
for(int i=0;i <list.size();i++) {
SpringtoResultSetInfo sri = (SpringtoResultSetInfo)list.get(i);
System.out.println("\n" + " " + sri.getId());
System.out.print( " " + sri.getTemplatename());
}
System.out.println( "\n完成 ");
}
}
提示信息:
2008-4-2 20:49:58 org.springframework.core.CollectionFactory <clinit>
信息: JDK 1.4+ collections available
2008-4-2 20:49:58 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [myspring.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Line 14 in XML document from class path resource [myspring.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Attribute "destory-method" must be declared for element type "bean".
org.xml.sax.SAXParseException: Attribute "destory-method" must be declared for element type "bean".
at com.(ErrorHandlerWrapper.java:236)
at com.(ErrorHandlerWrapper.java:172)
at com.(XMLErrorReporter.java:382)
at com.(XMLErrorReporter.java:316)
at com.(XMLDTDValidator.java:1306)
at com.(XMLDTDValidator.java:1971)
at com.(XMLDTDValidator.java:795)
at com.(XMLDocumentFragmentScannerImpl.java:878)
at com.(XMLDocumentFragmentScannerImpl.java:1693)
at com.(XMLDocumentFragmentScannerImpl.java:368)
at com.(XML11Configuration.java:834)
at com.(XML11Configuration.java:764)
at com.(XMLParser.java:148)
at com.(DOMParser.java:250)
at com.(DocumentBuilderImpl.java:292)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:222)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:173)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at test.Test.main(Test.java:17)