jsp连接SQL数据库,在数据库显示的中文乱码问题
如题~我用的是SQL2005的数据库,网页用JSP+Servlet+javabean写,在Servlet获取了JSP表单数据在传入javabean中连接数据库
大致的代码如下,
Servlet:
String name = (String)request.getParameter("name");
String sex = (String)request.getParameter("sex");
String birthyear = (String)request.getParameter("birthyear");
String birthmonth = (String)request.getParameter("birthmonth");
String political = (String)request.getParameter("political");
String education = (String)request.getParameter("education");
String city = (String)request.getParameter("city");
String phone = (String)request.getParameter("phone");
String email = (String)request.getParameter("email");
response.setContentType("text/html; charset=ISO-8859-1 ");
PS:上面charset我曾经用过GB2312,UTF-8,在SQL中显示一样乱码
//request.setCharacterEncoding( "gb2312 ");
ResumeManage.CreatResume(userID, name, sex, birthyear, birthmonth, political, education, city, phone, email);
javabean的代码就应该不用贴出来了。。既然能写入数据库,连接方面应该没问题。。。
另外还想问个问题,在javabean写入数据库时,是把SQL语句保存到一个String里面,那么就是所有的数据都是String类型,写入到数据库时系统会自动帮你改成数据库对应的类型?(如int,bigint,boolean,datetime等等)