如何使用Java通过LAN连接到Access数据库?

时间:2022-09-27 13:54:16

Do you know of any good guides on how to access an Access database using Java?

您是否知道如何使用Java访问Access数据库?

I know the basics and basic SQL, but I'm thinking more about access control.

我知道基础知识和基本SQL,但我正在考虑更多关于访问控制的知识。

4 个解决方案

#1


private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}";

    // Initialize the JdbcOdbc Bridge Driver
    static {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(ClassNotFoundException e) {
            System.err.println("JdbcOdbc Bridge Driver not found!");
        }
    }

    /** Creates a Connection to a Access Database */
    public static Connection getAccessDBConnection(String filename) throws SQLException {
        filename = filename.replace('', '/').trim();
        String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix;
        return DriverManager.getConnection(databaseURL, "", "");
    }  

Some useful links:

一些有用的链接:

#2


If you mean using relational databases in Java, you'll need to know JDBC.

如果您的意思是在Java中使用关系数据库,则需要了解JDBC。

You won't be able to do much with security using JDBC. You'll have to build it into the application using something like JAAS or Spring Security.

使用JDBC无法在安全性方面做很多事情。您必须使用JAAS或Spring Security之类的东西将其构建到应用程序中。

#3


You can share a database over a shared drive on LAN n then add it to System DSN of other PCs and you can share access database over LAN .. Worked for me like that

您可以通过LAN上的共享驱动器共享数据库,然后将其添加到其他PC的系统DSN,您可以通过LAN共享访问数据库..为我工作就像那样

I know string is old but maybe useful for someone like me i was frustrated finding a proper and easy way for sharing

我知道字符串很旧但对我这样的人有用我觉得很难找到一个合适而简单的分享方式

#4


JDBC is the way to go. Google for "JDBC tutorial" + mysql, you will get all you need.

JDBC是要走的路。谷歌的“JDBC教程”+ mysql,你将得到你所需要的一切。

#1


private static final String accessDBURLPrefix = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    private static final String accessDBURLSuffix = ";DriverID=22;READONLY=false}";

    // Initialize the JdbcOdbc Bridge Driver
    static {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch(ClassNotFoundException e) {
            System.err.println("JdbcOdbc Bridge Driver not found!");
        }
    }

    /** Creates a Connection to a Access Database */
    public static Connection getAccessDBConnection(String filename) throws SQLException {
        filename = filename.replace('', '/').trim();
        String databaseURL = accessDBURLPrefix + filename + accessDBURLSuffix;
        return DriverManager.getConnection(databaseURL, "", "");
    }  

Some useful links:

一些有用的链接:

#2


If you mean using relational databases in Java, you'll need to know JDBC.

如果您的意思是在Java中使用关系数据库,则需要了解JDBC。

You won't be able to do much with security using JDBC. You'll have to build it into the application using something like JAAS or Spring Security.

使用JDBC无法在安全性方面做很多事情。您必须使用JAAS或Spring Security之类的东西将其构建到应用程序中。

#3


You can share a database over a shared drive on LAN n then add it to System DSN of other PCs and you can share access database over LAN .. Worked for me like that

您可以通过LAN上的共享驱动器共享数据库,然后将其添加到其他PC的系统DSN,您可以通过LAN共享访问数据库..为我工作就像那样

I know string is old but maybe useful for someone like me i was frustrated finding a proper and easy way for sharing

我知道字符串很旧但对我这样的人有用我觉得很难找到一个合适而简单的分享方式

#4


JDBC is the way to go. Google for "JDBC tutorial" + mysql, you will get all you need.

JDBC是要走的路。谷歌的“JDBC教程”+ mysql,你将得到你所需要的一切。