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; ......
语法:
select * from table_name where column_name regexp '正则表达式'
或区分大小写
select * from table_name where column_name regexp binary '正则表达式'
支持的正则表达式符号:
. 任意字符
| 或,如:a|b|c
[] 范围,比如:[a-z],[0-9],[^0-9]不包 ......
今天搞了一下午,在电脑上搭建了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/ ......