Cannot create JDBC driver of class 'com.mysql.jdbc

来源:互联网 发布:淘宝直邮美国 编辑:程序博客网 时间:2024/06/05 15:31

严重: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL '
jdbc:mysql://localhost:3306/example?useUnicode=true&characterEncoding=utf-8

ApplicationContext.xml

<bean id="myDataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName">
            <value>com.mysql.jdbc.Driver</value>
        </property>
        <property name="url">
            <value>

                    jdbc:mysql://localhost:3306/example?useUnicode=true&amp;characterEncoding=utf-8

            </value>
        </property>
        <property name="username">
            <value>root</value>
        </property>
        <property name="password">
            <value>1</value>
        </property>
    </bean>

解决方法:

将<value>

                    jdbc:mysql://localhost:3306/example?useUnicode=true&amp;characterEncoding=utf-8

            </value>

改成:

<value>jdbc:mysql://localhost:3306/example?useUnicode=true&amp;characterEncoding=utf-8</value>

中间不能留有空格!