没有遇到任何合适的连接提供程序:JPA Hibernate

时间:2014-07-03 21:26:22

标签: java hibernate java-ee jpa

我尝试使用root用户密码和密码连接到我的本地数据库:password。我只是想学习这些东西而且很难开始。我知道需要为实体管理器和事务系统提供连接,但我认为我已经在我的持久性文件中指定了它。最后我运行独立的jboss所以也许我需要配置服务器端,但我觉得应该在我的容器中配置所有内容。最后,我没有hibernate.cfg.xml文件,因为我的实体都注释了所有内容。

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="persistenceUnit"
        transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hello" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="password" />
            <property name="hbm2ddl.auto" value="create" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        </properties>
    </persistence-unit>
</persistence>

修改

13:54:17,474 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-16) JBAS015876: Starting deployment of "hello.war" (runtime-name: "hello.war")
13:54:17,474 INFO  [org.jboss.web] (ServerService Thread Pool -- 529) JBAS018224: Unregister web context: /taylor
13:54:17,508 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment taylor.war (runtime-name: taylor.war) in 34ms
13:54:17,578 INFO  [org.jboss.as.jpa] (MSC service thread 1-10) JBAS011401: Read persistence.xml for persistenceUnit
13:54:17,604 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
13:54:17,604 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
13:54:17,606 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 533) JBAS011402: Starting Persistence Unit Service 'hello.war#persistenceUnit'
13:54:17,607 INFO  [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 533) HHH000204: Processing PersistenceUnitInfo [
    name: persistenceUnit
    ...]
13:54:17,616 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (ServerService Thread Pool -- 533) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
13:54:17,617 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 533) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
13:54:17,617 INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (ServerService Thread Pool -- 533) HHH000422: Disabling contextual LOB creation as connection was null
13:54:17,621 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (ServerService Thread Pool -- 533) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
13:54:17,621 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 533) HHH000397: Using ASTQueryTranslatorFactory
13:54:17,630 WARN  [org.hibernate.internal.SessionFactoryImpl] (ServerService Thread Pool -- 533) HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
13:54:17,632 INFO  [org.jboss.web] (ServerService Thread Pool -- 536) JBAS018210: Register web context: /helloMan
13:54:17,639 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "taylor.war" (runtime-name: "taylor.war")
13:54:17,639 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "hello.war" (runtime-name : "hello.war")

1 个答案:

答案 0 :(得分:1)

根据我的经验,我可以说几件事:

  1. 我还没有使用<provider>代码或hibernate.dialect属性 永远,这可能是一个问题。
  2. 我从未使用过其他属性     比hibernate.something.something或特定于应用服务器的标记,例如jboss.something.something中的persistence.xml。你使用的是不同的     &#34;家庭&#34;属性,这可能是一个问题。
  3. 更多基本提示 - 了解您的环境会有所帮助。应用程序服务器(Tomcat,JBoss等),Java版本等等。