org.springframework.jdbc.CannotGetJdbcConnectionException: java.sql.SQLException: No suitable driver found for jdbc:mysql -
i'm creating maven spring mysql application , i'm facing issue below
org.springframework.jdbc.cannotgetjdbcconnectionexception: not jdbc connection; nested exception java.sql.sqlexception: no suitable driver found jdbc:mysql
below pom-file
<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.ec</groupid> <artifactid>ecws</artifactid> <version>0.0.1-snapshot</version> <packaging>war</packaging> <properties> <jersey.version>2.2</jersey.version> <javax.servlet.version>2.3</javax.servlet.version> <spring.batch.version>2.2.0.release</spring.batch.version> <spring.version>3.1.1.release</spring.version> <slf4j.version>1.7.7</slf4j.version> <project.build.sourceencoding>utf-8</project.build.sourceencoding> </properties> <dependencies> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context-support</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-web</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>${slf4j.version}</version> </dependency> <dependency> <groupid>org.glassfish.jersey.core</groupid> <artifactid>jersey-server</artifactid> <version>${jersey.version}</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>${slf4j.version}</version> </dependency> <dependency> <groupid>commons-logging</groupid> <artifactid>commons-logging</artifactid> <version>1.1.1</version> </dependency> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <version>5.1.6</version> </dependency> <dependency> <groupid>com.jcraft</groupid> <artifactid>jsch</artifactid> <version>0.1.51</version> </dependency> <dependency> <groupid>javax.ws.rs</groupid> <artifactid>javax.ws.rs-api</artifactid> <version>2.0</version> </dependency> <dependency> <groupid>com.googlecode.json-simple</groupid> <artifactid>json-simple</artifactid> <version>1.1</version> </dependency> <dependency> <groupid>commons-lang</groupid> <artifactid>commons-lang</artifactid> <version>2.3</version> </dependency> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.8.1</version> <scope>test</scope> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>servlet-api</artifactid> <version>${javax.servlet.version}</version> <scope>provided</scope> </dependency> <dependency> <groupid>org.glassfish.jersey.containers</groupid> <artifactid>jersey-container-servlet</artifactid> <version>${jersey.version}</version> </dependency> <dependency> <groupid>org.glassfish.jersey.media</groupid> <artifactid>jersey-media-moxy</artifactid> <version>${jersey.version}</version> </dependency> <dependency> <groupid>org.glassfish.jersey.test-framework.providers</groupid> <artifactid>jersey-test-framework-provider-simple</artifactid> <version>${jersey.version}</version> <scope>test</scope> </dependency> <dependency> <groupid>org.glassfish.jersey.ext</groupid> <artifactid>jersey-spring3</artifactid> <version>${jersey.version}</version> </dependency> <dependency> <groupid>org.glassfish.jersey.ext</groupid> <artifactid>jersey-declarative-linking</artifactid> <version>2.19</version> </dependency> <dependency> <groupid>org.glassfish.jersey.ext</groupid> <artifactid>jersey-bean-validation</artifactid> <version>${jersey.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-jdbc</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-beans</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-aop</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-context</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-core</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-expression</artifactid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.apache.poi</groupid> <artifactid>poi</artifactid> <version>3.8</version> </dependency> <dependency> <groupid>org.apache.commons</groupid> <artifactid>commons-io</artifactid> <version>1.3.2</version> </dependency> <dependency> <groupid>org.springframework.batch</groupid> <artifactid>spring-batch-core</artifactid> <version>${spring.batch.version}</version> </dependency> <dependency> <groupid>org.springframework.batch</groupid> <artifactid>spring-batch-infrastructure</artifactid> <version>${spring.batch.version}</version> </dependency> <dependency> <groupid>net.sourceforge.jexcelapi</groupid> <artifactid>jxl</artifactid> <version>2.6.3</version> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-test</artifactid> <version>${spring.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.5.1</version> <inherited>true</inherited> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <artifactid>maven-war-plugin</artifactid> <version>2.4</version> <configuration> <warsourcedirectory>webcontent</warsourcedirectory> <failonmissingwebxml>false</failonmissingwebxml> </configuration> </plugin> </plugins> </build> </project>
and bean.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"> <context:component-scan base-package="com.ecable" /> <context:annotation-config /> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url" value="jdbc:mysql//localhost:3306/test" /> <property name="username" value="root" /> <property name="password" value="root" /> </bean> <bean id="loginjdbctemplate" class="com.ecb.dbtemplates.validate"> <property name="datasource" ref ="datasource"></property> </bean> </beans>
i using default schema test
created during mysqlserver creation. appreciated.
you have small typo in bean.xml file.
change value="jdbc:mysql//localhost:3306/test"
value="jdbc:mysql://localhost:3306/test"
Comments
Post a Comment