【发布时间】:2017-05-14 09:26:46
【问题描述】:
我正在尝试从 Spring Boot 应用程序连接到正在运行的 Derby 数据库,但是每次启动我的应用程序时,我都可以看到嵌入式数据库正在启动,而不是连接到现有的数据库。我很确定我的 Derby 数据库正在运行,因为 java -jar $DERBY_HOME/lib/derbyrun.jar server start 的执行没有任何错误,并且我可以从终端连接到数据库(使用 ij> connect 'jdbc:derby://localhost:1527/wrtschatz-db;')。
我正在自动装配 jdbcTemplate
@Component
public class LessonItemsRetriever {
@Autowired
JdbcTemplate jdbcTemplate;
// methods doing jdbcTemplate.query(...)
}
我希望它从我的 application.yml 创建数据源
spring.datasource:
url: jdbc:derby://localhost:1527/wortschatz-db
username: ""
password: ""
driverClassName: org.apache.derby.jdbc.ClientDriver
但实际上,当我尝试执行查询时,它会记录 2017-05-14 11:10:36.698 INFO 6418 --- [ main] o.s.j.d.e.EmbeddedDatabaseFactory : Starting embedded database: url='jdbc:derby:memory:testdb;create=true', username='sa',这当然会导致 Schema 'SA' does not exist; nested exception is java.sql.SQLSyntaxErrorException: Schema 'SA' does not exist。
我的配置中缺少什么?
【问题讨论】:
标签: java spring-boot derby jdbctemplate