forked from spring-projects/spring-framework
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use code includes and tabs in connections.adoc
- Loading branch information
Showing
11 changed files
with
249 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...org/springframework/docs/dataaccess/jdbc/jdbcdatasource/BasicDataSourceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.docs.dataaccess.jdbc.jdbcdatasource; | ||
|
||
import org.apache.commons.dbcp2.BasicDataSource; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
class BasicDataSourceConfiguration { | ||
|
||
// tag::dataSourceBean[] | ||
@Bean(destroyMethod = "close") | ||
BasicDataSource dataSource() { | ||
BasicDataSource dataSource = new BasicDataSource(); | ||
dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); | ||
dataSource.setUrl("jdbc:hsqldb:hsql://localhost:"); | ||
dataSource.setUsername("sa"); | ||
dataSource.setPassword(""); | ||
return dataSource; | ||
} | ||
// end::dataSourceBean[] | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ringframework/docs/dataaccess/jdbc/jdbcdatasource/ComboPooledDataSourceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.docs.dataaccess.jdbc.jdbcdatasource; | ||
|
||
import java.beans.PropertyVetoException; | ||
|
||
import com.mchange.v2.c3p0.ComboPooledDataSource; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
class ComboPooledDataSourceConfiguration { | ||
|
||
// tag::dataSourceBean[] | ||
@Bean(destroyMethod = "close") | ||
ComboPooledDataSource dataSource() throws PropertyVetoException { | ||
ComboPooledDataSource dataSource = new ComboPooledDataSource(); | ||
dataSource.setDriverClass("org.hsqldb.jdbcDriver"); | ||
dataSource.setJdbcUrl("jdbc:hsqldb:hsql://localhost:"); | ||
dataSource.setUser("sa"); | ||
dataSource.setPassword(""); | ||
return dataSource; | ||
} | ||
// end::dataSourceBean[] | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...ngframework/docs/dataaccess/jdbc/jdbcdatasource/DriverManagerDataSourceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.docs.dataaccess.jdbc.jdbcdatasource; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.jdbc.datasource.DriverManagerDataSource; | ||
|
||
@Configuration | ||
class DriverManagerDataSourceConfiguration { | ||
|
||
// tag::dataSourceBean[] | ||
@Bean | ||
DriverManagerDataSource dataSource() { | ||
DriverManagerDataSource dataSource = new DriverManagerDataSource(); | ||
dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); | ||
dataSource.setUrl("jdbc:hsqldb:hsql://localhost:"); | ||
dataSource.setUsername("sa"); | ||
dataSource.setPassword(""); | ||
return dataSource; | ||
} | ||
// end::dataSourceBean[] | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...n/org/springframework/docs/dataaccess/jdbc/jdbcdatasource/BasicDataSourceConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.springframework.docs.dataaccess.jdbc.jdbcdatasource | ||
|
||
import org.apache.commons.dbcp2.BasicDataSource | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class BasicDataSourceConfiguration { | ||
|
||
// tag::dataSourceBean[] | ||
@Bean(destroyMethod = "close") | ||
fun dataSource(): BasicDataSource { | ||
val dataSource = BasicDataSource() | ||
dataSource.driverClassName = "org.hsqldb.jdbcDriver" | ||
dataSource.url = "jdbc:hsqldb:hsql://localhost:" | ||
dataSource.username = "sa" | ||
dataSource.password = "" | ||
return dataSource | ||
} | ||
// end::dataSourceBean[] | ||
} |
22 changes: 22 additions & 0 deletions
22
...springframework/docs/dataaccess/jdbc/jdbcdatasource/ComboPooledDataSourceConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.springframework.docs.dataaccess.jdbc.jdbcdatasource | ||
|
||
import com.mchange.v2.c3p0.ComboPooledDataSource | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
internal class ComboPooledDataSourceConfiguration { | ||
|
||
// tag::dataSourceBean[] | ||
@Bean(destroyMethod = "close") | ||
fun dataSource(): ComboPooledDataSource { | ||
val dataSource = ComboPooledDataSource() | ||
dataSource.driverClass = "org.hsqldb.jdbcDriver" | ||
dataSource.jdbcUrl = "jdbc:hsqldb:hsql://localhost:" | ||
dataSource.user = "sa" | ||
dataSource.password = "" | ||
return dataSource | ||
} | ||
// end::dataSourceBean[] | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ringframework/docs/dataaccess/jdbc/jdbcdatasource/DriverManagerDataSourceConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2002-2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.docs.dataaccess.jdbc.jdbcdatasource | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.jdbc.datasource.DriverManagerDataSource | ||
|
||
@Configuration | ||
class DriverManagerDataSourceConfiguration { | ||
|
||
// tag::dataSourceBean[] | ||
@Bean | ||
fun dataSource() = DriverManagerDataSource().apply { | ||
setDriverClassName("org.hsqldb.jdbcDriver") | ||
url = "jdbc:hsqldb:hsql://localhost:" | ||
username = "sa" | ||
password = "" | ||
} | ||
// end::dataSourceBean[] | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
.../org/springframework/docs/dataaccess/jdbc/jdbcdatasource/BasicDataSourceConfiguration.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:context="http://www.springframework.org/schema/context"> | ||
|
||
<!-- tag::dataSourceBean[] --> | ||
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"> | ||
<property name="driverClassName" value="${jdbc.driverClassName}"/> | ||
<property name="url" value="${jdbc.url}"/> | ||
<property name="username" value="${jdbc.username}"/> | ||
<property name="password" value="${jdbc.password}"/> | ||
</bean> | ||
|
||
<context:property-placeholder location="jdbc.properties"/> | ||
<!-- end::dataSourceBean[] --> | ||
</beans> |
15 changes: 15 additions & 0 deletions
15
...pringframework/docs/dataaccess/jdbc/jdbcdatasource/ComboPooledDataSourceConfiguration.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:context="http://www.springframework.org/schema/context"> | ||
|
||
<!-- tag::dataSourceBean[] --> | ||
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> | ||
<property name="driverClass" value="${jdbc.driverClassName}"/> | ||
<property name="jdbcUrl" value="${jdbc.url}"/> | ||
<property name="user" value="${jdbc.username}"/> | ||
<property name="password" value="${jdbc.password}"/> | ||
</bean> | ||
|
||
<context:property-placeholder location="jdbc.properties"/> | ||
<!-- end::dataSourceBean[] --> | ||
</beans> |
15 changes: 15 additions & 0 deletions
15
...ingframework/docs/dataaccess/jdbc/jdbcdatasource/DriverManagerDataSourceConfiguration.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:context="http://www.springframework.org/schema/context"> | ||
|
||
<!-- tag::dataSourceBean[] --> | ||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | ||
<property name="driverClassName" value="${jdbc.driverClassName}"/> | ||
<property name="url" value="${jdbc.url}"/> | ||
<property name="username" value="${jdbc.username}"/> | ||
<property name="password" value="${jdbc.password}"/> | ||
</bean> | ||
|
||
<context:property-placeholder location="jdbc.properties"/> | ||
<!-- end::dataSourceBean[] --> | ||
</beans> |