Wednesday, August 4, 2021

jdk11: Eclipse MariaDB Connector/J

 

Minimum Java Project JavaSe-1.8.

Adding MariaDB Connector/J 2.7.3 to Eclipse 2021-06:

  1. Download MariaDB Connector/J 2.7.3 (stable) from https://downloads.mariadb.org/connector-java/2.7.3/
  2. Put JAR file in [Workspace] -> [project_name] -> lib (create folder lib)
  3. Right click on Package Explorer -> [project_name] -> Properties
  4. Java Build Path -> Library -> Add External JARs, point it to [Workspace]/[project_name]/lib/mariadb-java-client-2.7.3.jar
  5. Click Apply and Close

Example code to access MariaDB database

package com.dedetok;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class TesCon {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        String muser = "my_user";
        String mpass = "my_password";
        String murl = "jdbc:mariadb://localhost:3306/my_database_name";
        Class.forName("org.mariadb.jdbc.Driver");
        Connection connection = DriverManager.getConnection(murl, muser, mpass);
        System.out.println("ok");
    }
}

Sunday, July 18, 2021

Android Studio: moving project from windows to Debian 10

Backup:

  1. all files in
    [Workspace] -> [app_name]
    backup jks and iml file
  2. Folder
    [Workspace] -> [app_name] -> [app]
    Exclude folder release and build

DO NOT BACKUP: Hiden folder (.gradle, .idea), gradle

Restore all folder structure into your new Workspace folder in new OS

Before you open your project in new OS, adjust your files depend on your your SDK, SDK version and Buildtool version, edit file

[workspace] -> [app_name]
local.properties
    sdk.dir=/home/[username]/Android/Sdk

[workspace] -> [app_name] -> [app]
build.gradle
    compileSdkVersion 31
    buildToolsVersion "31.0.0"
    ...
        targetSdkVersion 31

You can safely open your project, Android Studio will make same adjustment, download some necessary library and reconfigure your project.

Tested on

  • Debian Buster
  • Android Studio 4.2.x
  • moving project from windows to Debian

Thursday, July 15, 2021

Debian Buster (Debian 10): install mysql workbench

 

Download mysql workbench from https://downloads.mysql.com/archives/workbench/

I use mysql-workbench-community version 8.0.19 for ubuntu 18.04 i.e. mysql-workbench-community_8.0.19-1ubuntu18.04_amd64

Install libtinfo5

# apt-get install  libtinfo5

Install mysql workbench using dpkg

# dpkg -i mysql-workbench-community_8.0.19-1ubuntu18.04_amd64

NOTE:

  • only mysql workbench community for Ubuntu 18.04 will work on Debian Buster (10)

Monday, July 5, 2021

Debian Buster: LAMP + PhpMyadmin

 

LAMP: Linux Apache2 MariaDB PHP + PhpMyyadmin

Install mariadb

# apt-get install mariadb-server  mariadb-client  

Set mysql root password

# mysqladmin -u root password [yourpassword]

Install Apache2 and PHP

# apt-get install apache2 php libapache2-mod-php php-gd php-mysql

Disable autostart

# systemctl disable mariadb
# systemctl disable apache2

install phpmyadmin

  1. Install depedency php-twig (> 2.9) from backport
    # apt-get install -t buster-backports php-twig
  2. Install phpmydmin
    # apt-get install phpmyadmin php-bz2 php-curl php-tcpdf php-zip
Using browser open http://localhost/phpmyadmin/index.php

Debian Buster: install all in one hp ink tank 315

 

Detect hp ink tank 315 detected by system

# dmesg
...
[   66.017856] usb 3-2: new high-speed USB device number 2 using xhci_hcd
[   66.170313] usb 3-2: New USB device found, idVendor=03f0, idProduct=1053, bcdDevice= 1.00
[   66.170319] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   66.170322] usb 3-2: Product: Ink Tank 310 series
[   66.170324] usb 3-2: Manufacturer: HP
[   66.170326] usb 3-2: SerialNumber: CN83B2G1YK06PH
[   66.198225] usblp 3-2:1.1: usblp0: USB Bidirectional printer dev 2 if 1 alt 0 proto 2 vid 0x03F0 pid 0x1053
[   66.198300] usbcore: registered new interface driver usblp

Install CUPS and hplip

# apt-get install system-config-printer hplip cups hplip-ppds  

If CUPS error

# tail /var/log/cups/error_log
X [09/Jun/2021:13:20:46 +0700] No valid Listen or Port lines were found in the configuration file.

Edit /etc/cups/cupsd.conf

# vi /etc/cups/cupsd.conf
Listen 127.0.0.1:631

Configure printer via Browser http://localhost:631/

  1. Administration -> Add Printer
  2. HP Ink Tank 310 series USB CN83B2G1YK06PH HPLIP (HP Ink Tank 310 series), Next
  3. Continue
  4. Model: HP Ink Tank 310 Series hpijs, 318.12 (en), Add Printer
  5. Filled User Name with root and its password, Ok

Install XSane for scanner

# apt-get install xsane sane-utils

Detect hp ink tank 315 scanner

# lsusb
Bus 004 Device 002: ID 03f0:1053 HP, Inc
# sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x03f0 [HP], product=0x1053 [Ink Tank 310 series]) at libusb:004:002
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.

Try your scanner

# scanimage -L
device `hpaio:/usb/Ink_Tank_310_series?serial=CN83B2G1YK06PH' is a Hewlett-Packard Ink_Tank_310_series all-in-one

or

$ scanimage > image.pnm

To install driver print to pdf

# apt-get install printer-driver-cups-pdf