mysql - Connecting to an AWS MySQL Database from Scala with Slick
问题描述
i just created my first AWS MySQL Database and want to connect to that from my scala application using Slick.
My config file shows:
awsMySQL = {
profile = "slick.jdbc.MySQLProfile$"
dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
properties = {
url = "jdbc:mysql://<databaseName>.cn17tbad2awy.eu-central-1.rds.amazonaws.com"
user = "foo"
password = "bar"
driver = com.mysql.cj.jdbc.Driver
}
connectionPool = disabled
keepAliveConnection = true
}
I just define a query to receive all my customers, but when exeuting this code i receive a SQLException: No database selected.
val db = Database.forConfig("awsMySQL")
val CustomersDAO = TableQuery[Customers]
val q1 = for (c <- CustomersDAO) yield c.name
val a = q1.result
val f = db.run(a)
Await.result(f, Duration.Inf)
I do not really understand this exception, because from my point of view by the url specifies the database. Could you please help me.
Thanks in advance.
解决方案
我认为您指向的是运行 MySQL 服务的主机,而不是数据库本身
尝试url = "jdbc:mysql://<databaseName>.cn17tbad2awy.eu-central-1.rds.amazonaws.com"
用类似的东西替换:
url = "jdbc:mysql://<databaseName>.cn17tbad2awy.eu-central-1.rds.amazonaws.com/DBSCHEMA"
推荐阅读
- asp.net - 角度问题 - 无法获取 /
- python - 使用flask babel相应地设置html标签语言属性
- java - org.springframework.beans.factory.BeanCreationException:创建 ServletContext 资源中定义的名称为“entityManagerFactory”的 bean 时出错
- angular - 增加z-index的角小吃店不起作用?
- android - Android 8.0 - Google API 26 升级失败
- f# - 为什么我不能使用显式类型管道函数
- python - 使用另一个多索引系列屏蔽数据框
- excel - 将列值展平为逗号分隔列表
- android-studio-3.0 - 安卓工作室 3.2。当 buildType = release -> Error: commons-logging 定义的类与 Android 现在提供的类冲突
- java - 没有别名就不可能覆盖父bean吗?