首先,我技术不是很好,一直在研究Liferay,突然间搭建SSH2遇见问题,发现自己无法下手,找不到解决方法,特来求助!勿怪!
按照这个地址给的方案,搭建的环境:http://wenku.baidu.com/link?url=ScCzMjkXEna8Wv0ZfX4EjrBBvU2T81wvKXqnz101eUcWmleFbAKUOL12yd95tM1ws-gd1kbV2cFDkrzIM-bcbgYHvPNFvSayUiXLc1TOhui
在进行action调用applicationContext.xml时,出现错误,但是在main中测试的时候正常:
Cannot create JDBC driver of class '' for connect URL 'jdbc:mysql://127.0.0.1:3306/sinosso'
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:278)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782)
...
我的代码是:
public String execute() {
getData();
if (UserName.equals("TF") && PassWord.equals("123")){
System.out.println("成功");
return "SUCCESS";
}else{
return "INPUT";
}
}
private void getData() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
UserDAO dao = (UserDAO) context.getBean("UserDAO");
List<User> list = dao.findAll();
int n = list.size();
for (int i = 0; i < n; i++) {
User c = list.get(i);
String name = c.getUserName();
System.out.println(name);
}
}
恳求帮助!
------解决思路----------------------
估计 你的jdbc驱动类有问题