General Programming Tips

This page contains various programming tips that I took the time to document - which means that I probably had a hard time finding this information when I needed to know it.

If you found this page, hopefully you find something useful.

Connecting Java to a MSAccess Database through JDBC

Many guides on the web instruct you to set up a System DSN or JDBC connection to connect java to to MSAccess on a windows machine. That is completely unnecessary. You simply need to use this for your JDBC Driver:

sun.jdbc.odbc.JdbcOdbcDriver

And then use a URL like this to connect to your database:

jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\Path\\to\\Your\\database.mdb

I can't explan any of the nutty syntax, but I know that this works.

 

"Error 3014 - Can't Open Any More Tables." when trying to get data from an Access Database.

To prevent this error, make sure that you are closing everything as soon as you are done with it. ResultSets, Prepared Statements and connections. This is usually caused by not closing your Prepared Statements after you finish a query.

 

Building self contained Java Apps with Ant:

The following is an ant build script that will build a jar file that not only contains your source code - but also the contents of any jar files that you rely on. Simply download the file, make a few simple changes to line up with your source tree, and you are all set.

build.xml