对一些文件的上传下载
源代码在线查看: conn.java
软件大小: |
68 K |
上传用户: |
yhb71181491615 |
|
|
关键词: |
|
下载地址: |
免注册下载 普通下载
|
|
/**
* @(#)conn.java
*
*
* @author
* @version 1.00 2008/10/8
*访问数据库的javabean
*
*/
package download;
import java.sql.*;
public class conn {
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Program Files/Apache Group/Tomcat 4.1/webapps/download/download.mdb";
Connection connect=null;
ResultSet rs=null;
public conn() {
try{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e){
System.err.println(e.getMessage());
}
}
public ResultSet executeQuery(String sql){
try{
connect=DriverManager.getConnection(sConnStr);
Statement stmt=connect.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println(ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql){
int result=0;
try{
connect=DriverManager.getConnection(sConnStr);
Statement stmt=connect.createStatement();
result=stmt.executeUpdate(sql);
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
return result;
}
}