A tutorial on integrating Dameng database with SpringBoot (detailed explanation)

1. Download the trial version from the official website

http://www.dameng.com/down.aspx

My win 11 system download is as follows:

2. Installation

Double-click to open the iso file after decompression

then click install 

 Choose to create an instance (note that the account/password port number is SYSDBA/SYSDBA 5236 by default)

 

Then go to the next step until it is completed (it can be completed without doing other operations, and the database and visualization tools can be used at this time)

 

The installation is now complete.

3. Visualization tool connection

It comes with a visualization tool, and the directory can be opened as follows:

 

 My connection information is as follows:

 

Successful connection screen and newly created schema (= Mysql database) 

 The following is a new table dm_user and two pieces of data I created

 Test query sql (double quotes must be used as shown in the figure)

4. Use springboot connection test

First find the driver jar package directory as follows:

Because there is no online one, it can only be installed locally with maven. If there is no maven environment, you can use idea to install:

The installation command is as follows (where -Dpackaging=jar -Dfile=D:\xapp\dm\DmJdbcDriver18.jar is the directory of your own driver jar):

mvn install:install-file -DgroupId=com.dm -DartifactId=DmJdbcDriver -Dversion=1.8.0 -Dpackaging=jar -Dfile=D:\xapp\dm\DmJdbcDriver18.jar

After the installation is successful, add the jar point to the pom file of your project:

<dependency>
    <groupId>com.dm</groupId>
    <artifactId>DmJdbcDriver</artifactId>
    <version>1.8.0</version>
</dependency>

Then configure the database related information:

#达梦
    datasource:
        driverClassName: dm.jdbc.driver.DmDriver
        url: jdbc:dm://127.0.0.1:5236/test?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8
        username: SYSDBA
        password: SYSDBA

5. Interface test data

Controller

@RestController
@RequestMapping("/dmtest")
public class TestController {
	
	@Autowired
	TeacherService teacherService;
	
	@GetMapping("/list")
	public ResponseMsg list(int page, int limit) {
		Map<String, Object> query = new HashMap<>();
		List<Teacher> res = teacherService.dmlist(query);
	return new ResponseMsg(res);
	}
 
}

Service

List<Teacher> dmlist(Map<String, Object> query);

ServiceImpl

    @Override
    public List<Teacher> dmlist(Map<String, Object> query) {
        return teacherMapper.dmlist(query);
    }

Mapper (note that you have to use double quotes or you will report an error) 

    @Select("select \"id\", \"name\" from \"test\".\"dm_user\" ")
    List<Teacher> dmlist(Map<String, Object> query);

Interface request result:

over!

 

 

 

Guess you like

Origin blog.csdn.net/m0_69057918/article/details/131089511