Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring错误:无法获取JDBC连接_Java_Mysql_Spring_Spring Jdbc - Fatal编程技术网

Java Spring错误:无法获取JDBC连接

Java Spring错误:无法获取JDBC连接,java,mysql,spring,spring-jdbc,Java,Mysql,Spring,Spring Jdbc,我正在使用Spring框架和JDBC进行一个小练习,我得到了以下错误: Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql:3306//loca

我正在使用Spring框架和JDBC进行一个小练习,我得到了以下错误:

    Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql:3306//localhost/springcore
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:876)
    at springcore.springcore.EmployeeJDBCTemplate.create(EmployeeJDBCTemplate.java:23)
    at springcore.springcore.EmployeeApp.main(EmployeeApp.java:23)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql:3306//localhost/springcore
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
My pom.xml:

<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>springcore</groupId>
  <artifactId>springcore</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>springcore</name>
  <url>http://maven.apache.org</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>

      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.1.0.RELEASE</version>
        </dependency>
        <!-- MySQL database driver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.9</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.0.RELEASE</version>
        </dependency>
      </dependencies>
    </project>

4.0.0
春芯
春芯
0.0.1-快照
罐子
春芯
http://maven.apache.org
UTF-8
朱尼特
朱尼特
3.8.1
测试
org.springframework
spring上下文
4.1.0.1发布
mysql
mysql连接器java
5.1.9
org.springframework
SpringJDBC
3.2.0.1发布
和Beans.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">

   <!-- Initialization for data source -->
   <bean id="dataSource" 
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
      <property name="url" value="jdbc:mysql:3306//localhost/springcore"/>
      <property name="username" value="root"/>
      <property name="password" value=""/>
   </bean>
<!-- Definition for employeeJDBCTemplate bean -->
   <bean id="employeeJDBCTemplate" 
      class="springcore.springcore.EmployeeJDBCTemplate">
      <property name="dataSource"  ref="dataSource" />    
   </bean>
</beans>

数据库:MySQL,我使用Xampp和phpmyadmin来管理数据库! IDE:esclipse,Maven项目

我是不是错过了图书馆什么的

请告诉我哪里出错了!:D
提前谢谢

您确定连接字符串正确吗

默认url

jdbc:mysql://localhost:3306/dbname

您确定连接字符串正确吗

默认url

jdbc:mysql://localhost:3306/dbname

清理并构建您的项目

Tomcat服务器终端并重新启动

正确使用你的网址

JDBC_DRIVER=“com.mysql.JDBC.DRIVER”;
DB_URL=“jdbc:mysql://localhost/EMP";

conn=DriverManager.getConnection(DB_URL,USER,PASS)清理并构建项目

Tomcat服务器终端并重新启动

正确使用你的网址

JDBC_DRIVER=“com.mysql.JDBC.DRIVER”;
DB_URL=“jdbc:mysql://localhost/EMP";

conn=DriverManager.getConnection(DB_URL,USER,PASS)似乎是一个驱动程序问题。请确保您的连接url正确,并且您的驱动程序已安装在本地m2存储库中。stacktrace显示驱动程序问题非常明显。请确保您的连接url正确,并且您的驱动程序已安装在本地m2存储库中