run swing application without DSN creation

2019-06-06 19:57发布

问题:

How to run the swing application without creating the DSN on the client

I am working on a swing application in which i have to give the mdb database to the client with password protection , i dont want the need to create DSN on client side

Is there any possible way to give the database path in the coding part rather than specifying the DSN name. because DSN creation is a complicated task for client.

回答1:

USE below code to create your connection:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\\as\\sampleDB.mdb");

This might help You.