Erro ao conectar com o postgreSQL

6 respostas
C

to com um problema estou tentando inserir um dado no postgre mas recebo esta msg :
O servidor pediu autenticação baseada em senha, mas nenhuma senha foi fornecida.

Estou usando Hibernate com Postgre.
meu arquivo do hibenatecfg.xml é:

org.hibernate.dialect.PostgreSQLDialect
org.postgresql.Driver
jdbc:postgresql://localhost:5432/teste
root
bvr1

sera que alguém pode me ajudar ficarei muito grado. Agradeço desde já! Obrigado

6 Respostas

E

Olá,

O postgreSQL possui um arquivo chamado onde voce configura( se não estou enganado: pg_hba.conf ou algo muito parecido ) a forma de autenticação que o servidor esta esperando.

Dentre elas temos o md5, password, trust e outras…

Dentro do próprio arquivo existe exemplos de como configurar o tipo de autenticação, de uma olhada.

Acredito que se voce modificar o tipo de autenticação para password deva funcionar.

Att,

C

Beleza…
Encontrei os arquivos:
Edit pg_hba.conf
Edit pg_ident.conf
Edit postgre.conf

ai meu Edit pg_hba.conf
tem:

“host” is either a plain or SSL-encrypted TCP/IP socket, “hostssl” is an

SSL-encrypted TCP/IP socket, and “hostnossl” is a plain TCP/IP socket.

DATABASE can be “all”, “sameuser”, “samerole”, a database name, or

a comma-separated list thereof.

USER can be “all”, a user name, a group name prefixed with “+”, or

a comma-separated list thereof. In both the DATABASE and USER fields

you can also write a file name prefixed with “@” to include names from

a separate file.

CIDR-ADDRESS specifies the set of hosts the record matches.

It is made up of an IP address and a CIDR mask that is an integer

(between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies

the number of significant bits in the mask. Alternatively, you can write

an IP address and netmask in separate columns to specify the set of hosts.

METHOD can be “trust”, “reject”, “md5”, “crypt”, “password”,

“krb5”, “ident”, or “pam”. Note that “password” sends passwords

in clear text; “md5” is preferred since it sends encrypted passwords.

OPTION is the ident map or the name of the PAM service, depending on METHOD.

Database and user names containing spaces, commas, quotes and other special

characters must be quoted. Quoting one of the keywords “all”, “sameuser” or

“samerole” makes the name lose its special character, and just match a

database or username with that name.

This file is read on server startup and when the postmaster receives

a SIGHUP signal. If you edit the file on a running system, you have

to SIGHUP the postmaster for the changes to take effect. You can use

“pg_ctl reload” to do that.

Put your actual configuration here

----------------------------------

If you want to allow non-local connections, you need to add more

“host” records. In that case you will also need to make PostgreSQL listen

on a non-local interface via the listen_addresses configuration parameter,

or via the -i or -h command line switches.

TYPE DATABASE USER CIDR-ADDRESS METHOD

IPv4 local connections:

host all all 127.0.0.1/32 md5

IPv6 local connections:

#host all all ::1/128 md5

a pergunta é: se este o arquivo que devo alterar e onde devo alderar?
ex: mudar de md5 pa password?
é só isso que devo fazer?

Agrade sua Atenção! Obrigado!

C

[color=red]Alterei de md5 para password e ainda continua dando o mesmo problema…[/color]

D

Mas vc esta conseguindo conectar com o BD ???

E com alguma aplicação externa tipo o pg_admin???

Até mais

C

é o seguinte alterei a configuração do postgree para "trust"
que é acesso livre sem senha…so para testar ai vei outro erro:
error:

Caused by: java.sql.BatchUpdateException: Entrada em lote 0 /* insert classesbasicas.AreaDeEntrega <em>/ insert into AreaDeEntrega (nome, descricao, id) values (Boa Viagem, Area de entrega com grante potencial, 1) foi abortada. Chame getNextException para ver a causa.

at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2497)

at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:399)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1298)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)

at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2559)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)

at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)

… 10 more

2006-11-24 09:55:36,183 DEBUG hibernate.jdbc.ConnectionManager  -> registering flush end

Area de Entrega não Cadastrada

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)

at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)

at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)

at hibernateUtility.HibernateUtility.commitTransaction(HibernateUtility.java:63)

at hibernate.pesistencia.AreaDeEntregaDao.inserir(AreaDeEntregaDao.java:25)

at test.Test.main(Test.java:16)

Caused by: java.sql.BatchUpdateException: Entrada em lote 0 /</em> insert classesbasicas.AreaDeEntrega */ insert into AreaDeEntrega (nome, descricao, id) values (Boa Viagem, Area de entrega com grante potencial, 1) foi abortada. Chame getNextException para ver a causa.

at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2497)

at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:399)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1298)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)

at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2559)

at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)

at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)

 10 more

voce poderia me dizer o pq do error? To precisando muito.! agradeço desde ja! Obrigado!

C

[color=red]org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update [/color]

Criado 24 de novembro de 2006
Ultima resposta 24 de nov. de 2006
Respostas 6
Participantes 3