In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces Oracle+mybatis how to achieve the function of adding, deleting, modifying and querying data, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
What is MyBatis?
MyBatis is an excellent persistence layer framework that supports normal SQL queries, stored procedures, and advanced mapping. MyBatis eliminates almost all manual setting of JDBC code and parameters and retrieval of result sets. MyBatis can use simple XML or annotations for configuration and raw mapping, mapping interfaces and Java's POJO (Plain Old Java Objects, plain Java objects) to records in the database.
This article will introduce in detail the relevant contents of using Oracle + mybatis to realize the simple addition, deletion, modification and query of data. I won't say much below, let's take a look at the detailed introduction.
The steps are as follows:
Step 1:-- create a tablespace named mybatis and build it under the date folder under disk D:
Step 2: create a user whose name is lisi and password: 123456
Step 3: authorize the user:
Step 4: we create an emp table under the lisi user:
Insert a few values at will:
(this watch is available online and can be taken off.)
Step 5: (eclipse is used here) Open eclipse to set up a maven project and search for mybatis guide packages in the online maven repository
We use 3.4.6 this:
Paste this code into the pom.xml of the project you just built in eclipse "must be connected to the network": download:
Then find the ojdbc6.jar in the installation Oracle path and glue it to the project: right-click to import:
As shown in the figure:
Step 6: establish config.xml under src/main/resources: configure database connection information
-- =
By now, the configuration of mybatis has been completed:
Step 7: create bean package, mapper package and test package (test) under src/main/Java:
1. Encapsulate the information of the emp table:
two。 Establish the EmpMapper class
3. Create the EmpMapper.xml file:
3. Set up the test class for testing:
1 > query via id:
The results are as follows:
2 > add: (note: except for queries that do not need to commit transactions, all other additions, deletions and changes need to commit transactions)
The query results of the database are as follows:
3. Change:
Results:
Xiao Wang is no longer in the database:
4. Full query:
Results:
Thank you for reading this article carefully. I hope the article "how to add, delete, modify and query data in Oracle+mybatis" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.