Conexão ao Banco mysql
24/11/2013 13:56
1
Alá galera
Já tentei de tudo mas não tem jeito. Minha versão do grails é 2.3.2 e estou seguindo a vídeo aula do site: http://www.itexto.net/devkico/?page_id=1016
Aliás muito boa, mas estou tendo este problema, já dei um "grails clean" e não resolveu.
Estou com o seguinte erro:


| Running Grails application
| Error 2013-11-24 13:47:13,455 [localhost-startStop-1] ERROR context.GrailsCon
extLoader - Error initializing the application: Error creating bean with name
transactionManagerPostProcessor': Initialization of bean failed; nested excepti
n is org.springframework.beans.factory.BeanCreationException: Error creating be
n with name 'transactionManager': Cannot resolve reference to bean 'sessionFact
ry' while setting bean property 'sessionFactory'; nested exception is org.sprin
framework.beans.factory.BeanCreationException: Error creating bean with name 's
ssionFactory': Cannot resolve reference to bean 'hibernateProperties' while set
ing bean property 'hibernateProperties'; nested exception is org.springframewor
.beans.factory.BeanCreationException: Error creating bean with name 'hibernateP
operties': Cannot resolve reference to bean 'dialectDetector' while setting bea
property 'properties' with key [hibernate.dialect]; nested exception is org.sp
ingframework.beans.factory.BeanCreationException: Error creating bean with name
'dialectDetector': Invocation of init method failed; nested exception is org.sp
ingframework.jdbc.support.MetaDataAccessException: Error while extracting Datab
seMetaData; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsE
ception: Communications link failure

Last packet sent to the server was 0 ms ago.
Message: Error creating bean with name 'transactionManagerPostProcessor': Initi
lization of bean failed; nested exception is org.springframework.beans.factory.
eanCreationException: Error creating bean with name 'transactionManager': Canno
resolve reference to bean 'sessionFactory' while setting bean property 'sessio
Factory'; nested exception is org.springframework.beans.factory.BeanCreationExc
ption: Error creating bean with name 'sessionFactory': Cannot resolve reference
to bean 'hibernateProperties' while setting bean property 'hibernateProperties'
nested exception is org.springframework.beans.factory.BeanCreationException: E
ror creating bean with name 'hibernateProperties': Cannot resolve reference to
ean 'dialectDetector' while setting bean property 'properties' with key [hibern
te.dialect]; nested exception is org.springframework.beans.factory.BeanCreation
xception: Error creating bean with name 'dialectDetector': Invocation of init m
thod failed; nested exception is org.springframework.jdbc.support.MetaDataAcces
Exception: Error while extracting DatabaseMetaData; nested exception is com.mys
l.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'transactionMana
er': Cannot resolve reference to bean 'sessionFactory' while setting bean prope
ty 'sessionFactory'; nested exception is org.springframework.beans.factory.Bean
reationException: Error creating bean with name 'sessionFactory': Cannot resolv
reference to bean 'hibernateProperties' while setting bean property 'hibernate
roperties'; nested exception is org.springframework.beans.factory.BeanCreationE
ception: Error creating bean with name 'hibernateProperties': Cannot resolve re
erence to bean 'dialectDetector' while setting bean property 'properties' with
ey [hibernate.dialect]; nested exception is org.springframework.beans.factory.B
anCreationException: Error creating bean with name 'dialectDetector': Invocatio
of init method failed; nested exception is org.springframework.jdbc.support.Me
aDataAccessException: Error while extracting DatabaseMetaData; nested exception
is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link
failure

Last packet sent to the server was 0 ms ago.
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'sessionFactory'
Cannot resolve reference to bean 'hibernateProperties' while setting bean prop
rty 'hibernateProperties'; nested exception is org.springframework.beans.factor
.BeanCreationException: Error creating bean with name 'hibernateProperties': Ca
not resolve reference to bean 'dialectDetector' while setting bean property 'pr
perties' with key [hibernate.dialect]; nested exception is org.springframework.
eans.factory.BeanCreationException: Error creating bean with name 'dialectDetec
or': Invocation of init method failed; nested exception is org.springframework.
dbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; n
sted exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Comm
nications link failure

Last packet sent to the server was 0 ms ago.
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'hibernateProper
ies': Cannot resolve reference to bean 'dialectDetector' while setting bean pro
erty 'properties' with key [hibernate.dialect]; nested exception is org.springf
amework.beans.factory.BeanCreationException: Error creating bean with name 'dia
ectDetector': Invocation of init method failed; nested exception is org.springf
amework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMe
aData; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsExcept
on: Communications link failure

Last packet sent to the server was 0 ms ago.
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'dialectDetector
: Invocation of init method failed; nested exception is org.springframework.jdb
.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nest
d exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communi
ations link failure

Last packet sent to the server was 0 ms ago.
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nes
ed exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Commun
cations link failure

Last packet sent to the server was 0 ms ago.
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
->> 406 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1074 | createCommunicationsException in com.mysql.jdbc.SQLError
| 2103 | createNewIO in com.mysql.jdbc.ConnectionImpl
| 718 | <init> in ''
| 46 | <init> . in com.mysql.jdbc.JDBC4Connection
| 406 | handleNewInstance in com.mysql.jdbc.Util
| 302 | getInstance in com.mysql.jdbc.ConnectionImpl
| 282 | connect in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Caused by ConnectException: Connection refused: connect
->> 79 | socketConnect in java.net.DualStackPlainSocketImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 339 | doConnect in java.net.AbstractPlainSocketImpl
| 200 | connectToAddress in ''
| 182 | connect in ''
| 172 | connect . in java.net.PlainSocketImpl
| 392 | connect in java.net.SocksSocketImpl
| 579 | connect . in java.net.Socket
| 528 | connect in ''
| 425 | <init> . in ''
| 241 | <init> in ''
| 253 | connect . in com.mysql.jdbc.StandardSocketFactory
| 280 | <init> in com.mysql.jdbc.MysqlIO
| 2026 | createNewIO in com.mysql.jdbc.ConnectionImpl
| 718 | <init> in ''
| 46 | <init> . in com.mysql.jdbc.JDBC4Connection
| 406 | handleNewInstance in com.mysql.jdbc.Util
| 302 | getInstance in com.mysql.jdbc.ConnectionImpl
| 282 | connect in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread

Tags: mysql


1
Oi Cleber, legal que tenha gostado do vídeo, valeu!

Dando uma olhada no seu log vejo duas coisas que podem estar errado:

* O que você digitou na instrução dialect?
* Jà tentou acessar o banco de dados usando um cliente qualquer (como o Workbench) usando as configurações que estão no seu arquivo?

Rola de postar aqui seu arquivo DataSource.groovy?


0
Olá, que bom que me respondeu, eu editei o arquivo DataSourse.groovy, de acordo com uma postagem que estava neste Fórum, também tentei igual a do vídeo mas não rolou também.
Desculpe mas sou iniciante nesta área com groovy end grails! ou seja em programação em geral!!
não sei se esta correto, e lembrando que já adicionei o arquivo jar do mysql-connector-java-5.1.6 na pasta lib. Eu só tenho instalado o xamp com mysql e phpMyadmin. E estou usando a configuração padrão de usuário root e sem senha para facilitar. Sei que não é o ideal!!!
Segue abaixo o meu código:


dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}

// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306//projektor"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306//projektor"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306//projektor"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
jdbcInterceptors="ConnectionState"
}
}
}
}






0
Olá pessoal resolvi o problema, foi uma voada minha mesmo, é que o grails é tão bom que eu pensei que ele tambem criava o banco pra gente, rsrsrsrsrs, na verdade ele cria as tabelas com as relações, no caso o banco em si temos que criar. Criei o banco com o phpMyAdmin e fiz como estava no video e foi só partir pro abraço. Valeu pelas respostas Kico.

Como já disse sou iniciante nesta área.

Abraço a todos.



Ainda não faz parte da comunidade???

Para se registrar, clique aqui.


Aprenda Groovy e Grails com a Formação itexto!

Newsletter Semana Groovy

Assinar

Envie seu link!


Livro de Grails


/dev/All

Os melhores blogs de TI (e em português) em um único lugar!

 
Creative Commons
RSS Grails Brasil é mantido por itexto Consultoria.
Em caso de problemas contacte Henrique Lobo Weissmann (Kico) por e-mail: kico@itexto.com.br
Todo o conteúdo presente neste site adota o Creative Commons como licença padrão.
Ver: 4.14.0
itexto