2012-03-30 2 views
1

MySQL의 응용 프로그램에서 PostgreSQL을 대체하려고합니다.JPA/Hibernate는 Postgresql과 함께 작동하지만 Mysql과 함께 작동하지 않습니다.

PostgreSQL의 :

<property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/> 
<property name="hibernate.connection.username" value=""/> 
<property name="hibernate.connection.password" value=""/> 
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/> 
<property name="hibernate.show_sql" value="true"/> 

MySQL은 : 나는이 persistence.xml 파일에 <properties>를 대체하기에 충분해야한다고 생각, 내가 점점 AMG

<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> 
<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 
<property name="hibernate.connection.username" value=""/> 
<property name="hibernate.connection.password" value=""/> 
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
<property name="hibernate.hbm2ddl.auto" value="update"/> 

그러나이 교체로

java.lang.UnsupportedOperationException: The application must supply JDBC connections 

내가 뭘 잘못하고 있는지 잘 모르겠다. 대체는 간단 할 것이다. PostgreSQL에서는 모든 것이 올바르게 작동합니다.

의 persistence.xml : https://gist.github.com/2252443

applicationContext.xml : https://gist.github.com/2252463

예외 : https://gist.github.com/2252487

감사합니다!

편집 : 주어진 코드에서 의도적으로 사용자 이름과 암호를 제거합니다.

+0

세션 팩토리에 대한 시작 메시지를 게시 할 수 있습니까? – araqnid

+0

당신은 주어진 자격 증명 정보로 mysql workbench에서 연결할 수 있습니까? –

답변

6

당신은 PostgreSQL을에 대한 구성 최대 절전 모드 사투리 누락 :

<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> 

편집 :

당신은 구성에서 미스 맞춤법이 :

<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 

이어야

<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 

hibernate이지만 hiberante이 아닙니다.

+0

예제에 추가하는 것을 잊어 버렸지 만, 내 문제는 PostgreSQL, byt MySQL이 아닙니다. –

+1

@ Vojtěch 내 업데이트 된 답변을 참조하십시오. –

1
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/demo</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password">root</property> 
관련 문제