五jsp连接Access数据库
<%@page import=javasql*
import =javautil*
import =javaio*
import=javatext*
contentType=text/html; charset=gb
buffer=kb
%><%! int allim_count;
String odbcQuery;
Connection odbcconn;
Statement odbcstmt;
ResultSet odbcrs;
String usernametitlecontentworkemailurltimedate;
String datetime;
%>
<%
try{
ClassforName(sunjdbcodbcJdbcOdbcDriver);
}catch (ClassNotFoundException e)
{ outprint (驱动程序不存在);
}
try{
odbcconn = DriverManagergetConnection(jdbc:odbc:db);
odbcstmt = odbcconncreateStatement();
odbcQuery=Select * From book where datetime> Order By datetime DESC;
odbcrs=odbcstmtexecuteQuery(odbcQuery);
int i=;
while (i<) odbcrsnext();
while (odbcrsnext())
{
//*/////////////////////////显示数据库的内容用于调试程序是用//
int ii;
try{
try{
for (ii=;;ii++)
outprint (<br>Cloumn +ii+ is: +odbcrsgetString(ii));
}catch (NullPointerException e) {
outprint (有空的指针);
}
}catch (SQLException e){
}
}
odbcrsclose();
odbcstmtclose();
odbcconnclose();
}catch (SQLException e)
{ outprint (e);
}
%>
[] [] []