社区
Web 开发
帖子详情
好有趣的中文显示问题
bigbigbug
2001-07-24 04:34:21
当我使用jswdk时,从页面提交的中文不能正确的存储到数据库中,但数据库中的中文记录可以正确的显示到页面上;而当我使用resin时正好相反,从页面可正确的提交中文,但数据库中的中文记录却不能正确显示到页面上。这是怎么回事?是我的设置不正确?请各位大虾指教!
...全文
94
5
打赏
收藏
好有趣的中文显示问题
当我使用jswdk时,从页面提交的中文不能正确的存储到数据库中,但数据库中的中文记录可以正确的显示到页面上;而当我使用resin时正好相反,从页面可正确的提交中文,但数据库中的中文记录却不能正确显示到页面上。这是怎么回事?是我的设置不正确?请各位大虾指教!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
nicolas
2001-07-27
打赏
举报
回复
环境:jswdk+jdk1.3+access
1.将中文数据写入数据库
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="databean" scope="page" class="dbbean.dbbean"/>
String strName="",strSql="";
byte[] tmpbyte=null;
strName=strName.trim();
tmpbyte=strName.getBytes("ISO8859_1");
strName=new String(tmpbyte);
strSql="insert into user_info(name) values('"+strName+"')";
databean.executeInsert(strSql);
2.将中文数据提出可以直接显示在页面上。
3.bean代码:
/*
* @dbbean.java
* Author:yjx
* Date:2001-3-21
* version:1.0v
* Function:connect database,query table,update table by parameter
*/
package dbbean;
import java.sql.*;
import java.io.*;
public class dbbean{
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Connection conn=null;
ResultSet rs=null;
/*
* constructor:try to create a dababase driver
*/
public dbbean(){
try{
Class.forName(sDBDriver);
}catch(java.lang.ClassNotFoundException e){
System.err.println("dbbean(): "+e.getMessage());
}
}
public ResultSet executeQuery(String sqlStr){
rs=null;
try{
conn=DriverManager.getConnection("jdbc:odbc:wygl");
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sqlStr);
}catch(SQLException e){
System.err.println("executeQuery(): "+e.getMessage ());
}
return rs;
}
public int executeInsert(String sqlStr){
try{
conn=DriverManager.getConnection("jdbc:odbc:wygl");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sqlStr);
return 1;//成功
}catch(SQLException e){
System.err.println("executeInsert(): "+e.getMessage());
return 0;//失败
}
}
public int executeUpdate(String sqlStr){
try{
conn=DriverManager.getConnection("jdbc:odbc:wygl");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sqlStr);
return 1;//成功
}catch(SQLException e){
System.err.println("executeInsert(): "+e.getMessage());
return 0;//失败
}
}
public int executeDelete(String sqlStr){
try{
conn=DriverManager.getConnection("jdbc:odbc:wygl");
Statement stmt=conn.createStatement();
stmt.executeUpdate(sqlStr);
return 1;//成功
}catch(SQLException e){
System.err.println("executeDelete(): "+e.getMessage());
return 0;//失败
}
}
}
24680
2001-07-26
打赏
举报
回复
建个头文件。
bigbigbug
2001-07-25
打赏
举报
回复
to wyzegg(蛋):show me 那个函数啦,老大。
wyzegg
2001-07-24
打赏
举报
回复
需要转换,我们有个函数
dragonerfish
2001-07-24
打赏
举报
回复
可能是字符集设的不正确!!!
mysql 数字用什么表示什么意思_学习计划 mysql 整数类型后面的数字,是什么意思?...
Mysql中定义整数类型的数字,是指定这个字段的长度么?比如 INT(10) 10代表10个字节么?还是只能存储10为长度的数字内容?今天本来想学习下字符类型,一下子发现了这个,感觉好
有趣
。--那么,int(1)和tinyint(1) 他们表示什么意思?有什么区别呢?关于int类型和tinyint类型,我们知道,int类型占4个字节,tinyint占1个字节。int(1) 和 int(4)从本身...
文字环绕图片的布局效果
为什么80%的码农都做不了架构师?>>> ...
深入浅出java高级编程【2011-11-29】
急:如何通过ActiveX调用Websphere部署的EJB? 便携的J2EE应用 JBuilder9与WebLogic8.1的
问题
? 关于JSP
中文
的
问题
,请高手解答???????? [原创]Jcharts学习笔记 请教: jsp中关于注册页面的写法 消息队列中间件中对象池技术是否适合???? 谁有Ext2FS Anywhere? JDBC call SQLServer的存储过程
Linux centOS7
在硬盘上分出40GB的空间安装Linux的空间分配如下:所需目录磁盘容量文件系统分区格式BIOS启动2MB系统自订主分区/启动1GBXFS主分区/10GBXFSLVM方式/家5GBXFSLVM方式交换1GB交换LVM方式使用软碟通将下好的镜像,写入Ú盘中。使用ü盘进行安装。3.2.2选择安装模式与开机 - inst.gpt如果一切都顺利没
问题
的话,那么使用光碟映像档开机后,就会出现如下画面:图3...
[App]Microsoft Visual C++ 6.0 + SP6 英文版
Visual C++ provides a powerful and flexible development environment for creating Microsoft Windows-based and Microsoft .NET-based applications. It also enables developers to build Web applications,
Web 开发
81,094
社区成员
341,711
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章