📄 dbmanager.java
字号:
package load;
import java.sql.*;
public class DBManager{
private String driver="sun.jdbc.odbc.JdbcOdbcDriver";
private String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Program Files/Apache Group/Tomcat 4.1/webapps/myjsp/soft.mdb";
private Connection conn=null;
private Statement stmt=null;
private ResultSet rs=null;
private String str="";
private String tt="";
public DBManager(){
try{
Class.forName(driver);
}catch(java.lang.ClassNotFoundException e){
e.printStackTrace();
}
}
public ResultSet executeQuery(String sql){
try{
conn=DriverManager.getConnection(url);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery(sql);
}catch(Exception e){
System.err.println(e.getMessage());
}
return rs;
}
public int executeUpdate(String sql){
int iRbt=-1;
try{
conn=DriverManager.getConnection(url);
stmt=conn.createStatement();
iRbt=stmt.executeUpdate(sql);
}catch(Exception e){
System.err.println(e.getMessage());
}
return iRbt;
}
public String showOnePage(ResultSet rs,int Page,int PageSize)
{
str="";
try{
rs.absolute((Page-1)*PageSize+1);
}catch(Exception e){
}
for(int i=1;i<=PageSize;i++)
{
str+=rsToGbook(rs);
try{
if(!rs.next())
break;
}catch(Exception e){
}
}
return str;
}
public String rsToGbook(ResultSet rs)
{
tt="";
/*
int tmpid=0;
int hits=0;
String hot="";
String showname="";
String date="";
String memo="";
try{
tmpid=;
hits=;
showname=;
date=;
memo=;
}catch(Exception e){
}
int i=hits/50;
if(i==0){
i=1;
}
for(int j=1;j<=i;j++){
hot=hot+"★";
}
try{
stmt.executeUpdate("update download set hot='"+hot+"' where id="+tmpid);
}catch(Exception e){
}
*/
try{
tt="<hr color=#ff0000 width='95%'>";
tt=tt+"<center><table border=1 width='95%'>";
tt=tt+"<tr><td bgcolor=#00FFFF width='15%'>软件名称:</td><td><a href=openfile.jsp?id="+rs.getInt("id")+" target=dispwin>"+rs.getString("showname")+"</a></td>";
tt=tt+"<td bgcolor=#00FFFF width=14%>星级评定:</td><td width='21%'><font color=#ff0000>"+rs.getString("hot")+"</font></td>";
tt=tt+"<tr><td bgcolor='#00FFFF' width='15%'>下载次数</td><td><font color='#ff0000'><B>"+rs.getInt("hits")+"</B></font></td>";
tt=tt+"<td bgcolor='#00FFFF'>加入时间</td><td>"+rs.getDate("date").toString()+"</td></tr>";
tt=tt+"<tr><td bgcolor=#00FFFF width='15%'>软件介绍</td>";
tt=tt+"<td colspan=3>"+rs.getString("softnote")+"</td></tr>";
tt=tt+"</table></center>";
}catch(Exception e){
}
return tt;
}
public String xtwh(ResultSet rs)
{
tt="";
int tmpid=0;
try{
tmpid=rs.getInt("id");
}catch(Exception e){
}
try{
tt="<hr color=#ff0000 width='95%'>";
tt+="<form name='form' action='oper.jsp' method=post>";
tt+="<center><table border=1 width='95%'>";
tt+="<tr><td align=center><input type=submit name=add value=增加></td>";
tt+="<td align=center><input type=submit name=cha"+tmpid+" value=修改></td>";
tt+="<td colspan=2 align=center><input type=submit name=del"+tmpid+" value=删除></td></tr>";
tt=tt+"<tr><td bgcolor=#00FFFF width='15%'>软件名称:</td><td><a href=openfile.jsp?id="+rs.getInt("id")+" target=dispwin>"+rs.getString("showname")+"</a></td>";
tt=tt+"<td bgcolor=#00FFFF width=14%>星级评定:</td><td width='21%'><font color=#ff0000>"+rs.getString("hot")+"</font></td>";
tt=tt+"<tr><td bgcolor='#00FFFF' width='15%'>下载次数</td><td><font color='#ff0000'><B>"+rs.getInt("hits")+"</B></font></td>";
tt=tt+"<td bgcolor='#00FFFF'>加入时间</td><td>"+rs.getDate("date").toString()+"</td></tr>";
tt=tt+"<tr><td bgcolor=#00FFFF width='15%'>软件介绍</td>";
String memo=rs.getString("softnote");
tt=tt+"<td colspan=3>"+memo+"</td></tr>";
tt=tt+"</table></center>";
tt+="</form>";
}catch(Exception e){
}
return tt;
}
public String xtwhShowOnePage(ResultSet rs,int Page,int PageSize)
{
str="";
try{
rs.absolute((Page-1)*PageSize+1);
}catch(Exception e){
}
for(int i=1;i<=PageSize;i++)
{
str+=xtwh(rs);
try{
if(!rs.next())
break;
}catch(Exception e){
}
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -