Struts2+Spring+Hibernate连接mysql中文乱码解决
1.struts.xml中设置
<constant name="struts.il8n.encoding" value="UTF-8"></constant>
2.jsp页面设置
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
3.数据库连接url
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
或
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=gbk
相关文档:
#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "123"
#define database "oa"
MYSQL *conn;
int main()
{
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i,ret;
FILE *fp;
MYSQL_FIELD *field;
......
[root@sql21 ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.1.26-rc-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database &nb ......
......
在数据库表中,对字段建立索引可以大大提高查询速度。假如我们创建了一个
mytable
表:
CREATE TABLE mytable(
ID INT NOT NULL,
username VARCHAR(16) NOT NULL
);
我们随机向里面插入了
10000
条记录,其中有一条:
5555, admin
。
在查找
username="admin"
的记录
SELECT * from mytable WH ......
备份MySQL数据库的命令
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
备份MySQL数据库为带删除表的格式
备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库。
mysqldump -–add-drop-table -uusername -ppassword databasename > bac ......