Java “指定的JDBC驱动程序”;com.microsoft.sqlserver.jdbc.SQLServerDriver“;找不到类

Java “指定的JDBC驱动程序”;com.microsoft.sqlserver.jdbc.SQLServerDriver“;找不到类,java,hibernate,maven,Java,Hibernate,Maven,我尝试创建简单的应用程序来测试hibernate。我使用ms sql server作为数据库 我从microsoft官方网站下载sqljdbc4,并添加到我的sts(eclipse)的构建路径中: 它位于maven依赖项上 当我调用我的应用程序时,我看到: SessionFactory creation failed.org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "com.

我尝试创建简单的应用程序来测试hibernate。我使用ms sql server作为数据库

我从microsoft官方网站下载sqljdbc4,并添加到我的sts(eclipse)的构建路径中:

它位于maven依赖项上

当我调用我的应用程序时,我看到:

SessionFactory creation failed.org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "com.microsoft.sqlserver.jdbc.SQLServerDriver" class not found
Exception in thread "main" java.lang.ExceptionInInitializerError
    at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:22)
    at logic.HibernateUtil.<clinit>(HibernateUtil.java:8)
    at logic.Main.main(Main.java:12)
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "com.microsoft.sqlserver.jdbc.SQLServerDriver" class not found
    at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:107)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782)
    at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:17)
    ... 2 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class ["com.microsoft.sqlserver.jdbc.SQLServerDriver"]
    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
    at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:104)
    ... 16 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
    ... 17 more
然后键入ctrl+鼠标左键单击我看到了![在此处输入图像描述][2]

因此我可以输出这个类存在,但hibernate看不到它的存在

你能帮我吗

更新

C:\Users\Nikolay_Tkachev\mavenHibernateTest>
C:\Users\Nikolay_Tkachev\mavenHibernateTest>mvn exec:java -Dexec.mainClass="logic.Main"
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for hiberTest:hiberTest:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.hibernate:hibernate-core:jar ->
 version 4.0.1.Final vs 4.1.4.Final @ line 45, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myTest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ hiberTest >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ hiberTest <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ hiberTest ---
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Initial SessionFactory creation failed.org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "
com.microsoft.sqlserver.jdbc.SQLServerDriver" class not found
[WARNING]
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ExceptionInInitializerError
        at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
        at logic.HibernateUtil.<clinit>(HibernateUtil.java:8)
        at logic.Main.main(Main.java:12)
        ... 6 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "com.microsoft.sqlserver.jdbc
.SQLServerDriver" class not found
        at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnec
tionProviderImpl.java:107)
        at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159
)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
        at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159
)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782)
        at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
        ... 8 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class ["com.microsoft.sqlserver.jdbc
.SQLServerDriver"]
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
        at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnec
tionProviderImpl.java:104)
        ... 22 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : "com.microsoft.sqlserver.jdbc.SQLServerDriver"

        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
        ... 23 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.403s
[INFO] Finished at: Wed Sep 11 17:14:07 MSK 2013
[INFO] Final Memory: 6M/115M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project hiberTest: An excepti
on occured while executing the Java class. null: InvocationTargetException: ExceptionInInitializerError: Specified JDBC Driv
er "com.microsoft.sqlserver.jdbc.SQLServerDriver" class not found: Unable to load class ["com.microsoft.sqlserver.jdbc.SQLSe
rverDriver"]: Could not load requested class : "com.microsoft.sqlserver.jdbc.SQLServerDriver" -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
C:\Users\Nikolay_Tkachev\mavenHibernateTe

如何调用应用程序

我有一节课:

import org.hibernate.Session;

public class Main {
    public static void main(String[] args){
        Prepod prepod = new Prepod();
        Student student = new Student();
        prepod.getStudents().add(student);
        student.getPrepods().add(prepod);

        Session session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();
        session.update(student);
        session.getTransaction().commit();
    }
}
因此:

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            // Configuration configuration = new Configuration().configure(
            // "C:\\Users\\Nikolay_Tkachev\\workspace\\hiberTest\\src\\logic\\hibernate.cfg.xml");
            // return configuration.buildSessionFactory();
            SessionFactory sessionFactory = new Configuration()
                    .configure("/resources/hibernate.cfg.xml").buildSessionFactory();
            return sessionFactory;
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    public static void shutdown() {
        // Close caches and connection pools
        getSessionFactory().close();
    }

}
右键单击Main.java->运行方式->java应用程序

更新2

项目结构:

!![在此处输入图像描述][3]

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>hiberTest</groupId>
    <artifactId>hiberTest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>myTest</name>
    <description>description</description>
    <properties>
        <hibernate.version>4.2.1.Final</hibernate.version>
        <hibernate-validator.version>4.3.1.Final</hibernate-validator.version>
    </properties>
    <dependencies>

        <!-- <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> 
            <version>${mysql.version}</version> </dependency> -->
        <!-- HIBERNATE -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>4.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-multipart</artifactId>
            <version>1.8</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.4.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.5.6-Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.3.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>4.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-envers</artifactId>
            <version>4.1.4.Final</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>3.0</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
hiberTest
hiberTest
0.0.1-快照
我的测试
描述
4.2.1.最终版本
4.3.1.最终版本
org.hibernate
冬眠核心
4.0.1.最终版本
mysql
mysql连接器java
5.1.6
org.hibernate
hibernate-c3p0
4.0.1.最终版本
泽西岛
泽西服务器
1.8
com.sun.jersey.contribs
泽西多部分
1.8
org.slf4j
slf4j-log4j12
1.6.1
org.hibernate
冬眠核心
4.1.4.最终版本
org.hibernate
休眠注释
3.5.6-最终版本
org.hibernate
休眠验证器
4.3.0.1最终版本
org.hibernate.common
hibernate commons注释
4.0.1.最终版本
org.hibernate
冬眠使者
4.1.4.最终版本
com.microsoft.sqlserver
sqljdbc4
3
src
maven编译器插件
3
1.6
1.6
Vinay的更新

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

...
C:\Users\Nikolay_Tkachev\.m2> mvn install:install-file -Dfile=sqljdbc4-3.0.jar -DgroupId=com.microsoft.sqlserver -DartifactI
d=sqljdbc4 -Dversion=3.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing C:\Users\Nikolay_Tkachev\.m2\sqljdbc4-3.0.jar to C:\Users\Nikolay_Tkachev\.m2\repository\com\microsoft\sql
server\sqljdbc4\3.0\sqljdbc4-3.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.686s
[INFO] Finished at: Wed Sep 11 17:05:35 MSK 2013
[INFO] Final Memory: 3M/90M
[INFO] ------------------------------------------------------------------------
C:\Users\Nikolay_Tkachev\.m2>cd C:\Users\Nikolay_Tkachev\mavenHibernateTest

C:\Users\Nikolay_Tkachev\mavenHibernateTest>mvn eclipse:eclipse
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for hiberTest:hiberTest:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.hibernate:hibernate-core:jar ->
 version 4.0.1.Final vs 4.1.4.Final @ line 45, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myTest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.9:eclipse (default-cli) @ hiberTest >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.9:eclipse (default-cli) @ hiberTest <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.9:eclipse (default-cli) @ hiberTest ---
[INFO] Using Eclipse Workspace: null
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] File C:\Users\Nikolay_Tkachev\mavenHibernateTest\.project already exists.
       Additional settings will be preserved, run mvn eclipse:clean if you want old settings to be removed.
[INFO] Wrote Eclipse project for "hiberTest" to C:\Users\Nikolay_Tkachev\mavenHibernateTest.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.061s
[INFO] Finished at: Wed Sep 11 17:07:20 MSK 2013
[INFO] Final Memory: 7M/113M
[INFO] ------------------------------------------------------------------------
C:\Users\Nikolay_Tkachev\mavenHibernateTest>
Microsoft Windows[版本6.1.7601]
版权所有(c)2009微软公司。版权所有。
...
C:\Users\Nikolay_Tkachev\.m2>mvn安装:安装文件-Dfile=sqljdbc4-3.0.jar-DgroupId=com.microsoft.sqlserver-DartifactI
d=sqljdbc4-Dversion=3.0-dpackage=jar
[信息]正在扫描项目。。。
[信息]
[信息]------------------------------------------------------------------------
[信息]建筑Maven存根项目(无POM)1
[信息]------------------------------------------------------------------------
[信息]
[信息]---maven安装插件:2.3.1:安装文件(默认cli)@standalone pom---
[信息]正在将C:\Users\Nikolay\u Tkachev\.m2\sqljdbc4-3.0.jar安装到C:\Users\Nikolay\u Tkachev\.m2\repository\com\microsoft\sql
server\sqljdbc4\3.0\sqljdbc4-3.0.jar
[信息]------------------------------------------------------------------------
[信息]建立成功
[信息]------------------------------------------------------------------------
[信息]总时间:0.686s
[信息]完成时间:2013年9月11日星期三17:05:35
[信息]最终内存:3M/90M
[信息]------------------------------------------------------------------------
C:\Users\Nikolay\u Tkachev\.m2>cd C:\Users\Nikolay\u Tkachev\mavenHibernateTest
C:\Users\Nikolay\u Tkachev\mavenHibernateTest>mvn eclipse:eclipse
[信息]正在扫描项目。。。
[警告]
[警告]为hiberTest:hiberTest:jar:0.0.1-SNAPSHOT构建有效模型时遇到一些问题
[警告]“dependencies.dependency.(groupId:artifactId:type:classifier)”必须是唯一的:org.hibernate:hibernate核心:jar->
版本4.0.1.Final vs 4.1.4.Final@第45行第15列
[警告]
[警告]强烈建议修复这些问题,因为它们会威胁到构建的稳定性。
[警告]
[警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式错误的项目。
[警告]
[信息]
[信息]------------------------------------------------------------------------
[信息]正在构建myTest 0.0.1-SNAPSHOT
[信息]------------------------------------------------------------------------
[信息]
[信息]>>>maven eclipse插件:2.9:eclipse(默认cli)@hiberTest>>>
[信息]
[信息]
版本4.0.1.Final vs 4.1.4.Final@第45行第15列
[警告]
[警告]强烈建议修复这些问题,因为它们会威胁到构建的稳定性。
[警告]
[警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式错误的项目。
[警告]
[信息]
[信息]------------------------------------------------------------------------
[信息]正在构建myTest 0.0.1-SNAPSHOT
[信息]------------------------------------------------------------------------
[信息]
[信息]>>>exec maven插件:1.2.1:java(默认cli)@hiberTest>>>
[信息]
[信息]
  • 添加sqljdbc驱动程序作为maven依赖项。请参阅
  • 调用mvn eclipse:eclipse
  • 运行应用程序
  • 我确信这会解决你的问题。

    非常简单的错误:

    解决方案

    错:

    “com.microsoft.sqlserver.jdbc.SQLServerDriver”
    
    对:

    com.microsoft.sqlserver.jdbc.SQLServerDriver
    

    非常有趣)

    下面的代码片段可以很好地连接和查询Microsoft SQL SERVER中的数据库。请注意,Microsoft不允许jar文件“sqljdbc42.jar”(即jdbc驱动程序)在任何在线repo(如MavenCentral())上可用。因此,您需要从Microsoft网站下载此jar并保存在project workspace目录中。下载'sqljdbc_4.2.6420。
    C:\Users\Nikolay_Tkachev\mavenHibernateTest>
    C:\Users\Nikolay_Tkachev\mavenHibernateTest>mvn exec:java -Dexec.mainClass="logic.Main"
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for hiberTest:hiberTest:jar:0.0.1-SNAPSHOT
    [WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.hibernate:hibernate-core:jar ->
     version 4.0.1.Final vs 4.1.4.Final @ line 45, column 15
    [WARNING]
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING]
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING]
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building myTest 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ hiberTest >>>
    [INFO]
    [INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ hiberTest <<<
    [INFO]
    [INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ hiberTest ---
    log4j:WARN No appenders could be found for logger (org.jboss.logging).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    Initial SessionFactory creation failed.org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "
    com.microsoft.sqlserver.jdbc.SQLServerDriver" class not found
    [WARNING]
    java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ExceptionInInitializerError
            at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
            at logic.HibernateUtil.<clinit>(HibernateUtil.java:8)
            at logic.Main.main(Main.java:12)
            ... 6 more
    Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver "com.microsoft.sqlserver.jdbc
    .SQLServerDriver" class not found
            at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnec
    tionProviderImpl.java:107)
            at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159
    )
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
            at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
            at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
            at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159
    )
            at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
            at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
            at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277)
            at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782)
            at logic.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
            ... 8 more
    Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class ["com.microsoft.sqlserver.jdbc
    .SQLServerDriver"]
            at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
            at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnec
    tionProviderImpl.java:104)
            ... 22 more
    Caused by: java.lang.ClassNotFoundException: Could not load requested class : "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    
            at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$1.findClass(ClassLoaderServiceImpl.java:99)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:247)
            at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
            ... 23 more
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.403s
    [INFO] Finished at: Wed Sep 11 17:14:07 MSK 2013
    [INFO] Final Memory: 6M/115M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project hiberTest: An excepti
    on occured while executing the Java class. null: InvocationTargetException: ExceptionInInitializerError: Specified JDBC Driv
    er "com.microsoft.sqlserver.jdbc.SQLServerDriver" class not found: Unable to load class ["com.microsoft.sqlserver.jdbc.SQLSe
    rverDriver"]: Could not load requested class : "com.microsoft.sqlserver.jdbc.SQLServerDriver" -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    C:\Users\Nikolay_Tkachev\mavenHibernateTe
    
    <property name="hibernate.connection.driver_class">"com.microsoft.sqlserver.jdbc.SQLServerD‌​river"</property>
    
    <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerD‌​river</property>
    
    <property name="hibernate.connection.driver_class">"com.microsoft.sqlserver.jdbc.SQLServerDriver"</property>
    
    <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
    
            repositories {
                flatDir name: 'localRepository', dirs: 'lib'
            }
            configurations {
                driver
            }
            dependencies {
                driver group: 'sql', name: 'sqljdbc42', version:''
            }
    
    
            URLClassLoader loader = GroovyObject.class.classLoader
            configurations.driver.each { File file ->
                loader.addURL(file.toURL())
            }
    
            task connectToCoreDb << {
                def props = [user: 'sa', password: 'shock', allowMultiQueries: 'true'] as Properties
                def connectionUrl = "jdbc:sqlserver://cpt-op-01-db1:1433;databaseName=buds"
                def driver = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
                def sql = Sql.newInstance(connectionUrl, props, driver)
                sql.eachRow('SELECT name, alias, expiry_date FROM [buds].[dbo].[obj_keystore] ) { row ->
                    println "$row.name $row.alias $row.expiry_date"
                }
                logger.info "Closing connection..."
                sql.close()
            }