2017-04-05 15 views
0

UserEntity:Wy私はJPAとデータベースを接続できませんか?

package model.entity; 

import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.GenerationType; 
import javax.persistence.Id; 
import javax.persistence.Table; 

@Entity 
@Table 
public class UserEntity { 

    @Id 
    @GeneratedValue(strategy = GenerationType.AUTO)  
    private int eid; 

    private String username; 
    private String password; 
    private String email; 
    private String function; 

    public UserEntity(int eid, String username, String password, String email, String function){ 
     this.eid = eid; 
     this.username = username; 
     this.password = password; 
     this.email = email; 
     this.function = function; 
    } 

    public UserEntity(){ 
     super(); 
    } 

    public String getUsername() { 
     return username; 
    } 

    public void setUsername(String username) { 
     this.username = username; 
    } 

    public String getPassword() { 
     return password; 
    } 

    public void setPassword(String password) { 
     this.password = password; 
    } 

    public String getEmail() { 
     return email; 
    } 

    public void setEmail(String email) { 
     this.email = email; 
    } 

    public String getFunction() { 
     return function; 
    } 

    public void setFunction(String function) { 
     this.function = function; 
    } 

    public int getEid() { 
     return eid; 
    } 

    public void setEid(int eid) { 
     this.eid = eid; 
    } 

} 

とのpersistence.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> 

    <persistence-unit name="FastFoodJSF" transaction-type="RESOURCE_LOCAL"> 

    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <class>model.entity.UserEntity</class> 

    <properties> 

     <property name="javax.persistance.jdbc.url" value="jdbc:mysql://localhost:3306/fastfood" /> 
     <property name="javax.persistance.jdbc.user" value="fastfoodadmin" /> 
     <property name="javax.persistance.jdbc.password" value="fastfood" /> 
     <property name="javax.persistance.jdbc.driver" value="com.mysql.jdbc.Driver" /> 

    </properties> 

    </persistence-unit> 
</persistence> 

これはエラーアン示しています

[EL Info]: 2017-04-05 12:17:38.926--ServerSession(2006034581)--EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd 
[EL Severe]: ejb: 2017-04-05 12:17:38.934--ServerSession(2006034581)--Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException 
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform 
Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException 
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform 
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:766) 
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204) 
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304) 
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336) 
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:302) 
    at model.service.FindUsers.main(FindUsers.java:13) 
Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException 
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform 
    at org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:383) 
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:91) 
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162) 
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:204) 
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:741) 
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239) 
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685) 
    ... 5 more 

それはそれが表示されていないbecouseそれがデータベースに接続傾けるように私には見えます永続性からのプロパティー? 私はこの技術の新人であり、JPAがどのように動作すべきか理解できません。

答えて

1

:) おかげで、あなたはjavax.persist nce.jdbcを交換してみてください。* javax.persist 電子 nce.jdbcで。*?

+0

HAHAHAHAH:D は、私はいくつかの時間のために昨日からこの問題を解決しようとしています:D は、1つの文字と構文の問題であるとしdidntは:D はまだmayby BYT他のいくつかのerroesを持って、私は簡単にそれらを解決するためwoule :) – lukaszP

+0

をはい、時々その種の問題が発生します:) – CoDel

関連する問題