Friday, September 27, 2024

 ODBC / JDBC Connectivity with LibreOffice Base on Debian 12

Below are some hurdles I had to jump over to get ODBC and JDBC working when connecting to mySQL server on Debian 12:

Download ODBC Drivers directly from dev.mysql.com: https://dev.mysql.com/downloads/connector/odbc/ 

Make sure you choose "Linux - Generic" under "Select Operating System". 

  • copy the file libmyodbc8a.so to /usr/lib/x86_64-linux-gnu/odbc/ 
  • copy the file libmyodbc8w.so to /usr/lib/x86_64-linux-gnu/odbc/ 
*The name/versions of these files may change with updates.

 then, create file  /etc/odbcinst.ini ⇒ sudo nano /etc/odbcinst.ini

[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc9a.so 
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbc9w.so
FileUsage = 1
   
and create file /etc/odbc.ini sudo nano /etc/odbc.ini

[my-connector]
Description     = MySQL connection to  database
Driver          = MySQL (‡ see note below)
Database        = eik
Server          = localhost
User            = root
Password        = 
Port            = 3306
#Socket          = /opt/lampp/var/mysql/mysql.sock
Socket          = /run/mysqld/mysql.sock

echo "select 1" | isql -v my-connector  
  1. Duplicate above for separate databases you wish to connect to e.g.
[anotherdb]
  Description     = MySQL connection to  database
  Driver          = Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc9a.so 
  Database        = testdb
  Server          = localhost
  User            = root
  Password        = 
  Port            = 3306
  Socket          = /run/mysqld/mysql.sock
echo "select 1" | isql -v anotherdb
  1. Note the location of the mysqld may vary and the commented out string is for xampp
  2. You can find your running mysql daemon location with this command: sudo find / -type s
  3. Edit /etc/odbc.ini to include the correct path.
To connect to ODBC/JDBC in  LibreOffice Base:
  1. "Connect to an existing database": MySQL/MariaDB
  2. "Connect using ODBC (Open Database Connectivity"
  3. "Browse" (button in the next dialog should show the configured ODBC connections in /etc/odbc.ini).
  4. Select User Name: usually root
  5. Select Password required checkbox if password not blank.

If you get an error:

"Could not load the program library libodbc.so or it is corrupted. The ODBC data source selection is not available."

sudo apt-get install odbc-mdbtools

If you get an error:

"[unixODBC][Driver Manager]Data source name not found and no default driver specified at ./connectivity/source/drivers/odbc/OTools.cxx:357"

Look in the file /etc/odbcinst.ini and copy Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc9a.so to Driver = ‡ in /etc/odbc.ini

ODBC doesn't display Japanese characters, but JDBC does!

(ODBCでは日本語の文字は表示されませんが、JDBCでは表示されます)

JDBC connect

  1. sudo apt install default-jdk
  2. sudo apt install libmariadb-java
  3. Download : https://dev.mysql.com/downloads/connector/j/ for Debian Linux
  4. sudo dpkg -i mysql-connector-j_9.0.0-1debian12_all.deb
  • Open LibreOffice Start Center (not Base) and set the path /usr/share/java tools->options->advanced->class path
  • Add : mariadb-java-client.jar as a class 
  •  I moved /usr/share/java/mariadb-java-client.jar to ~/Documents/JDBC folder
  • Database Connection Wizard (in LibreOffice Base):

    1. "Connect to an existing database": MySQL/MariaDB
    2. "Connect using JDBC (Java Database Connectivity"
    3. Enter Database Name:
    4. Server: localhost
    5. Port: 3306
    6. You should see org.mariadb.jdbc.Driver in the Window:
      MySQL/MariaDB JDBC Driver Class

     

    Notes:

    Sunday, October 20, 2013

    Flash a WHR-G300N V2 Japanese router with US firmware

    Instructions below presume the router's address is 192.168.11.1 - I am no expert so follow this at your own risk! Be aware that by following these instructions  "Bricking", or rendering your router unusable, is possible!

     (A) Flash Router with Original Japanese Firmware. **

    Flashing the router with DD-WRT alternative OpenSource firmware did not work well for me, so I first restored the router to the original Japanese firmware: (note:: I couldn't get this to work with Ubuntu's tftp so followed this guide http://dd-wrt.com/wiki/index.php/WHR-G300N_V2 except I used Parted Magic rescue disk's tftp with command # tftp -l whrg301n-182 -p 192.168.11.1).

    **Note: Part (A) may not necessary if you haven't tried to install DD-WRT and have the original firmware installed.  It may not even be necessary if you have installed DD-WRT (I am not sure here, but to be sure I restored the original Japanese language firmware anyway).

     (B) To Change to US English Buffalo Firmware version:

    1. Boot computer with Linux rescue disk. I used Parted Magic.
    2. Download whr-g300nv2_fw182.zip from the Buffalo US site.
    3. Connect only your computer to the router via ethernet cable.
    4. Extract whrg300nv2-182 from zip file to a directory.
    5. Open browser (firefox) Note:: restart browser if you have been logged into router to clear normal login cache otherwise step (6) may not work. You will get a blank page saying ---- UNDER CONSTRUCTION ---
    6. Log in to http://192.168.11.1/cgi-bin/cgi?req=frm&frm=py-db/55debug.html 
    7. username: bufpy  
    8. password: otdpopy(addyourpasswordhere)
    9. In your browser click on telnetd link then the telnetd button [START] and from a terminal in your rescue disk telnet to the router:
      • #telnet 192.168.11.1 
      • #ubootenv set accept_open_rt_fmt=1 
      • #ubootenv set region=US (not sure if this is necessary)
    10. Log out of telnet.
      • #exit
    11. Unplug router, power cable and all ethernet cables. 
    12. Write down the number on the back of your router, which  will be an SSID number e.g. 106F4BCC5347.
    13. Open a terminal in the same directory as the unzipped US firmware file whrg300nv2-182 see step (4).
    14. In the terminal type:: 
      • # ifconfig eth0 192.168.11.2
      • # arp -s 192.168.11.1 10:6F:4B:CC:53:47 (note: not this actual number 10:6F:4B:CC:53:47 - it's made up see step (12) You must use your unique SSID).
      • # tftp -l whrg300nv2-182 -p 192.168.11.1 (you are now trying to upload the firmware file but you are not connected to the router yet: see next step!)
    15. Now quickly plug in the router power and ethernet cable that connects to your computer ( not in the blue wan port ) and tftp should now start uploading the firmware file to the router.
    16. Keep hitting the up arrow on your keyboard and Enter as you do this ( it may fail a few times ). (Note:: I couldn't get this to work with Ubuntu's tftp hence Parted Magic) .
    17. You should see a progress bar if successful. 
    18. The router should take several minutes to reset and when you log in again, you should see an English version of the firmware, once all has settled.  
    19. Note:: The only setting I couldn't recover was the Japanese ntp server (ntp1.jst.mfeed.ad.jp) so make a note of that address before doing this.

    REFERENCES:


     ODBC / JDBC Connectivity with LibreOffice Base on Debian 12

    Below are some hurdles I had to jump over to get ODBC and JDBC working when connecting to mySQL server on Debian 12: Download ODBC Driver...