英文:
how to connect grails with mysql and why grails compile shows :compileJava NO-SOURCE
问题
我在使用Grails 3项目中遇到了使用MySql的问题。
Application.yml 文件--
---
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
dataSource: # <- 修改 !!!
pooled: true
jmxExport: true
driverClassName: com.mysql.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
environments:
development:
dataSource: # <- 修改 !!!
username: root
password:
dbCreate: create-drop # 选项有 'create', 'create-drop', 'update', 'validate', ''
url: jdbc:mysql://localhost:8888/nsl_api
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: none
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
在 Build.gradle 中,我使用了 runtime 'mysql:mysql-connector-java:5.1.29'
依赖。
当我使用 grials compile
命令时,出现了 :compileJava NO-SOURCE
的错误。如何在 IntelliJ IDEA 中添加 Java 源代码?我不太清楚,因为我是新来的。请帮忙。
另一个错误是
ERROR --- [main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
还有一个错误是 Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
如何连接 MySQL 数据库到我的 Grails 项目?我也运行了 XAMPP 软件,其中包含了 Apache、MySQL 和 Tomcat。我应该怎么做?我如何将数据发送到 MySQL 数据库并逐行在网页上检索数据?
英文:
I am facing problem using MySql with Grails 3 project.
Application.yml file--
---
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
dataSource: # <- CHANGE !!!
pooled: true
jmxExport: true
driverClassName: com.mysql.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
environments:
development:
dataSource: # <- CHANGE !!!
username : root
password :
dbCreate : create-drop # one of 'create', 'create-drop', 'update', 'validate', ''
url : jdbc:mysql://localhost:8888/nsl_api
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: none
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
in Build.gradle, I use runtime 'mysql:mysql-connector-java:5.1.29'
dependencies.
When in use grials compile
command I am getting :compileJava NO-SOURCE
. how to add java source in itellij? I donot know it as I am new here. Please help.
Another error I am getting is
ERROR --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
And another error is Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
How can I connect mysql database with my grails project? I also run xammp software where apache, mysql and tomcat is running. what should I do? How can I send data into mysql database and retrieve that data in a web page row by row.
专注分享java语言的经验与见解,让所有开发者获益!
评论