1、本地ORACLE服务名问题
2、我通过的代码:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<!--告诉编译器使用SQL包-->
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%
Connection con;
Statement stmt;
ResultSet rs;
String Color;
java.lang.String sql,pagesql,strPage;
java.sql.ResultSet page_rs;
int cu=1;
//定义分页用的变量
int intPageSize;
//一页显示的记录数
int intRowCount;
//记录总数
int intPageCount;
//总页数
int intPage;
//待显示页码
int i,j,k;
//设置一页显示的记录数
intPageSize = 20;
//取得待显示页码
/*------------------------------------------------------------------------------------*/
strPage = request.getParameter("page");
if(strPage==null){
//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
} else
{
//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
/*-----------------------------------------------------------------------------------*/
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc
dbc:jjgl";
con=DriverManager.getConnection(url, "jjgl", "jjgl");
stmt = con.createStatement();
/*-----------------------------------------------------------------------------------*/
pagesql = "Select count(*) a From jjgc_ydwcqk";
page_rs = stmt.executeQuery(pagesql);
page_rs.next();
intRowCount = page_rs.getInt("a");
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage>intPageCount)
{ intPage = intPageCount;
}
page_rs.close();
/*-----------------------------------------------------------------------------------*/
rs = stmt.executeQuery("Select * From jjgc_ydwcqk Order by xh Desc ");
//将记录指针定位到待显示页的第一条记录上
i = (intPage-1) * intPageSize;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>早会信息</title>
<STYLE type=text/css>
BODY { FONT-SIZE: 12px}
TD { FONT-SIZE: 12px}
.wh { COLOR: #fff00f;
FONT-SIZE: 12px;
TEXT-DECORATION: none}
.white { COLOR: #000066;
FONT-SIZE: 12px;
TEXT-DECORATION: none}
A.map:link { COLOR: #d00000;
FONT-SIZE: 12px;
TEXT-DECORATION: underline}
A.map:visited { COLOR: #d00000;
FONT-SIZE: 12px;
TEXT-DECORATION: underline}
A.map:hover { COLOR: #d00000;
FONT-SIZE: 12px;
TEXT-DECORATION: underline}
a:link { color: #99CC00;
font-size: 12px;
text-decoration: none }
a:visited { color: #99CC00;
font-size: 12px;
text-decoration: none }
A:hover { COLOR: #000066;
FONT-SIZE: 12px;
TEXT-DECORATION: underline}
A.wt:link { COLOR: #FFFFFF;
FONT-SIZE: 12px;
TEXT-DECORATION: none}
A.wt:visited { COLOR: #FFFFFF;
FONT-SIZE: 12px;
TEXT-DECORATION: none}
A.wt:hover { COLOR: #FFFFFF;
FONT-SIZE: 12px;
TEXT-DECORATION: underline}
A.title:link { COLOR: #ffffff;
FONT-SIZE: 14px;
TEXT-DECORATION: none}
A.title:visited { COLOR: #ffffff;
FONT-SIZE: 14px;
TEXT-DECORATION: none}
A.title:hover { COLOR: #ffffff;
FONT-SIZE: 14px;
TEXT-DECORATION: none}
.f1 {BORDER-BOTTOM: 1px inset;
BORDER-LEFT: 1px inset;
BORDER-RIGHT: 1px inset;
BORDER-TOP: 1px inset;
height: 14pt;
font-size: 12px}
.f2 {BACKGROUND-COLOR: #cccccc;
BORDER-BOTTOM: 1px ridge;
BORDER-LEFT: #ffffff 1px ridge;
BORDER-RIGHT: 1px ridge;
BORDER-TOP: #ffffff 1px ridge;
height: 14pt;
font-size: 12px}
.f3 {BACKGROUND-COLOR: #cccccc;
BORDER-BOTTOM: 1px ridge;
BORDER-LEFT: #ffffff 1px ridge;
BORDER-RIGHT: 1px ridge;
BORDER-TOP: #ffffff 1px ridge;
height: 14pt;
font-size: 12px;
color: #CC0000}
.L { COLOR: #ffffff;
FONT-SIZE: 14px}
.L14 { LINE-HEIGHT: 140%}
.L15 { LINE-HEIGHT: 150%}
.L16 { LINE-HEIGHT: 160%}
.L17 { LINE-HEIGHT: 170%}
.dot { COLOR: #e00000;
FONT-SIZE: 7px;
LINE-HEIGHT: 14px}
.date { FONT-SIZE: 9px}
.title { COLOR: #000066;
FONT-SIZE:14px;
TEXT-DECORATION: none}
.cf { COLOR: #cc0000;
FONT-SIZE: 12px}
.L18 { LINE-HEIGHT: 180%}
.L19 { LINE-HEIGHT: 190%}
</STYLE>
</head>
<body>
<h3 align="center"><br>
基建工程管理
</h3>
<div align="center">
<center>
<form method="POST">
<table border="0" width="780" height="32" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
<tr>
<td width="66" height="32" bgcolor="#D9E6FF" align="center">查找:</td>
</center>
<td width="318" height="32" bgcolor="#D9E6FF" align="center" valign="middle">
<p align="left"><select size="1" name="D1" class="f1">
<option>sdsadasd</option>
</select> <input type="text" name="T1" size="16" class="f1"> <input type="submit" value="确定" name="B1" class="f2"></p>
</td>
<td width="278" height="32" bgcolor="#D9E6FF" align="center">
</td>
<td width="96" height="32" bgcolor="#D9E6FF" align="center">
<p align="right">增加新数据</p>
</td>
</tr>
<center>
</table>
</form>
</center>
</div>
<div align="center">
<center>
<table border="0" width="784" height="69" cellspacing="1" cellpadding="0" bgcolor="#FFFFFF">
<tr>
<td width="66" height="21" bgcolor="#F3F3F3" align="center">日期</td>
<td width="43" height="21" bgcolor="#F3F3F3" align="center">序号</td>
<td width="86" height="21" bgcolor="#F3F3F3" align="center">工程编号</td>
<td width="278" height="21" bgcolor="#F3F3F3" align="center">工程名称</td>
<td width="148" height="21" bgcolor="#F3F3F3" align="center">开工时间</td>
<td width="203" height="21" bgcolor="#F3F3F3" align="center">所需资金</td>
<td width="71" height="21" bgcolor="#F3F3F3" align="center">管理</td>
</tr>
<%
for(j=0;j<i;j++) rs.next();
//显示数据
i = 0;
while(i<intPageSize &&
rs.next())
{
String col1 = rs.getString("RQ");
String col2 = rs.getString(2);
String col3 = rs.getString(3);
String col4 = rs.getString(4);
String col5 = rs.getString(5);
String col6 = rs.getString(7);
if(col1==null||col1.length()==0)
{ col1="";
}
if(col2==null||col2.length()==0)
{ col2="";
}
if(col3==null||col3.length()==0)
{ col3="";
}
if(col4==null||col4.length()==0)
{ col4="";
}
if(col5==null||col5.length()==0)
{ col5="";
}
if(col6==null||col6.length()==0)
{ col6="";
}
cu++;
if (cu % 2 == 0) { Color="#FBF7FF";
}
else
{ Color="#fFFFfF";
}
%>
<tr>
<td width="66" height="21" bgcolor="<%=Color%>"><%=col1%> </td>
<td width="43" height="21" bgcolor="<%=Color%>"><%=col2%> </td>
<td width="86" height="21" bgcolor="<%=Color%>"><%=col3%> </td>
<td width="278" height="21" bgcolor="<%=Color%>"><%=col4%> </td>
<td width="148" height="21" bgcolor="<%=Color%>"><%=col5%> </td>
<td width="203" height="21" bgcolor="<%=Color%>"><%=col6%> </td>
<td width="71" height="21" bgcolor="<%=Color%>" align="center">详细</td>
</tr>
<%
i++;
}
%>
<tr>
<td colspan=7 align=center height="21" style="border-top-style: solid;
border-top-width: 1;
border-bottom-style: solid;
border-bottom-width: 1" bgcolor="#F3F3F3" width="846">
共有<%=intRowCount%>条记录&nbsp;&nbsp;&nbsp;
第<%=intPage%>页/ 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
&nbsp;&nbsp;
<a href="test.jsp?page=<%=intPage+1%>">下一页</a><% } %>
<%if(intPage>1){%>
&nbsp;
<a href="test.jsp?page=<%=intPage-1%>">上一页</a>
<% } %>
</td>
</tr>
<%
out.println("</table>");
%>
</center>
</table>
</body>
</html>
3、ODBC配置了没有
4、试一下JDBC