必须通过ODBC-JDBC的桥!
没有别的办法?

解决方案 »

  1.   

    很简单,来自数据驿站 http://www.dbstep.com
    package DBstep;import java.sql.*;
    import java.lang.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author unascribed
     * @version 1.0
     */public class iDBManager2000 {
      public javax.servlet.ServletContext Application;
      public String ClassString=null;
      public String ConnectionString=null;
      public String UserName=null;
      public String PassWord=null;  public Connection Conn;
      public Statement Stmt;
      public iDBManager2000(javax.servlet.ServletContext mApplication) {    //For Access Driver
        Application=mApplication;
        ClassString="sun.jdbc.odbc.JdbcOdbcDriver";
        ConnectionString=("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+Application.getRealPath("DBstep.mdb")+";ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=128;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;").replace('\\','/');    //For SQLServer Driver
        //ClassString="com.microsoft.jdbc.sqlserver.SQLServerDriver";
        //ConnectionString="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=iweboffice;User=iweboffice;Password=iweboffice";
        //UserName=...;
        //PassWord=...;    //For Oracle Driver
        //ClassString="oracle.jdbc.driver.OracleDriver";
        //ConnectionString="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为你的数据库的SID
        //UserName=...;
        //PassWord=...;    //For MySQL Driver
        //ClassString="org.gjt.mm.mysql.Driver";
        //ConnectionString="jdbc:mysql://localhost/softforum?user=...&password=...&useUnicode=true&characterEncoding=8859_1";
        //ClassString="com.mysql.jdbc.Driver";
        //ConnectionString="jdbc:mysql://localhost/dbstep?user=root&password=&useUnicode=true&characterEncoding=gb2312";    //For Sybase Driver
        //ClassString="com.sybase.jdbc.SybDriver";
        //ConnectionString="jdbc:sybase:Tds:localhost:5007/tsdata"; //tsdata为你的数据库名
        //Properties sysProps = System.getProperties();
        //SysProps.put("user","userid");
        //SysProps.put("password","user_password");
        //If using Sybase then DriverManager.getConnection(ConnectionString,sysProps);  }  public boolean OpenConnection()
      {
       boolean mResult=true;
       try
       {
         Class.forName(ClassString);
         if ((UserName==null) && (PassWord==null))
         {
           Conn= DriverManager.getConnection(ConnectionString);
         }
         else
         {
           Conn= DriverManager.getConnection(ConnectionString,UserName,PassWord);
         }     Stmt=Conn.createStatement();
         mResult=true;
       }
       catch(Exception e)
       {
         System.out.println(e.toString());
         mResult=false;
       }
       return (mResult);
      }  //关闭数据库连接
      public void CloseConnection()
      {
       try
       {
         Stmt.close();
         Conn.close();
       }
       catch(Exception e)
       {
         System.out.println(e.toString());
       }
      }
      public String GetDateTime()
      {
       Calendar cal  = Calendar.getInstance();
       SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       String mDateTime=formatter.format(cal.getTime());
       return (mDateTime);
      }  public ResultSet ExecuteQuery(String SqlString)
      {
        ResultSet result=null;
        try
        {
          result=Stmt.executeQuery(SqlString);
        }
        catch(Exception e)
        {
          System.out.println(e.toString());
        }
        return (result);
      }  public int ExecuteUpdate(String SqlString)
      {
        int result=0;
        try
        {
          result=Stmt.executeUpdate(SqlString);
        }
        catch(Exception e)
        {
          System.out.println(e.toString());
        }
        return (result);
      }}
      

  2.   

    用这个接口:javax.sql 
    Interface DataSource
      

  3.   

    好了~!access的JDBC驱动程序,到http://industry.java.sun.com/products/jdbc/drivers这个网站上查找并下在access的jdbc驱动程序。如提!