用jsp如何读取access数据库
时间:2007-12-23 来源:不详 作者:迈克DB
<%@page import="java.sql.*"
import ="java.util.*"
import ="java.io.*"
import="java.text.*"
contenttype="text/html; charset=gb2312"
buffer="20kb"
%><%! int all,i,m_count;
string odbcquery;
connection odbcconn;
statement odbcstmt;
resultset odbcrs;
string username,title,content,work,email,url,time,date;
string datetime;
%>
<%
try{
class.forname("sun.jdbc.odbc.jdbcodbcdriver");
}catch (classnotfoundexception e)
{ out.print ("驱动程序不存在");
} try{
odbcconn = drivermanager.getconnection("jdbc:odbc:db1");
odbcstmt = odbcconn.createstatement(); odbcquery="select * from book where datetime>2001-4-26 order by datetime desc"; dedecms.com
odbcrs=odbcstmt.executequery(odbcquery);
int i=0;
while (i<130) odbcrs.next();
while (odbcrs.next())
{
//*/////////////////////////显示的内容用于调试程序是用//
int ii;
try{
try{
for (ii=1;;ii )
out.print ("
cloumn " ii " is: " odbcrs.getstring(ii));
}catch (nullpointerexception e) {
out.print ("有空的指针");
}
}catch (sqlexception e){
}
}
odbcrs.close();
odbcstmt.close();
odbcconn.close();
}catch (sqlexception e)
{ out.print (e);
}
%>
文章评论
共有位Admini5网友发表了评论 查看完整内容