jsp连接mysql对数据库进行操作乱码的解决
如果jsp插入mysql数据库出现乱码,mysql数据库安装时编码设为utf8,在执行插入语句的前面(紧挨着执行语句)添加转码语句:String na="";
try{
na=rowSet.getString(k);
byte bb[]=na.getBytes("iso-8859-1");
na=new String(bb);
}catch(UnsupportedEncodingException ex){
throw new RuntimeException("unsupported encoding type.");
}
如果jsp从mysql数据库中读出来的中文为乱码,则在显示操作结果的语句前面添加转码语句:String na="";
try{
na=rowSet.getString(k);
byte bb[]=na.getBytes("iso-8859-1");
na=new String(bb);
&
相关文档:
//运行图:
//连接字符串
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
Class.forName(driverName).newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
//每页显示记录数
int PageSize ......
上一篇分页文章,是用于mysql,稍微修改下,用于Sqlserver2005/2008,没有异常处理。没有考虑性能等。
现将代码贴出,以供初学者参考:
注:邀月使用环境Eclipse 3.4.2+Tomcat 6.18+Sqlserver2005 sp3调试成功。
页面pagelistDemo.jsp内容:
Code
<%@ page language="java" contentType="text/html; ......
使用mysql中的with rollup可以得到每个分组的汇总级别的数据:
表如下:
CREATE TABLE `test3` (
`id` int(5) unsigned NOT NULL AUTO_INCREMENT,
`name1` varchar(10) DEFAULT NULL,
`name2` varchar(10) DEFAULT NULL,
`cnt` int(2) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGI ......
今天搞了一下午,在电脑上搭建了APM平台
系统:Windows7 Professional EN
Apache2.2.9:http://archive.apache.org/dist/httpd/binaries/win32/apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi
PHP5.3.1:http://windows.php.net/downloads/releases/php-5.3.1-Win32-VC6-x86.zip
MySQL5.1.42:http://ftp.iij.ad.jp/pub/db/ ......
jsp的内置对象、功能以及主要方法
Jsp内置对象 功能 主要方法
out 向客户端输出数据 print() println() flush() clear() isAutoFlush() getBufferSize() close() …………
request 向客户端请求数据 getAttributeNames() getCookies() getParameter() getParameterValues() ......