向mysql中插入中文出错
在jsp中向mysql中插入中文数据时提示错误:java.sql.SQLException: Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'Stu_name' at row 1
以下是我的代码,希望大侠帮忙指出原因,谢谢。
HTML code:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<%!
String tbl="";
%>
<%
Connection con;
Statement stmt;
ResultSet rs;
try
{
Class.forName("com.mysql.jdbc.Driver");
String dburl="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8";
con=DriverManager.getConnection(dburl,"root","sa" );
stmt=con.createStatement();
int i=stmt.executeUpdate("insert into t_student(id,stu_name,stuno) values (3,'张三','88')");
}
catch(Exception e)
{
}
%>
</body>
</html>
进入My
相关问答:
我是用mysql自带的C API
if(mysql_real_connect(&mysql,"125.0.0.108","root","root","home",3306,NULL,0))
{
AfxMessageBox("数据库连接失败") ......
请高手指点,我对一张表查询后再更新,查询是子查询,报错:
You can't specify target table 'a_table' for update in from clause
完整SQL语句是
UPDATE a_table SET STATUS=0 WHERE ID=(SELECT MIN(ID) from a_tab ......
请问下哪位仁兄有比较好的备份方案,用什么工具或者用什么方式,小弟借鉴下
直接用MYSQLDUMP备份
OR
用SQLYOG之类的图形化管理工具备份
直接用mysql自带的 mysqldump 就可以了。
http://dev.mysql.com/doc/re ......