Hibernate e JSF apostila FJ28 caelum

3 respostas
Y

Olá pessoal, sou novo no java web e estou tentando executar a apostila fj28 da caelum. Estou tendo o seguinte erro no exercício 3.8

22/06/2009 13:34:01 org.hibernate.cfg.annotations.Version 

INFO: Hibernate Annotations 3.3.1.GA

22/06/2009 13:34:02 org.hibernate.cfg.Environment 

INFO: Hibernate 3.2.5

22/06/2009 13:34:02 org.hibernate.cfg.Environment 

INFO: hibernate.properties not found

22/06/2009 13:34:02 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: Bytecode provider name : cglib

22/06/2009 13:34:02 org.hibernate.cfg.Environment 

INFO: using JDK 1.4 java.sql.Timestamp handling

22/06/2009 13:34:02 org.hibernate.cfg.Configuration configure

INFO: configuring from resource: /hibernate.cfg.xml

22/06/2009 13:34:02 org.hibernate.cfg.Configuration getConfigurationInputStream

INFO: Configuration resource: /hibernate.cfg.xml

22/06/2009 13:34:02 org.hibernate.cfg.Configuration doConfigure

INFO: Configured SessionFactory: null

22/06/2009 13:34:02 org.hibernate.cfg.AnnotationBinder bindClass

INFO: Binding entity from annotated class: emp.yves.bd.Usuarios

22/06/2009 13:34:02 org.hibernate.cfg.annotations.EntityBinder bindTable

INFO: Bind entity emp.yves.bd.Usuarios on table USUARIOS

22/06/2009 13:34:02 org.hibernate.validator.Version 

INFO: Hibernate Validator 3.0.0.GA

22/06/2009 13:34:02 org.hibernate.connection.DriverManagerConnectionProvider configure

INFO: Using Hibernate built-in connection pool (not for production use!)

22/06/2009 13:34:02 org.hibernate.connection.DriverManagerConnectionProvider configure

INFO: Hibernate connection pool size: 20

22/06/2009 13:34:02 org.hibernate.connection.DriverManagerConnectionProvider configure

INFO: autocommit mode: false

22/06/2009 13:34:02 org.hibernate.connection.DriverManagerConnectionProvider configure

INFO: using driver: org.firebirdsql.jdbc.FBDriver at URL: jdbc:firebirdsql://127.0.0.1:3050/c:/java/ConDent.fdb

22/06/2009 13:34:02 org.hibernate.connection.DriverManagerConnectionProvider configure

INFO: connection properties: {user=SYSDBA, password=****}

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

WARNING: Could not obtain connection metadata

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544472. Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

Reason: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:122)

at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:131)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:140)

at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)

at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

at emp.yves.bd.NewClass.main(NewClass.java:24)

at org.firebirdsql.gds.GDSException: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2169)

at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2119)

at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.internalAttachDatabase(AbstractJavaGDSImpl.java:434)

at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscAttachDatabase(AbstractJavaGDSImpl.java:369)

at org.firebirdsql.jca.FBManagedConnection.(FBManagedConnection.java:86)

at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:477)

at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:69)

at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:119)

at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:131)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:140)

at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)

at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

at emp.yves.bd.NewClass.main(NewClass.java:24)

22/06/2009 13:34:02 org.hibernate.dialect.Dialect 

INFO: Using dialect: org.hibernate.dialect.FirebirdDialect

22/06/2009 13:34:02 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory

INFO: Using default transaction strategy (direct JDBC transactions)

22/06/2009 13:34:02 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup

INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Automatic flush during beforeCompletion(): disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Automatic session close at end of transaction: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Scrollable result sets: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JDBC3 getGeneratedKeys(): disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Connection release mode: auto

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Default batch fetch size: 1

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Generate SQL with comments: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Order SQL updates by primary key: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Order SQL inserts for batching: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory

INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory

22/06/2009 13:34:02 org.hibernate.hql.ast.ASTQueryTranslatorFactory 

INFO: Using ASTQueryTranslatorFactory

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Query language substitutions: {}

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: JPA-QL strict compliance: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Second-level cache: enabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Query cache: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory createCacheProvider

INFO: Cache provider: org.hibernate.cache.NoCacheProvider

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Optimize cache for minimal puts: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Structured second-level cache entries: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Echoing all SQL to stdout

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Statistics: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Deleted entity synthetic identifier rollback: disabled

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Default entity-mode: pojo

22/06/2009 13:34:02 org.hibernate.cfg.SettingsFactory buildSettings

INFO: Named query checking : enabled

22/06/2009 13:34:02 org.hibernate.impl.SessionFactoryImpl 

INFO: building session factory

22/06/2009 13:34:03 org.hibernate.impl.SessionFactoryObjectFactory addInstance

INFO: Not binding factory to JNDI, no JNDI name configured

22/06/2009 13:34:03 org.hibernate.util.JDBCExceptionReporter logExceptions

WARNING: SQL Error: 335544472, SQLState: HY000

22/06/2009 13:34:03 org.hibernate.util.JDBCExceptionReporter logExceptions

SEVERE: GDS Exception. 335544472. Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

Reason: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

Exception in thread main org.hibernate.exception.GenericJDBCException: Cannot open connection

at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)

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

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

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

at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)

at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)

at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)

at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)

at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)

at emp.yves.bd.NewClass.main(NewClass.java:31)

Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544472. Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

Reason: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:122)

at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:131)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:140)

at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)

at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)

 5 more

Java Result: 1

meu hibernate.cfg segue abaixo

<?xml version="1.0" encoding="UTF-8"?> org.hibernate.dialect.FirebirdDialect org.firebirdsql.jdbc.FBDriver jdbc:firebirdsql://127.0.0.1:3050/c:/java/ConDent.fdb SYSDBA MASTERKEY true true

a única coisa diferente que fiz foi utilizar uma base de dados criada anteriormente por mim no firebird onde chave primária tem um trigger e um generator para autoincremento. Vou passar também a minha classe usuários

@Entity
@Table(name = “USUARIOS”)

public class Usuarios implements Serializable {

private static final long serialVersionUID = 1L;

@Id

@Column(name = ID)

@GeneratedValue(strategy=GenerationType.AUTO)

private Integer id;

@Column(name = LOGIN)

private String login;

@Column(name = SENHA)

private String senha;
public Usuarios() {
}

public Usuarios(Integer id) {
    this.id = id;
}

public Integer getId() {
    return id;
}

public void setId(Integer id) {
    this.id = id;
}

public String getLogin() {
    return login;
}

public void setLogin(String login) {
    this.login = login;
}

public String getSenha() {
    return senha;
}

public void setSenha(String senha) {
    this.senha = senha;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Usuarios)) {
        return false;
    }
    Usuarios other = (Usuarios) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "emp.yves.bd.Usuarios[id=" + id + "]";
}

}

se alguém puder me ajudar, ficaria muito grato.

3 Respostas

P

Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

Reason: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.

jdbc:firebirdsql://127.0.0.1:3050/c:/java/ConDent.fdb

No lugar disso c:/java/ConDent.fdb vai o nome do banco :!:

Precisa verificar seu usuário e senha também. :shock:

Y

Puka obrigado por responder tão rápido, mas ainda não funcionou coloquei jdbc:firebirdsql://127.0.0.1:3050/ConDent no local da property e continuou com o mesmo erro, coloquei só Condent e então gera uma sqlException parece que não encontra o banco. Com a url jdbc:firebirdsql://127.0.0.1:3050/ConDent.fdb eu consigo acessar a base pelo JDBC, mas com hibernate não tá dando, há algo de errado com a conexão e eu não sei o que é. Será alguma propriedade que eu não configurei? Mas na apostila não cita nada à respeito.
Valeu

P

http://www.guj.com.br/posts/list/34995.java

Criado 22 de junho de 2009
Ultima resposta 24 de jun. de 2009
Respostas 3
Participantes 2