简体   繁体   English

Hibernate、JDBC:调用 Driver#connect 时出错

[英]Hibernate, JDBC: Error calling Driver#connect

I try to use Hibernate to connect to my database.我尝试使用 Hibernate 连接到我的数据库。 But when I build my SessionFactory, it always throws a JDBCCOnnectionException: Error calling Driver#connect但是当我构建我的 SessionFactory 时,它总是抛出一个 JDBCCONnectionException: Error calling Driver#connect

Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:118)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:140)
at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:58)
at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75)
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at HibernateTest.main(HibernateTest.java:19)

Code:代码:

Configuration cfg = new Configuration().configure("hibernate.cfg.xml");         
    StandardServiceRegistryBuilder sb = new StandardServiceRegistryBuilder();
    sb.applySettings(cfg.getProperties());
    StandardServiceRegistry standardServiceRegistry = sb.build();                   
    SessionFactory sessionFactory = cfg.buildSessionFactory(standardServiceRegistry); //<-- Exception here
    System.err.println("configuration done");

The hibernate.cfg.xml file was loaded complete and successful. hibernate.cfg.xml 文件加载完成并成功。 I also added, the mysql-connector-java-5.1.29.bin.jar to my buildpath.我还将 mysql-connector-java-5.1.29.bin.jar 添加到我的构建路径中。

This is the problem of your configuration file.这是你的配置文件的问题。

Check you Sid in检查你 Sid in

 hibernate.cfg.xml file

For Oracle Express Edition:对于 Oracle 快捷版:

<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>

For Oracle Enterprise Edition:对于 Oracle 企业版:

<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Hibernate 调用 Driver#connect 时出错 - “Error calling Driver#connect” using Hibernate org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 - org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect failed.org.hibernate.exception.JDBCConnectionException:使用PostGres Hibernate调用Driver#connect时出错 - failed.org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect with PostGres Hibernate 无法创建sessionFactory object.org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 - Failed to create sessionFactory object.org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect 引起原因:org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 - Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect 调用Driver#connect时出错,并且无法创建与数据库服务器的连接 - Error calling Driver#connect and Could not create connection to database server amazon aws ubuntu java mysql webservice“错误调用Driver#connect” - amazon aws ubuntu java mysql webservice “Error calling Driver#connect” JDBC 驱动程序错误,无法连接到 mysql 服务器 - JDBC driver error and cannot connect to mysql server Spring + Hibernate + Maven:j无法为连接URL“ jdbc:mysql // localhost:3306 / test”创建类“ com.mysql.jdbc.Driver”的JDBC驱动程序 - Spring + Hibernate + Maven: jCannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql//localhost:3306/test' Jboss Hibernate Tools:读取错误模式 - 可能是 JDBC 驱动程序问题 - Jboss Hibernate Tools: Reading error schema - Probably a JDBC driver Issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM