如何使用UCanAccess访问网络上共享文件夹中的数据库

时间:2018-07-19 13:29:38

标签: android-studio networking ucanaccess

我绝对无法访问数据库,我已经花费了数小时,而且没有办法。欢迎任何帮助。下面是连接类代码和清单。

退货始终相同:

  

I / System.out:net.ucanaccess.jdbc.UcanaccessSQLException:UCAExc ::: 0.0   给定的文件不存在:/192.168.15.4/Banco/DBase.accdb

public class ConnectionClass {

public static Connection conn = null;

public Connection CONN(){
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    String DRIVER = "net.ucanaccess.jdbc.UcanaccessDriver";
    String DbDsn = "jdbc:ucanaccess://";
    String DbServer = "//192.168.15.4";
    String DbPath = "/Banco";
    String DbName = "/DBase.accdb";

    String ConnUrl= DbDsn + DbServer + DbPath + DbName;

    try{

        String caminho_2 = DbServer+DbPath+DbName;
        System.out.println("Caminho - " + caminho_2);

        File teste = new File(caminho_2);
        if(teste.exists()) {
            System.out.println("Arquivo OK");
        }else{
            System.out.println("Não OK");
        }

        try {
            System.out.println("Verificação Driver");
            Class.forName(DRIVER);
        }
        catch(ClassNotFoundException cnfex) {

            System.out.println("Problem in loading or "
                    + "registering MS Access JDBC driver");
            cnfex.printStackTrace();
        }
        System.out.println("Classificando Driver");

        System.out.println("String de conexão - " + ConnUrl);

        conn = DriverManager.getConnection(ConnUrl);

        System.out.println("Conexão Estabelecida");

    }catch (SQLException cnfe){
        System.out.println(cnfe);
        System.out.println("Erro - 1");
    }catch (Exception se){
        System.out.println(se);
        System.out.println("Erro - 2");
    }
    return conn;
}

0 个答案:

没有答案