- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据 this documentation :
29.1.1 Embedded Database Support
Spring Boot can auto-configure embedded H2, HSQL and Derby databases. You don’t need to provide any connection URLs, simply include a build dependency to the embedded database that you want to use.
和
29.1.2 Connection to a production database
Production database connections can also be auto-configured using a pooling DataSource.
DataSource configuration is controlled by external configuration properties in spring.datasource.*. For example, you might declare the following section in application.properties:
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
[Tip] You often won’t need to specify the driver-class-name since Spring boot can deduce it for most databases from the url.
[Note] For a pooling DataSource to be created we need to be able to verify that a valid Driver class is available, so we check for that before doing anything. I.e. if you set spring.datasource.driver-class-name=com.mysql.jdbc.Driver then that class has to be loadable.
如果我将以下内容放入我的 application.properties 文件中会怎样:
spring.datasource.url=jdbc:hsqldb:file:db/organization-db
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
自从我指定了 spring.datasource.driver-class-name 后,Spring Boot 会自动配置一个池化数据源吗?
或者它只是为嵌入式数据库驱动程序创建一个没有连接池的数据源?
如何确认 Spring Boot 是否使用连接池?
最佳答案
感谢戴夫的回答。我刚刚开始学习 Spring 框架,所以我正在修改它。这是我在 MyApplication.main 方法中所做的,以确认 Spring Boot 是否正在使用连接池:
ApplicationContext context = SpringApplication.run(MyApplication.class);
DataSource dataSource = context.getBean(javax.sql.DataSource.class);
System.out.println("DATASOURCE = " + dataSource);
我得到了以下输出:
DATASOURCE = org.apache.tomcat.jdbc.pool.DataSource@a5b0b86{ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=org.hsqldb.jdbcDriver; maxActive=100; maxIdle=100; minIdle=10; initialSize=10; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=60000; testWhileIdle=false; testOnConnect=false; password=********; url=jdbc:hsqldb:mem:testdb; username=sa; validationQuery=null; validationQueryTimeout=-1; validatorClassName=null; validationInterval=30000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=false; removeAbandonedTimeout=60; logAbandoned=false; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alternateUsernameAllowed=false; commitOnReturn=false; rollbackOnReturn=false; useDisposableConnectionFacade=true; logValidationErrors=false; propagateInterruptState=false; ignoreExceptionOnPreLoad=false; }
我还尝试使用 application.properties 文件和我的 build.grade 文件进行不同的配置,以确认 Spring Boot 在自动配置 DataSource 时是否仍会使用连接池我发现 Spring Boot 的自动配置总是创建一个池化数据源。
关于spring-mvc - Spring 启动+JDBC+HSQLDB : How to Verify if Spring Boot is using a Connection Pool?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36570276/
有没有办法截断HSQLDB中的所有表? 如果这不可能,是否有任何方法可以级联删除具有外键引用的表? 最佳答案 可以截断模式中的所有表: 截断模式并提交 此命令有一些选项在指南中有描述: http://
DB 中的表数量有限制吗? 模式内的表数量是否有一些限制? 最佳答案 希望这可以帮助 What are the limitations of the database (size of columns
我想在 .script 文件中评论一个查询,我该怎么做?我用 # 测试过, -- , ({}) , , ::没有任何效果。我收到有关意外 token 的广告异常。 最佳答案 Spring 嵌入式数据
我想以编程方式启动 HSQLdb 服务器。 我创建了一个如下所示的可运行对象,然后在一个线程中启动它。 Runnable hsqlRunnable = new Runnable() {
我正在尝试使用 Liquibase 1.9.5 将一些数据加载到 HSQLDB 数据库中。我有一个 loadData 命令如下: 在我的 CSV 数据文件中,我试图将
我正在使用 HSQLDB 来持久化一个小数据,在我的查询中,我想在第一次创建表,如果它们不再存在。 但是,对于 HSQLDB,我无法像 mysql 或 mssql 等其他 dbms 一样执行查询“CR
我正在尝试将 HSQLDB 用作 spring 应用程序中的嵌入式数据库(用于测试)。由于目标生产数据库是Oracle,我想使用HSQLDBs Oracle 语法模式特性。 在我使用的 Spring
是否有与 MYSQL SHOW COLUMNS from TABLE 命令等效的 HSQLDB? 最佳答案 HSQLDB 没有用于显示表、列或其他数据库对象的单独命令。 为此目的,您使用 SELECT
我想做什么 如何让 maven/eclipse 指向 2.3.2 jar? 通过 Java/jdbc 连接到 HSQL 数据库(我想一旦我解决了上述问题我应该能够这样做) 我的设置 看来我的hsql服
当我的列名包含连字符“-”时出现异常 Entity : this is the entity name. @Entity @Table(name = "RequestHeade
我们有一个设置,使用嵌入式 HSQLDB 来支持 Java 中的 Hibernate/JPA 单元测试,并且我们使用内存数据库模式,因为我们只是希望在测试运行后丢弃数据库。我的问题是,其中一项测试由于
如何在HSQLDB 和C# .net 之间形成连接?我已经看过 SharpHSQL 和 H2Sharp,但无法连接 HSQLDB。 最佳答案 试试这样:确保您已经添加 hsqldb.dll、IKVM.
我正在尝试使用 Hibernate 和 HSQLDB。我试图将教程改编为更当前的版本,所以可能存在问题。当我使用 JUnit 运行单元测试时会发生这种情况。 我将 HSQLDB 2.3.2 与 Hib
我有 DAO 代码,其中包含一些具有 Oracle 特定语法的 JDBC,例如: select count(*) cnt from DUAL where exists (select null fro
我经常使用内存中的 HSQL 数据库作为测试数据库来编写依赖于数据库的代码的单元测试。最近我决定从 1.8.1.3 升级到 2.2.9 以利用 2.x 版本分支中添加的 ROW_NUMBER() 支持
要使用缓存表,我可以使用驱动程序 URL:jdbc:hsqldb:mem或者我应该使用 jdbc:hsqldb:file ? 我需要一个非持久性临时表来保存更多可以放入内存的数据。 文档中不清楚是否使
我正在尝试使用 2.2.9、Hibernate 3.6.9 和 Spring 3.1.2 版本设置 HSQL 数据库进行测试。我们一直在使用本地 postgresql 数据库,但正在转换以进行测试。我
我正在创建一个使用嵌入式hsqldb的基于Spring的Web应用程序。 我的spring配置非常简单: 但是通过此配置,所有数据都存储在内存中。这是创建的数据源URL jdbc:hsq
“如何索引 HSQL 数据库?” 最佳答案 您不索引数据库,而是在表中的字段上创建索引。您可以在单个列上创建索引,也可以在多个列上创建单个索引。 从这里开始 http://www.hsqldb.org
如何查看HSQLDB中表的结构(列的详细信息等)?它不像Oracle那样“desc”,那又如何呢? 最佳答案 该信息由INFORMATION_SCHEMA中的 View 提供 SELECT * FRO
我是一名优秀的程序员,十分优秀!