Tuesday 16 February 2010

MySql with Java in Ubuntu

I had some problems connecting to a MySql database from a Java application in Ubuntu. This a short description on what is needed. This assumes you have MySql and some database set already.

First, you need to install the package:
sudo aptitude install libmysql-java
Then you need to make sure that the classpath is correct:
CLASSPATH=$CLASSPATH:/usr/share/java/
export CLASSPATH
This is a good point to logout/login...

The code to connect to the database looks something like

No comments:

Post a Comment