2
respostas

Configurei o MySql

Usei na minha aplicação o Mysql, no trecho do código dentro do persistence.xml, com o update funcionou o código normalmente, porém usando o create não deu certo, então criei a tabela manualmente, quando houve a mudança na classe produto ( o professor incluiu o atributo dataCadastro, ) funciou normal usando o update, porém quando usa no valor o create (se apagar as tabelas do banco ), o código não funciona, ele não cria as tabelas,gostaria de saber o porque.

2 respostas

Oi Guilherme,

Qual erro aconteceu ao usar o create?

Então, eu já finalizei o curso, consegui contornar esse problema, criando a tabela manualmente, o erro é esse ------ > Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1602) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1641) at br.com.guilherme.novo.loja.dao.ProdutoDao.retornaPreco(ProdutoDao.java:49) at br.com.guilherme.novo.loja.testes.TesteConsulta.main(TesteConsulta.java:32) Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:67) at org.hibernate.loader.Loader.getResultSet(Loader.java:2304) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2057) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2019) at org.hibernate.loader.Loader.doQuery(Loader.java:948) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) at org.hibernate.loader.Loader.doList(Loader.java:2850) at org.hibernate.loader.Loader.doList(Loader.java:2832) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2664) at org.hibernate.loader.Loader.list(Loader.java:2659) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1625) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1593) ... 3 more Caused by: java.sql.SQLSyntaxErrorException: Table 'bdloja.produtos' doesn't exist at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57) ... 18 more