SQLite, JDBC & Solaris (SPARC)

SQLite is one of simple and powerful Database engine. Recently I was doing some testing and performance check, using a Java Code and Xerial SQLite-JDBC library. As a part of this, I wanted to run this test on Solaris 11 (SPARCv9) environment.  Thats when I noticed two things:

1) Xerial SQLite JDBC Library not having the Native Library for Solaris SPARC  Architecture. JDBC Native Library is used to bridge the Java JDBC call to SQLite C Call. It is simple JNI Wrapper library.

2) My Solaris Base machine as well as the spare VM does not have the GNU Developer Tools.

I am not regularly playing with Solaris Package System and  not sure about the impact of installing the new set of libraries and tools in the base machine. So decided use the spare Oracle VM and not to touch the base machine.

Installing GNU Developer Tools in Solaris 11 SPARC:

Starts with GCC and supporting library installation. But this

# pkg install gcc or gcc-4X

Failed with message “This version is excluded by installed incorporation blah blah”. All my other tricks to install gcc also failed. But I was able to install vim  using:

# pkg install vim

This event pushed me to read about the Package Incorporation in Oracle documents:
“Every package that is part of the Oracle Solaris 11 OS has a dependency on an incorporation package. Incorporation packages constrain the versions of the their incorporated packages to help keep the system in a supportable state across updates. Some incorporated packages might be safe to downgrade or upgrade at a version different from the version specified by the incorporation”.

You have an option to relax some (version) constraints to allow the installation any package. GNU Developer tools might have some inter-dependency, I don’t want to go in this direction and decide to search list of incorporated packages. Below command listed the packages:

# pkg contents -m ips-incorporation

And following line in the output, give me a clue.

depend fmri=group/feature/developer-gnu@0.XXX type=incorporate

developer-gnu is a group package and it can install all the tools with correct dependency, in one go.

# pkg install developer-gnu

All GNU tools are installed with-out any issue. Ah, next..

Compile SQLite-JDBC on SPARC:

Developers didn’t compile it for the SPARC platform. But they put a place holder in the Makefile. This reduced my job to few fine tuning only. Let see thous steps:

1. Install the JDK (I used JDK 1.8) and Set the JAVA_HOME

2. Get the Xerial SQLite-JDBC library source from GitHub (I used 3.15)

3. During the compilation process, original SQLite code will be download. So target machine need to have the Internet access or you need to change the Makefile to use locally downloaded files.

3. Changes in Makefile.common:

A) Add -std=gnu99 — To support C99 Standard

SunOS-sparcv9_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC  -m64 -std=gnu99 -fvisibility=hidden

B) For 32 bit binary, then add the following:

SunOS-sparc_CC := $(CROSS_PREFIX)gcc
SunOS-sparc_STRIP := $(CROSS_PREFIX)strip
SunOS-sparc_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_linux -O2 -fPIC  -m32 -std=gnu99 -fvisibility=hidden
SunOS-sparc_LINKFLAGS := -shared -static-libgcc
SunOS-sparc_LIBNAME := libsqlitejdbc.so

C) Added new target to known_targets:

known_targets := .. SunOS-sparc

4. Changes in Makefile:

A) For 32 bit binary, then add the following:

          $(MAKE) native OS_NAME=SunOS OS_ARCH=sparc

5. Build the native part

$ gmake sparcv9

$ gmake sparc

You can find the native library (libsqlitejdbc.so) in the folders:
32 bit: target/sqlite-3.15.1-SunOS-sparc
64 bit: target/sqlite-3.15.1-SunOS-sparcv9

6. Rebuild the JAR:

I am not building it for multiple platforms. It is also not possible. Because the some part of the build step depends on docker images, which is not supported in my VM. So I left with only one option of manually adding this native library into the sqlite-jdbc-3.15.X.jar JAR.

A) Download the latest JAR file.
B) Extract it (JAR is simply a ZIP File)
C) Create “SunOS” folder inside the /org/sqlite/native/
D) Create “sparc” and “sparcv9” folders inside the SunOS
E) Copy the libsqlitejdbc.so into corresponding folders (32 and 64)
F) Recreate the JAR

Now JAR ready for the Solaris SPARC platform. HTH 🙂

Tagged with: , , ,
Posted in Uncategorized

Interesting Hardware Issue: Photoelectric Effect on R Pi 2

Recently Raspberry Pi 2 released. One of the user trying to take a photo of his board (at that time board in running condition). When his camera flash went off, board power also went off. After testing few times, user posted this issue in the forum. R Pi team analysed and found out an interesting hardware issue – Photoelectric Effect Issue (similar to ESD in early days).

Read this blog: http://www.raspberrypi.org/xenon-death-flash-a-free-physics-lesson/

Posted in Uncategorized

Intel NUC – Tiny but powerful

Update (Mid 2016): D54250WYKH – This old (2014/2015) model has serious hardware issues related to USB, Display and SATA interfaces. Some this issues not resolved even after BIOS update. Please refer the Intel NUC forum to understand more this. To minimize the issues, you can run the unit with-out any keyboard, mouse and monitor. But still SSD/ HDD related issues might pop up.

Today I brought one Intel NUC for experiment purpose. Totel cost is ~1K SGD (NUC-i5, 16GB RAM, 250GB mSATA SSD, 1TB 2.5″ HDD).

Performance is okay. Remember not to compare the NUC processor (less speed and less cache) with regular i5 processors. Max RAM is 16GB. Tested with Win8.1, Ubuntu 14.04 and running few VMs also on it. Slit lag during heavy operations like starting VM. Otherwise okay.




Posted in Uncategorized

Porject Ara – DevConf @ SG

Today, I manage to reach the Google Project Ara – DevConf by 10:30AM. Interesting talks and Ideas. Met interesting people like Greg Kroah-Hartman, George Grey, Ara Team. Saw interesting modules like Pluggable camera, UniPro Bridge Chip, Blood Glucometer, Water Tester, Processor module, etc. The ProjectAra DevBoard is not yet ready for pure software development. If you are a core hardware developer with interesting idea, you can apply for DevBoard loan.

Posted in Uncategorized

LDAP: Multiple Provider URLs

The LDAP service provider uses this URL to configure its connection to the directory server. Only the host, port, and dn parts of the URL are relevant in this setting. Supplying other parts of the URL results in a ConfigurationException(in the API reference documentation). Most commonly we use just one URL. But we can also supply a space-separated list of URLs. In this case, the LDAP provider will attempt to use each URL in turn until it is able to create a successful connection. How to determine, on which server, are we connected to?? The LDAP provider set Context.PROVIDER_URL property to the successful URL, so that the application can determine which URL is being used. Here is an example of how to specify a list of URLs.

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, “com.sun.jndi.ldap.LdapCtxFactory”);

// Specify list of space-separated URLs
env.put(Context.PROVIDER_URL, “ldap://host1:389/o=JNDITutorial ” + “ldap://host2:389/o=JNDITutorial ” + “ldap://host3:389/o=JNDITutorial ” + “ldap://host4:389/o=JNDITutorial”);

// Create initial
context DirContext ctx = new InitialDirContext(env);

// See which server was used

For more info: http://docs.oracle.com/javase/jndi/tutorial/ldap/misc/url.html

Posted in Uncategorized

Find the Yesterday

On GNU/Linux platform finding the particular date from current date is a no brainer task. For example:

Yesterday: date –date=’yesterday’
Nextday: date –date=’next day’ OR date –date=’tomorrow’
Other Tricks:
date –date=’10 year’
date –date=’10 year ago’
date –date=’this sunday’

But on Solaris, you don’t have this luxury. So you can use the following trick:
TZ=GMT+24 date

Tagged with: , ,
Posted in Uncategorized

Android Udev Rules

Linux Udev rule file to interface Android Hardware for Application/System development.

# Acer 0502
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="plugdev"
# ASUS 	0b05
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev"
# Dell 	413c
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="plugdev"
# Foxconn 	0489
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev"
# Fujitsu 	04c5
# Fujitsu Toshiba 	04c5
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev"
# Garmin-Asus 	091e
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="plugdev"
# Google 	18d1
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
# Haier 	201E
SUBSYSTEM=="usb", ATTR{idVendor}=="201e", MODE="0666", GROUP="plugdev"
# Hisense 	109b
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", GROUP="plugdev"
# HTC 	0bb4
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
# Huawei 	12d1
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
# K-Touch 	24e3
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", GROUP="plugdev"
# KT Tech 	2116
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", GROUP="plugdev"
# Kyocera 	0482
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", GROUP="plugdev"
# Lenovo 	17ef
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"
# LG 	1004
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
# Motorola 	22b8
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
# MTK 	0e8d
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev"
# NEC 	0409
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", GROUP="plugdev"
# Nook 	2080
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666", GROUP="plugdev"
# Nvidia 	0955
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="plugdev"
# OTGV 	2257
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", GROUP="plugdev"
# Pantech 	10a9
SUBSYSTEM=="usb", ATTR{idVendor}=="10a9", MODE="0666", GROUP="plugdev"
# Pegatron 	1d4d
SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", MODE="0666", GROUP="plugdev"
# Philips 	0471
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666", GROUP="plugdev"
# PMC-Sierra 	04da
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", GROUP="plugdev"
# Qualcomm 	05c6
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
# SK Telesys 	1f53
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666", GROUP="plugdev"
# Samsung 	04e8
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
# Sharp 	04dd
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="plugdev"
# Sony 	054c
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", GROUP="plugdev"
# Sony Ericsson 	0fce
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
# Teleepoch 	2340
SUBSYSTEM=="usb", ATTR{idVendor}=="2340", MODE="0666", GROUP="plugdev"
# Toshiba 	0930
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", GROUP="plugdev"
# ZTE 	19d2
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"
Tagged with: , ,
Posted in Uncategorized

Netbeans: Headers to Java File

In the Netbeans IDE, whenever you create a project/file, it adds the following header.

* To change this template, choose Tools | Templates
* and open the template in the editor.

Here we will see, how to change or customize this header to suit our needs.

  • Select Tools -> Templates -> Template Manager
  • Change the License statement
    • Select: Licenses -> Default License
    • Click the “Open in Editor” Button, Remove the existing text and add the following lines:

<#if licenseFirst??>
${licensePrefix} (c) ${date?date?string(“yyyy”)} Your/ Company Name
<#if licenseLast??>

  • Save
  • Change the Program Header
    • Java -> Java Main class
    • Click the “Open in Editor” Button
    • Replace the following lines:

* @author ${user}

  • With this lines:

* File Name:    ${nameAndExt}
* Project Name: ${project.name}
* @since  ${date}, ${time}
* @author ${user}
* File Description:
* Provide a 2 line short description.

  • Save
  • Repeats the previous step, for the following templates also:
    • Java Class
    • Java Interface
    • Java Singleton Class
    • Java Exception
  • Set Proper User Name: In Template Manager, Click the “Settings” Button and add the following line:

   user=Your Full Name <Your_Mail_Id@domain.com>

Tagged with: ,
Posted in Uncategorized

HP V1910 L3 Switch – Review

My experience with HP L3 Switch (formally 3Com) V1910 (16 and 24 Ports)


  1. Low cost. It is a simple smartly managed switch.
  2. HP Support (so for so good)
  3. Suitable for simple /24 based network


  1. Only web based interface. It can be accessed from any VLAN interface with IP. Normally, it is allowed only from Management VLAN. So may not be suitable for public IP routing.
  2. Some compatibility issue with Cisco Router. No documentation.
Tagged with: , ,
Posted in Uncategorized

Solaris 10: Replace the failed mirrored Boot Disk

I was lucky to identify Disk IO Error in one of our SunFire v215. The Disk contains the boot-able partition. So I have to replace ASAP. Here is the steps, that I followed to replace the failed mirror root disk.

System is having 4 disks. Disks are RAID1 mirrored (1+1). Partitions are UFS. (Not ZFS).

  • Mirror 1 – Boot-able
  • Disk 1 (c0t0d0)
  • Disk 2 (c0t1d0)  <- Failed Disk
  • Mirror 2 – Data
  • Disk 3 (c1t0d0)
  • Disk 4 (c1t0d0)


  1. Check the mirror status:
    • metastat -ac — Disk contains the partitions with (maint) are in the trouble.
    • iostat -En — Shows if there is any errors
  2. Important note
    • Don’t reboot, if s0 in “maint” state and md:mirrored_root_flag=1 not set in /etc/system file.
    • If you have chance to reboot the system, then do the following before the reboot
    • echo “set md:mirrored_root_flag=1” >> /etc/system
    • echo “set md_mirror:md_resync_bufsz = 2048” >> /etc/system
  3. Problem is conformed and Replacement disk is ready in the hand
    • metadb -i — Get metadb locations
    • cfgadm -al — Get disk config detail and Note down faulty disk detail
  4. Detach the faulty disk from the mirror
    • metadetach -f  d0 d20 — Detach the sub mirror d20 from mirror d0 and do the same for other mirrored slices (s1, s5, s7)
    • metaclear d20 — Clear sub mirror and do the same for other slices
    • metastat -ac — Just to verify
  5. Remove the faulty disk from the mirror
    • metadb -d c0t1d0s3 — In my case, Metadb in slice 3. you can get this info from metadb -i command
  6. Format the disk
    • As per your company policy, if you need to format the disk. You can do it now. Warning: Format may take 2 Hrs or more.
    • format
  7. Detach the faulty disk from OS
    • cfgadm -c unconfigure c0::dsk/c0t1d0
    • cfgadm -al — Just to conform, check faulty disk is unconfigured
    • Blue light should be ON. Now you can replace the disk.
  8. Attach the new disk to OS
    • cfgadm -c configure c0::dsk/c0t1d0 — Attach the disk
    • cfgadm al — Verify
  9. Copy the partition table to new disk
    • prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s – /dev/rdsk/cot1dos2
    • installboot /usr/platform/`uname -`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
  10. Create meta db in the new disk
    • metadb -c 2 -a c0t1d0s3
  11. Create and attach sub mirrors in the new disk as RAID1
    • metainit d20 1 1 c0t1d0s0 — Do the same for other slices (s1, s5, s7)
    • metattach d0 d20 — Do the same for the other slices (s1, s5, s7)
  12. Now mirror will starts sync the data between disks.
    • metastat -ac


Tagged with: , ,
Posted in Uncategorized