MyBatis教程– CRUD操作和映射關系–第1部分

CRUD操作
MyBatis是一個SQL Mapper工具,與直接使用JDBC相比,它極大地簡化了數據庫編程。

步驟1:創建一個Maven項目并配置MyBatis依賴項。

<project xmlns='http://maven.apache.org/POM/4.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd'><modelVersion>4.0.0</modelVersion><groupId>com.sivalabs</groupId><artifactId>mybatis-demo</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>mybatis-demo</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>2.3.2</version><configuration><source>1.6</source><target>1.6</target><encoding>${project.build.sourceEncoding}</encoding></configuration></plugin></plugins></build><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.10</version><scope>test</scope></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.1.1</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.21</version><scope>runtime</scope></dependency></dependencies>
</project>

步驟2:創建表USER和Java域對象User,如下所示:

CREATE TABLE  user (user_id int(10) unsigned NOT NULL auto_increment,email_id varchar(45) NOT NULL,password varchar(45) NOT NULL,first_name varchar(45) NOT NULL,last_name varchar(45) default NULL,PRIMARY KEY  (user_id),UNIQUE KEY Index_2_email_uniq (email_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
package com.sivalabs.mybatisdemo.domain;
public class User 
{private Integer userId;private String emailId;private String password;private String firstName;private String lastName;@Overridepublic String toString() {return 'User [userId=' + userId + ', emailId=' + emailId+ ', password=' + password + ', firstName=' + firstName+ ', lastName=' + lastName + ']';}//setters and getters 
}

步驟#3:創建MyBatis配置文件。

a)在src / main / resources文件夾中創建jdbc.properties文件

jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/mybatis-demojdbc.username=rootjdbc.password=admin

b)在src / main / resources文件夾中創建mybatis-config.xml文件

<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE configurationPUBLIC '-//mybatis.org//DTD Config 3.0//EN''http://mybatis.org/dtd/mybatis-3-config.dtd'><configuration><properties resource='jdbc.properties'/><typeAliases><typeAlias type='com.sivalabs.mybatisdemo.domain.User' alias='User'></typeAlias></typeAliases><environments default='development'><environment id='development'><transactionManager type='JDBC'/><dataSource type='POOLED'>    <property name='driver' value='${jdbc.driverClassName}'/><property name='url' value='${jdbc.url}'/><property name='username' value='${jdbc.username}'/><property name='password' value='${jdbc.password}'/></dataSource></environment></environments><mappers><mapper resource='com/sivalabs/mybatisdemo/mappers/UserMapper.xml'/></mappers></configuration>

步驟#4:在com.sivalabs.mybatisdemo.mappers包的src / main / java文件夾中創建一個UserMapper.java接口。

package com.sivalabs.mybatisdemo.mappers;import java.util.List;import com.sivalabs.mybatisdemo.domain.User;public interface UserMapper {public void insertUser(User user);public User getUserById(Integer userId);public List<User> getAllUsers();public void updateUser(User user);public void deleteUser(Integer userId);}

步驟5:在com.sivalabs.mybatisdemo.mappers包的src / main / resources文件夾中創建UserMapper.xml文件。

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper PUBLIC '-//mybatis.org//DTD Mapper 3.0//EN''http://mybatis.org/dtd/mybatis-3-mapper.dtd'><mapper namespace='com.sivalabs.mybatisdemo.mappers.UserMapper'><select id='getUserById' parameterType='int' resultType='com.sivalabs.mybatisdemo.domain.User'>SELECT user_id as userId, email_id as emailId , password, first_name as firstName, last_name as lastNameFROM USER WHERE USER_ID = #{userId}</select><!-- Instead of referencing Fully Qualified Class Names we can register Aliases in mybatis-config.xml and use Alias names. --><resultMap type='User' id='UserResult'><id property='userId' column='user_id'/><result property='emailId' column='email_id'/><result property='password' column='password'/><result property='firstName' column='first_name'/><result property='lastName' column='last_name'/>   </resultMap><select id='getAllUsers' resultMap='UserResult'>SELECT * FROM USER</select><insert id='insertUser' parameterType='User' useGeneratedKeys='true' keyProperty='userId'>INSERT INTO USER(email_id, password, first_name, last_name)VALUES(#{emailId}, #{password}, #{firstName}, #{lastName})</insert><update id='updateUser' parameterType='User'>UPDATE USER SETPASSWORD= #{password},FIRST_NAME = #{firstName},LAST_NAME = #{lastName}WHERE USER_ID = #{userId}</update><delete id='deleteUser' parameterType='int'>DELETE FROM USER WHERE USER_ID = #{userId}</delete></mapper>

步驟#6:創建MyBatisUtil.java實例化SqlSessionFactory。

package com.sivalabs.mybatisdemo.service;import java.io.IOException;
import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;public class MyBatisUtil 
{private static SqlSessionFactory factory;private MyBatisUtil() {}static{Reader reader = null;try {reader = Resources.getResourceAsReader('mybatis-config.xml');} catch (IOException e) {throw new RuntimeException(e.getMessage());}factory = new SqlSessionFactoryBuilder().build(reader);}public static SqlSessionFactory getSqlSessionFactory() {return factory;}
}

步驟#7:在src / main / java文件夾中創建UserService.java。

package com.sivalabs.mybatisdemo.service;import java.util.List;
import org.apache.ibatis.session.SqlSession;
import com.sivalabs.mybatisdemo.domain.User;
import com.sivalabs.mybatisdemo.mappers.UserMapper;public class UserService
{public void insertUser(User user) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{UserMapper userMapper = sqlSession.getMapper(UserMapper.class);userMapper.insertUser(user);sqlSession.commit();}finally{sqlSession.close();}}public User getUserById(Integer userId) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{UserMapper userMapper = sqlSession.getMapper(UserMapper.class);return userMapper.getUserById(userId);}finally{sqlSession.close();}}public List<User> getAllUsers() {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{UserMapper userMapper = sqlSession.getMapper(UserMapper.class);return userMapper.getAllUsers();}finally{sqlSession.close();}}public void updateUser(User user) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{UserMapper userMapper = sqlSession.getMapper(UserMapper.class);userMapper.updateUser(user);sqlSession.commit();}finally{sqlSession.close();}}public void deleteUser(Integer userId) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{UserMapper userMapper = sqlSession.getMapper(UserMapper.class);userMapper.deleteUser(userId);sqlSession.commit();}finally{sqlSession.close();}}}

步驟#8:創建一個JUnit Test類來測試UserService方法。

package com.sivalabs.mybatisdemo;import java.util.List;import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;import com.sivalabs.mybatisdemo.domain.User;
import com.sivalabs.mybatisdemo.service.UserService;public class UserServiceTest 
{private static UserService userService;@BeforeClasspublic static void setup() {userService = new UserService();}@AfterClasspublic static void teardown() {userService = null;}@Testpublic void testGetUserById() {User user = userService.getUserById(1);Assert.assertNotNull(user);System.out.println(user);}@Testpublic void testGetAllUsers() {List<User> users = userService.getAllUsers();Assert.assertNotNull(users);for (User user : users) {System.out.println(user);}}@Testpublic void testInsertUser() {User user = new User();user.setEmailId('test_email_'+System.currentTimeMillis()+'@gmail.com');user.setPassword('secret');user.setFirstName('TestFirstName');user.setLastName('TestLastName');userService.insertUser(user);Assert.assertTrue(user.getUserId() != 0);User createdUser = userService.getUserById(user.getUserId());Assert.assertNotNull(createdUser);Assert.assertEquals(user.getEmailId(), createdUser.getEmailId());Assert.assertEquals(user.getPassword(), createdUser.getPassword());Assert.assertEquals(user.getFirstName(), createdUser.getFirstName());Assert.assertEquals(user.getLastName(), createdUser.getLastName());}@Testpublic void testUpdateUser() {long timestamp = System.currentTimeMillis();User user = userService.getUserById(2);user.setFirstName('TestFirstName'+timestamp);user.setLastName('TestLastName'+timestamp);userService.updateUser(user);User updatedUser = userService.getUserById(2);Assert.assertEquals(user.getFirstName(), updatedUser.getFirstName());Assert.assertEquals(user.getLastName(), updatedUser.getLastName());}@Testpublic void testDeleteUser() {User user = userService.getUserById(4);userService.deleteUser(user.getUserId());User deletedUser = userService.getUserById(4);Assert.assertNull(deletedUser);   }
}

現在,我將解釋如何使用MyBatis注釋支持執行CRUD操作,而無需在XML映射器文件中進行查詢配置。

步驟#1 :創建一個表BLOG和一個Java域對象Blog。

CREATE TABLE  blog (blog_id int(10) unsigned NOT NULL auto_increment,blog_name varchar(45) NOT NULL,created_on datetime NOT NULL,PRIMARY KEY  (blog_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
package com.sivalabs.mybatisdemo.domain;import java.util.Date;public class Blog {private Integer blogId;private String blogName;private Date createdOn;@Overridepublic String toString() {return 'Blog [blogId=' + blogId + ', blogName=' + blogName+ ', createdOn=' + createdOn + ']';}//Seeters and getters
}

步驟2 :在Annotations中使用SQL查詢創建UserMapper.java接口。

package com.sivalabs.mybatisdemo.mappers;import java.util.List;import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;import com.sivalabs.mybatisdemo.domain.Blog;public interface BlogMapper 
{@Insert('INSERT INTO BLOG(BLOG_NAME, CREATED_ON) VALUES(#{blogName}, #{createdOn})')@Options(useGeneratedKeys=true, keyProperty='blogId')public void insertBlog(Blog blog);@Select('SELECT BLOG_ID AS blogId, BLOG_NAME as blogName, CREATED_ON as createdOn FROM BLOG WHERE BLOG_ID=#{blogId}')public Blog getBlogById(Integer blogId);@Select('SELECT * FROM BLOG ')@Results({@Result(id=true, property='blogId', column='BLOG_ID'),@Result(property='blogName', column='BLOG_NAME'),@Result(property='createdOn', column='CREATED_ON')  })public List<Blog> getAllBlogs();@Update('UPDATE BLOG SET BLOG_NAME=#{blogName}, CREATED_ON=#{createdOn} WHERE BLOG_ID=#{blogId}')public void updateBlog(Blog blog);@Delete('DELETE FROM BLOG WHERE BLOG_ID=#{blogId}')public void deleteBlog(Integer blogId);}

步驟#3 :在mybatis-config.xml中配置BlogMapper

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE configurationPUBLIC '-//mybatis.org//DTD Config 3.0//EN''http://mybatis.org/dtd/mybatis-3-config.dtd'>
<configuration><properties resource='jdbc.properties'/><environments default='development'><environment id='development'><transactionManager type='JDBC'/><dataSource type='POOLED'><!-- <property name='driver' value='com.mysql.jdbc.Driver'/><property name='url' value='jdbc:mysql://localhost:3306/mybatis-demo'/><property name='username' value='root'/><property name='password' value='admin'/> --><property name='driver' value='${jdbc.driverClassName}'/><property name='url' value='${jdbc.url}'/><property name='username' value='${jdbc.username}'/><property name='password' value='${jdbc.password}'/></dataSource></environment></environments><mappers><mapper class='com.sivalabs.mybatisdemo.mappers.BlogMapper'/></mappers>
</configuration>

步驟#4 :創建BlogService.java

package com.sivalabs.mybatisdemo.service;import java.util.List;import org.apache.ibatis.session.SqlSession;import com.sivalabs.mybatisdemo.domain.Blog;
import com.sivalabs.mybatisdemo.mappers.BlogMapper;public class BlogService
{public void insertBlog(Blog blog) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);blogMapper.insertBlog(blog);sqlSession.commit();}finally{sqlSession.close();}}public Blog getBlogById(Integer blogId) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);return blogMapper.getBlogById(blogId);}finally{sqlSession.close();}}public List<Blog> getAllBlogs() {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);return blogMapper.getAllBlogs();}finally{sqlSession.close();}}public void updateBlog(Blog blog) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);blogMapper.updateBlog(blog);sqlSession.commit();}finally{sqlSession.close();}  }public void deleteBlog(Integer blogId) {SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();try{BlogMapper blogMapper = sqlSession.getMapper(BlogMapper.class);blogMapper.deleteBlog(blogId);sqlSession.commit();}finally{sqlSession.close();}}}

步驟#5 :為BlogService方法創建JUnit測試

package com.sivalabs.mybatisdemo;import java.util.Date;
import java.util.List;import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;import com.sivalabs.mybatisdemo.domain.Blog;
import com.sivalabs.mybatisdemo.service.BlogService;public class BlogServiceTest 
{private static BlogService blogService;@BeforeClasspublic static void setup() {blogService = new BlogService();}@AfterClasspublic static void teardown() {blogService = null;}@Testpublic void testGetBlogById() {Blog blog = blogService.getBlogById(1);Assert.assertNotNull(blog);System.out.println(blog);}@Testpublic void testGetAllBlogs() {List<Blog> blogs = blogService.getAllBlogs();Assert.assertNotNull(blogs);for (Blog blog : blogs) {System.out.println(blog);}}@Testpublic void testInsertBlog() {Blog blog = new Blog();blog.setBlogName('test_blog_'+System.currentTimeMillis());blog.setCreatedOn(new Date());blogService.insertBlog(blog);Assert.assertTrue(blog.getBlogId() != 0);Blog createdBlog = blogService.getBlogById(blog.getBlogId());Assert.assertNotNull(createdBlog);Assert.assertEquals(blog.getBlogName(), createdBlog.getBlogName());}@Testpublic void testUpdateBlog() {long timestamp = System.currentTimeMillis();Blog blog = blogService.getBlogById(2);blog.setBlogName('TestBlogName'+timestamp);blogService.updateBlog(blog);Blog updatedBlog = blogService.getBlogById(2);Assert.assertEquals(blog.getBlogName(), updatedBlog.getBlogName());}@Testpublic void testDeleteBlog() {Blog blog = blogService.getBlogById(4);blogService.deleteBlog(blog.getBlogId());Blog deletedBlog = blogService.getBlogById(4);Assert.assertNull(deletedBlog);}
}

參考: MyBatis教程:第1部分–來自JCG合作伙伴 Siva Reddy的“ CRUD操作”,位于“我的技術實驗”博客上。

翻譯自: https://www.javacodegeeks.com/2012/11/mybatis-tutorial-crud-operations-and-mapping-relationships-part-1.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/370602.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/370602.shtml
英文地址,請注明出處:http://en.pswp.cn/news/370602.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java開發人員的升級之路

第一部分&#xff1a;對于參加工作一年以內的同學。恭喜你&#xff0c;這個時候&#xff0c;你已經擁有了一份Java的工作。這個階段是你成長極快的階段&#xff0c;而且你可能會經常加班。但是加班不代表你就可以松懈了&#xff0c;永遠記得我說的那句話&#xff0c;從你入行那…

docker 數據庫 mysql_在Docker中體驗數據庫之MySql

在上一篇在Docker中體驗數據庫之Mongodb之后&#xff0c;這次記錄一下在docker中安裝mysql。過程要比Mongodb麻煩一點……參考網址&#xff1a;https://dev.mysql.com/doc/refman/5.7/en/linux-installation-docker.htmlhttps://hub.docker.com/r/mysql/mysql-server/安裝過程如…

STL概覽——棧( stack )、隊列( queue )和優先級隊列( priority_queue)

棧&#xff08;stack&#xff09; stack是一種先進后出&#xff08;First In Last Out&#xff0c;FILO&#xff09;的數據結構&#xff0c;它只有一個口&#xff0c;平常在我們寫深度優先遍歷算法時&#xff0c;&#xff0c;就會用到棧&#xff0c;stack允許我們增加&#xff…

使用JMeter對異步HTTP / REST服務進行壓力/負載測試

盡管我一直在使用JMeter進行Web應用程序的壓力測試和負載測試好幾次&#xff0c;但我們還是花了一些時間才弄清楚如何使用該工具測試基于異步HTTP / REST的服務。 在我們這里&#xff0c;我是指一名程序員&#xff0c; Holger Staudacher &#xff0c;我很榮幸能與當前的一個項…

轉義字符的使用和功能python_Python中轉義符和格式符的混合使用,python,轉義字符,與,格式化...

# coding: utf-8 mon 麻辣小龍蝦 #周一麻辣小龍蝦 tue 宮保雞丁 #周二宮保雞丁 wed 水煮肉片 #周三水煮肉片 thu 果兒拌菜 #周四果兒拌菜 fri 小雞燉蘑菇 #小雞燉蘑菇 Cf_price 23 #麻辣小龍蝦價格 CK_price 12 #宮保雞丁價格 BM_price 32 #水煮肉片價格 MV_price 19 …

mock接口開發,excel(讀,寫,修改)

mock接口開發 首先需要安裝 Flask 模塊 &#xff1a;pip install flask 然后引用 from flask import request #想獲取到請求參數的話&#xff0c;就得用這個 lanxia flask.Flask(__name__) #把這個python文件當做一個web服務 lanxia.server(/login,[ post , get ] )#第…

web前端學習之ruby標記和rt/rp標記

ruby 標記定義ruby注釋&#xff08;中文注音或字符&#xff09;。ruby標記與rt標記一同使用。ruby標記由一個或多個字符&#xff08;需要一個解釋/發音&#xff09;和一個提供該信息的rt 標記組成&#xff0c;還包括可選的rp標記&#xff0c;定義當瀏覽器不支持ruby 標記時顯示…

mysql 5.7 udf http_mysql下mysql-udf-http效率測試小記

看到張宴的博客上關于"http/rest客戶端的文章"&#xff0c;怎樣安裝啥的直接都跳過&#xff0c;下面直接進入測試階段&#xff0c;測試環境&#xff1a;虛擬機復制代碼 代碼如下:[rootlocalhost ~]# uname -aLinux sunss 2.6.18-128.el5 #1 SMP Wed Jan 21 10:44:23 …

作為一名程序員,聊聊我們的現狀和未來

前言&#xff1a;互聯網這個高速發展的新興行業&#xff0c;注定是敢想敢干敢創新&#xff0c;耐勞耐操耐折騰年輕人的天下&#xff1f; 我們所在的互聯網行業&#xff0c;不斷地有新的公司冒出&#xff0c;有新的商業模式成形&#xff0c;有新的產品形態影響著大家的生活日常&…

適用于孩子,父母和祖父母的JBoss HornetQ –第1章

現在與HornetQ合作已經快4年了&#xff0c;我認為是時候分享我到目前為止所學知識的一部分了。 這篇文章的主要目的不是重寫官方文檔 &#xff0c;而是以簡單的方式闡明我們在PaddyPower中最常用的概念。 什么是HornetQ HornetQ是JMS實現。 JMS是一種面向消息的中間件API&am…

riot.js教程【四】Mixins、HTML內嵌表達式

前文回顧riot.js教程【三】訪問DOM元素、使用jquery、mount輸入參數、riotjs標簽的生命周期&#xff1b;riot.js教程【二】組件撰寫準則、預處理器、標簽樣式和裝配方法&#xff1b;riot.js教程【一】簡介&#xff1b; 共享Mixins 混合開發可以使你很好的復用代碼&#xff0c;如…

移動端判斷手機橫豎屏狀態

禁用用戶自動縮放功能&#xff1a; <meta name"viewport" content"widthdevice-width, initial-scale1.0, maximum-scale1.0, user-scalable0"> 判斷橫豎屏狀態有兩種方法&#xff1a;css判斷、js判斷 (一)、css判斷橫屏還是豎屏 1、寫在同一個css文…

ubuntu dhcp ping 不通 自己_??2、DHCP安裝和配置

DHCP動態主機設置協議&#xff0c;是一個局域網的網絡協議&#xff0c;使用UDP協議工作&#xff0c;可以快速分配IP地址&#xff0c;解決內網IP不足、手動配置IP造成IP沖突以及內網機器多手工配置比較麻煩的問題。1.把win2008和win2003設置同一網段&#xff0c;網絡適配器—配置…

python秒數變日期_將pandas日期列轉換為已用秒數

新答案 將文本轉換為Timedeltadf[Origin Time(Local)] pd.to_timedelta(df[Origin Time(Local)]) df[Seconds] df[Origin Time(Local)].dt.total_seconds() 舊答案 考慮數據幀dfdf pd.DataFrame(dict(Datepd.date_range(2017-03-01, 2017-03-02, freq2H))) Date 0 2017-03-0…

mysql用一個表更新另一個表的方法

Solution 1: 修改1列(navicate可行) update student s, city c set s.city_name c.name where s.city_code c.code; Solution 2: 修改多個列 update a, b set a.titleb.title, a.nameb.name where a.idb.id Solution 3: 采用子查詢(navicate不可行) update student s set…

選擇您的Java EE 6應用服務器

我被問到的第一個問題是&#xff1a;“我們應該使用哪個Java EE應用服務器&#xff1f;”。 隨著Java EE 6的日益普及&#xff0c;新的兼容應用程序服務器獲得了認證。 當前的官方兼容性和認證矩陣列出了針對完全配置文件&#xff0c;Web配置文件或兩者認證的12種不同產品。 如…

串的基本計算

#include<stdio.h> #include<stdlib.h> //typedef int Status; #define Max 20 #define OK 1 #define ERROR 0 #define OVERLOE -2 typedef struct//堆分配表示串 { char *ch; int length; }HString; // int CreatHString(HString &H)//構造字符串 { H.length …

HTML表格屬性及簡單實例

這里主要總結記錄下表格的一些屬性和簡單的樣式&#xff0c;方便以后不時之需。 1、<table> 用來定義HTML的表格&#xff0c;具有本地屬性 border 表示邊框&#xff0c;border屬性的值必須為1或空字符串("")。該屬性不會控制邊框的樣式&#xff0c;而是由CSS來…

怎么查看MySQL 源碼編譯了什么_Mysql 源碼編譯教程貼

題外話:這是一篇教程貼,不僅學的是mysql的編譯,還是一些編譯的知識.我也是一個菜鳥,寫一些感悟和心得,有什么問題可以批評指正,謝謝!如果只是為了安裝請移到我的另一篇安裝貼: Mysql安裝貼環境:OS: CentOS 6.6x64 minimysql: mysql-5.6.251. mysql 下載:http://dev.mysql.com/d…

linux mysql啟動_MySQL 安裝(二)

MySQL 安裝所有平臺的Mysql下載地址為&#xff1a;MySQL 下載 . 挑選你需要的 MySQL Community Server 版本及對應的平臺。Linux/UNIX上安裝MySQLLinux平臺上推薦使用RPM包來安裝MySQL&#xff0c;MySQL AB提供了以下RPM包的下載地址&#xff1a;MySQL - MySQL服務器。你需要該…