JSP数据库问题
<%@ page language= "java " import= "java.util.* " pageEncoding= "GB2312 "%>
<%@ page language= "java " import= "java.sql.* " %>
<jsp:directive.page import= "sun.jdbc.odbc.JdbcOdbc "/>
<jsp:directive.page import= "sun.jdbc.odbc.JdbcOdbcDriver "/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'Register.jsp ' starting page </title>
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<!--
<link rel= "stylesheet " type= "text/css " href= "styles.css ">
-->
</head>
<body>
<%
Connection con=null;
try{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
con=DriverManager.getConnection( "jdbc:odbc:ssia ", "sa ", " ");
String userName=request.getParameter( "userName ");
String Password=request.getParameter( "password ");
String Email=request.getParameter( "Email ");
String Address=request.getParameter( "address ");
String Phone=request.getParameter( "phone ");
Statement stat=con.createStatement();
stat.executeUpdate( "insert into [Use](UserName,PassWord,Email,Address,Phone)values( ' "+userName+ " ', ' "+Password+ " ', ' "+Email+ " ', ' "+Address+ " ', ' "+Phone+ " ') ");
out.println( "sucess ");
}
catch(
SQLException e)
{
out.println(e.getMessage());
}
catch(
ClassNotFoundException e)
{
out.println(e.getMessage());
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</body>
</html>
中文保存到数据库数据库中的内容就是问号,为什么会这样哪出问题了
------解决方案--------------------应该再对字符集进行一次转化.你试试我下面的方法.
public class FormUtility {
public sta