3
Good I’m trying to connect the postgresql, however, without success. My application will be an application jsf and so I’m using persistence.
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/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">
<persistence-unit name="comunicaVisual"
transaction-type="RESOURCE_LOCAL">
<jar-file>lib/postgresql-9.3-1101.jdbc3.jar</jar-file>
<class>entys.Pessoa</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<validation-mode>AUTO</validation-mode>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/postgres" />
<property name="javax.persistence.jdbc.user" value="testepg" />
<property name="javax.persistence.jdbc.password" value="336445" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.shutdown" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>
</properties>
</persistence-unit>
</persistence>
The error that is happening is as follows. I hope someone’s been there.
Good afternoon pleasure and thanks for the reply however the jars are added in the project lib and in the path also now the error that is happening is another [Hibernate: select nextval ('producto_id_seq') Hibernate: Insert into person (name, id) values (?, ?) ] I hope someone can help
– André Martins
@Andremartins This mistake there probably has something to do with the
SEQUENCE
that you created in the bank. You posted part of the log, but there is no error there. It may be a problem in the database, such as the SEQUENCE does not exist or the user used does not have permission. It may also be an error in mapping, such as incorrect annotation or incorrect SEQUENCE name. Give a check and if you fail, post another question by placing your entity and pertinent details about the bank’s structure. Hug.– utluiz
thanks, what was happening was that the table in the bank had a field more... however I managed to solve... I’m with another question now is to get change the scheme in the application... mysql is easy now postgresql is very complicated.
– André Martins
@Andremartins How to change the scheme? If you want to use tables of different schemes, just use the attribute
schema
in the annotation@Table
.– utluiz