2013年11月19日星期二

I myeclipse8.5 mysql database using spring3.0 operation , suggesting the following information , I ask : How do we solve it ? ( Enough points you can add points oh )

Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc.mysql :/ / localhost: 3306/spring'
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection (DataSourceUtils.java: 82)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java: 381)
at org.springframework.jdbc.core.JdbcTemplate.query (JdbcTemplate.java: 455)
at org.springframework.jdbc.core.JdbcTemplate.query (JdbcTemplate.java: 463)
at impl.StudentImpl.getStudent (StudentImpl.java: 39)
at operaDb.Test.main (Test.java: 22)

---------------------------------------------- ----
which StudentImpl.java the relevant code is as follows :

@ Override
public List getStudent () {
List studentList = jdbcTemplate.query ("SELECT * FROM studentinfo", new RowMapper () {
@ Override
public Student mapRow (ResultSet rs, int arg1) throws SQLException {
Student s = new Student ();
s.setsId (rs.getString ("sId"));
s.setsName (rs.getString ("sName"));
s.setsAge (rs.getInt ("sAge"));
return s;
}
});
return studentList;
}

applicationcontext.xml documents relevant code is as follows: ,




















Test.java class -related code is as follows :

public static void main (String [] args) {
ApplicationContext a = new FileSystemXmlApplicationContext ("D: \ \ myPrj \ \ myWebSpring \ \ WebRoot \ \ WEB-INF \ \ applicationContext.xml");
StudentDao s = (StudentDao) a.getBean ("zhou");
System.out.println (s.getStudent ());
}




------ Solution ------------------------------------ --------


This value was wrong now !


------ Solution ------------------------------------ --------
jdbc: mysql :/ / localhost: 3306/spring
is : No, it

没有评论:

发表评论