当前位置: 代码迷 >> J2EE >> hibernate联接sqlserver2008的
  详细解决方案

hibernate联接sqlserver2008的

热度:89   发布时间:2016-04-22 00:39:35.0
hibernate连接sqlserver2008的
异常信息如下:
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
at jyu.hibernate.model.StudentTest.main(StudentTest.java:17)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=用户管理
at java.sql.DriverManager.getConnection(DriverManager.java:604)
at java.sql.DriverManager.getConnection(DriverManager.java:190)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 5 more


hibernate的配置信息
XML code
<?xml version='1.0' encoding='utf-8'?>    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>    <session-factory>        <!-- Database connection settings -->        <!--             <property name="connection.driver_class">                com.mysql.jdbc.Driver            </property>               <property name="dialect">org.hibernate.dialect.MySQLDialect</property>         -->                 <property name="hibernate.dialect">            org.hibernate.dialect.SQLServerDialect        </property>        <property name="hibernate.connection.driver_class">            com.microsoft.sqlserver.jdbc.SQLServerDriver        </property>             <property name="connection.url">                jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=用户管理            </property>            <property name="connection.username">sa</property>            <property name="connection.password">123</property>                        <!-- JDBC connection pool (use the built-in)                <property name="connection.pool_size">1</property>            -->                          <!-- Enable Hibernate's automatic session context management                         <property name="current_session_context_class">thread</property>            -->                            <!-- Disable the second-level cache  -->            <!--            <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>            -->                        <!-- Echo all executed SQL to stdout -->             <property name="show_sql">true</property>              <!-- Drop and re-create the database schema on startup              <property name="hbm2ddl.auto">update</property>             -->                          <mapping resource="Student.hbm.xml" />    </session-factory> </hibernate-configuration>


------解决方案--------------------
Caused by: java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=用户管理
  相关解决方案