JSP inserts the MySQL database after the garbled solution method

Source: Internet
Author: User
js|mysql| Insert | solve | data | database

The JSP page is guaranteed to be GBK code with the following 3 sentences
<%@ page session= "true"%>
<%@ page contenttype= "TEXT/HTML;CHARSET=GBK"%>
<% @page pageencoding= "GBK"%>
<%request.setcharacterencoding ("GBK");%>

The database connection uses the following statement
String sConnStr = "jdbc:mysql://localhost:3306/test?user=michael&password=123456&useunicode=true& CHARACTERENCODING=GBK ";
and the contents of the My.ini in MySQL are as follows
Basedir=d:/mysql
#bind-address=127.0.0.1
Datadir=d:/mysql-data/data
Default_character_set=gbk
#language =d:/mysql/share/your Language Directory
#slow Query log#=
#tmpdir #=
#port =3306
#set-variable=key_buffer=16m
[Winmysqladmin]
Server=d:/mysql/bin/mysqld-nt.exe
User=michael
Password=123
[Client]
Default_character_set=gbk

The parameters passed between the Read JSP pages appear normal on the page
After inserting data under the DOS command line, the display is normal

One of the INSERT statements is as follows:

<jsp:usebean id= "Reg" scope= "page" class= "Test.chatreg"/>
String strsql= "INSERT into Chatreg (username, password, email, homepage)
VALUES (' + Regname + "', '" + Regpassword + "', '" + Regemail + "', '" + Reg Homepage + "')";
Reg.executequery (strSQL);



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.