Reputation: 85
I have correctly added all the necessary JARS:
My database is 100MB. While using only Jacksess, the same query takes 4-5 seconds, while this one takes about 1-2 minutes. I made some research and found out that Ucanaccess mirors the whole database. How can I disable that? Or is it necessary?
I also tried with parameters (memory, singleConnection, skipIndexes) but it didn't change anything.
I have to use UcanAccess because I want to use JasperReports. And for this I need a valid connection.
My code:
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String connectionURL = "jdbc:ucanaccess://P:/myDatabase.accdb";
Connection conn = DriverManager.getConnection(connectionURL, "", "");
Statement stmt = conn.createStatement();
String query =
"Select * from REQ_ACQ_ACQUISITIONS";
ResultSet rs = stmt.executeQuery(query);
while ( rs.next() ) {
int numColumns = rs.getMetaData().getColumnCount();
for ( int i = 1 ; i <= numColumns ; i++ ) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue + " " + rs.getMetaData().getColumnName(i));
}
System.out.println("");
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Upvotes: 2
Views: 2500
Reputation: 1
For me, I had a similar issue but mostly because throughout my code, I never closed my connections after running queries.
Upvotes: 0
Reputation: 1710
Notice that this is not truly the "connection time" but the time of the very first connection in the whole JVM life. So it's a startup time, something like a database startup time. All the following connections will be istantaneous. There are several approches to drammatically reduce the time of the very first connection. The easiest one is to build a filter database that links, as external tables, the only tables you need for your reports.
Upvotes: 3