HttpServletRequest request.getRealpath("");

解决方案 »

  1.   

    String odbcQuery;
    Connection odbcConn;
    Statement odbcStmt;
    ResultSet odbcRs; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    odbcConn=DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=F:\\Db_ColligateStatistic\\ColligateStatistic.mdb;","admin","");
    odbcStmt=odbcConn.createStatement();
      

  2.   

    select * from [Join] where NetName='sd'
      

  3.   

    将你的数据库customer.mdb放在你的主空目录下
    public Connect() {
    super();
    try {

    dbURL = "jdbc:odbc:customer";

                      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                       DriverManager.setLoginTimeout(10);
    conn = DriverManager.getConnection(dbURL);
    } catch (Exception e) {
    System.err.println(e);
    e.printStackTrace();
    }
    }
    public static java.sql.Connection getConnection() {
    if (conn!= null) {
    return (new Connect()).conn;
    }
    if (conn == null) {
    1="Sorry, configure file is wrong!";
    }
    return conn;
    }
      

  4.   

    谢谢 楼上的各位,我用了amadou(黑火柴)的问题解决了,为什么要加[ ]在表外面呢?要是其他的数据库,如mysql,oracle ,sqlserver2000等,他们要加吗??
      

  5.   

    SQL2000也要加的,因为JOIN是SQL是保留字,做为字段名或表名的时候要用[]来区分
      

  6.   

    ////////////////////////////////////////////////////////
    //////这样不加[]在表的外面也可以读到数据.///////////////ACCESS数据库+java
    ///////////////////////////////////////////////////////package football;
    import java.sql.*;
    import java.io.*;
    public class DbConnection {  Connection conn = null;
      Statement stmt = null;
      ResultSet rset = null;  private String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
      private String sConnStr = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=league.mdb";  public DbConnection() {
      }
      public void connectionOpen()
            {
              try {
                Class.forName(sDBDriver);
              }
              catch (java.lang.ClassNotFoundException e) {
                System.err.println(e.getMessage());
              }
            }    //executeQuery and executeUpdate            public ResultSet executeQuery(String query) throws SQLException{
                        conn = DriverManager.getConnection(sConnStr);
                        stmt = conn.createStatement();
                        rset = stmt.executeQuery(query);
                        return rset;
                }            public void executeUpdate(String query) throws SQLException{
                        stmt = conn.createStatement();
                        stmt.executeUpdate(query);
                        if(stmt != null) stmt.close();
                }            public void close() throws SQLException{
                        if(conn != null) conn.close();
                        if(rset != null) rset.close();
                        if(stmt != null) stmt.close();
                }            protected void finalize() throws Throwable{
                        close();
                }
    }