连接mysql的javabean实例+简单分页
<%@ page contentType="text/html;charset=GBK" language="java" import="java.sql.*,java.util.*"%>
<html>
<head>
<title>连接mysql的javabean实例+简单分页</title>
<link href="../CSS.css" rel="stylesheet" type="text/css">
</head>
<body>
<jsp:useBean id="mypage" class="ckstudio.db.mysqlconn" scope="page"/>
<table width="1024"><tr>
<td>rs.getString(user_id)</td>
<td>rs.getString(user_name)</td>
<td>rs.getString(user_mail)</td>
<td>rs.getString(user_adds)</td>
</tr>
<br>
<tr>
<td style="hight:8px:width:%25;background-color:red;">
<td style="hight:8px:width:%25;background-color:red;">
<td style="hight:8px:width:%25;background-color:red;">
<td style="hight:8px:width:%25;background-color:red;">
</tr>
<%!
int Cint(String cint)
{
try {
int n;
n= Integer.parseInt(cint);
return n;
}
catch (NumberFormatException e) {
return 0;
}
}
%>
<%
int PageSize=5; //设置每页显示的记录条数
int ShowPage=1; //设置想要显示的页数
int RowCount = 0; //ResultSet的记录数目 初始值
int PageCount = 0; //ResultSet分页后的总页数 初始值
int duoyu=0; //设置分页最后一页的记录数 初始值
//以上是对这些数据的初始化 pagesize可自行设置
String sql="select * from member order by user_id desc";
ResultSet rs=mypage.executeQuery(sql);
//建立ResultSet(结果集)对象,并执行SQL语句
%>
<%if(rs.next())
{
rs.last(); //将指标移至最后一笔记录
RowCount=rs.getRow();
duoyu=RowCount % PageSize;
&nbs
相关文档:
1. 安装mysql的时候选择字符集utf8
2. 安装结束后修改my.ini,有两个地方要修改,
[mysql] default-character-set=gbk
# The default character set that will be used when a new schema or table is
# created and no character set ......
<p>04级新生名单</p>
<table border="1" width="80%" cellpadding="0">
<tr>
<td width="10%" align="center">Id</td>
<td width="20%" align="center">Name</td>
<td width="10%" align="center">Age</td>
<td width="10%" align="cent ......
系统环境:rhel5 (最小化安装,只安装vi工具) 内核:2.6.18-8.el5 1、 下载编译安装 #cd /usr/local/src/tarbag #wget http://mysql.byungsoo.net/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz //下载5.1.38 #tar xzvf mysql-5.1.38.tar.gz -C ../software/ #cd ../software/mysql-5.1.38 #./configure --prefix=/usr ......
注: 从MySQL从服务器的版本不能小于主服务器的版本 实验环境 Master Mysql服务器版本5.1.36,IP:192.168.128.130 Slave Mysql服务器版本5.1.36,IP:192.168.128.132 一. MySQL主服务器配置 1.建立授权用户 用法:grant replication slave on *.* to ‘用户名’@'主机’ identified by ‘密码’; mysql>grant replicatio ......