// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class AccessTest {
	private static void test(Connection con) throws SQLException {
		System.out.println(con.getMetaData().getDatabaseProductName() + " " + con.getMetaData().getDatabaseProductVersion() + " / " +
                           con.getMetaData().getDriverName() + " " + con.getMetaData().getDriverVersion());
		try(Statement stmt = con.createStatement()) {
			try(ResultSet rs = stmt.executeQuery("SELECT f1,f2 FROM t1")) {
				while(rs.next()) {
					System.out.printf("%d %s\n",  rs.getInt(1), rs.getString(2));
				}
			}
		}
	}
	private static void test(String conurl) throws SQLException {
		try(Connection con = DriverManager.getConnection(conurl)) {
			test(con);
		}
	}
	public static void main(String[] args) throws SQLException {
		test("jdbc:ucanaccess://D:/Databases/Access/Test.accdb");
	}
}
