How to add a JDBC driver in the pom file

Source: Internet
Author: User

Cannot load driver class:com.mysql.jdbc.Driver
How to add a JDBC driver in the pom file

To-start with, the jar that I need to connect to MySQL 5.5 should have been Mysql-connector-java-5.1.15-bin.jar but Sql-connector-java-5.1.15.jar. Secondly, this jar isn't available in Maven repository so I needed to manually add it to M Y local maven repository and then added it as a dependency to my pom.xml.

Adding Mysql-connector-java-5.1.15.jar to the local maven repository by MVN install:install-file-dfile=c:\libraries\ Mysql-connector-java-5.1.15-bin\mysql-connector-java-5.1.15-bin.jar-dgroupid=mysql-dartifactid= Mysql-connector-java-dversion=5.1.15-bin-dpackaging=jar and then adding the following dependency to Pom.xml of the Proje Ct.

    <!--MYSQL 5.5 Connector-->   
    <dependency>
        <groupId>mysql</groupId>
        < Artifactid>mysql-connector-java</artifactid>
        <version>5.1.15-bin</version>
    

This is not done yet and you need to add <scope> tags before you can use

        <!--MYSQL 5.5 Connector-->
        <dependency>
            <groupId>mysql</groupId>
            < artifactid>mysql-connector-java</artifactid>
            <version>5.1.15-bin</version>
            < Scope>runtime</scope>
        </dependency>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.