Saturday, January 5, 2008

Accessing MySQL server using JDBC (Java DataBase Connectivity) from Open Office Org 2.2

First trial:
As I've done with other IDE like Eclipse or NetBeans, it was obvious for me to download from MySQL website the last release of the Java based driver compatible with my MySQL server version and then follow the steps for connecting my database server to Open Office, but once the connection test succesfully ran and actually established, Open Office crashed when I tried to browse the content of a table with not even a hint to indicate the source of the problem.
Second trial:
I was recommanded to use the following command:
apt-cache search jdbc | grep java


This command got me the name of the library that contains the JDBC driver for MySQL with several other « maybe » useful libraries. The next step was to install this library using:
sudo apt-install libmysql-java
Then restart your session.
Start Open Office Database.
Select Connect to an existing database and choose MySQL, click Next.


Choose Connecting using JDBC, click Next.


Fill the textfields, the database name should be one that already exist in your server, the server URL I used was localhost, and the port is 3306 (it's the default port assigned for MySQL server at installation, but it can be different ...). By default the Java class file used has already been specified, click Test Class.



The following window confirms that the driver has been successfully loaded.



This window asks for your authentification (username then password) and allows you to test the connection.



Execute a SQL script in MySQL 5.0 in Linux Ubuntu

To run a sql script file from MySQL command prompt: Change to the directory in which the script file is located in your file system.Run MySQL command prompt
mysql -u username
-p.
Go to the database in which you want the script file to be run with this command: use , it supposes that you already have a database created in your server, I used a database called 'budget'.
Then use the SOURCE command as this:
SOURCE scriptname.sql;