Wednesday, October 31, 2018

Printing Barcode from Command Line to USB Printer Remotely

Hardware Required

This is achieved using Ethernet to USB Print Server adapter. This should not to be confused with USB to Ethernet adapter where the USB port connects to the PC and Ethernet port connects to a networking router.

Hardware Setup

  • Connet the USB barcode printer to a print server adapter.
  • Connect printer server network port to network router
  • Power up and assign a static IP address to the printer server

Print Server Configuration

Access the print server via a browser http://<ip address>


This screen may look different depending on the print server make.

Take note of the port name. This will be used as print queue name when executing lpr command. Using other name as the queue name might return the following error:

Error: print server did not accept request.  Job aborted.

Barcode Programming Language File

Prepare your barcode file, e.g. test.zpl

LPR

LPR stands for Line Printer Remote. On a windows system, this is not enabled by default. Go to Windows Features to enable LPR.

Send the ZPL file using the following command:

                                    
lpr -S 129.10.10.101 -P U1 test.zpl 
                                    
When sending print request to USB print server, the print queue name should be set to the port name that the printer is connected to.

Friday, January 5, 2018

Oracle - Create Table from Another Table and Add a New Column

Let's say we want to add a new column to an existing database table T.

Get the DDL for the table and its constraints (e.g. use SQL Developer or DBMS_METADATA.GET_DDL).

Duplicate the old table. This table will be temporary for transferring existing data to the new table.

CREATE TABLE T_TMP AS (SELECT * FROM T);

Drop the old table.

DROP TABLE T CASCADE CONSTRAINTS;

Duplicate the temporary table and add the column.

CREATE TABLE T AS
  SELECT COL_1, COL_2, COL_3, CAST(NULL AS NUMBER(15)) AS COL_NEW
  FROM RUN_T_TMP;

Recreate all constraints, primary keys and indexes.

Drop the temporary table.

DROP TABLE T_TMP CASCADE CONSTRAINTS;


That's it.

Thursday, January 4, 2018

Ant Build Problem in Eclipse Oxygen - JRE less than 1.8 is not supported

When executing ant build within Eclipse using JRE 1.6, the following error occurs:



One would ask, "Why use old JRE when there are newer and better versions?"

The answer to this question is, in some environments, there are existing legacy system that cannot be upgraded due to various reasons including financial constraints.
The Eclipse Oxygen comes with Ant version 1.10.1 plugin. Apache Ant 1.10.x requires Java Runtime 1.8, whereas Ant 1.9.x stays compatible with Java 1.5 to 1.7.

Since Ant 1.10.x requires JRE8 and above, if you run an ant build file using the default Ant Home that points to the ant plugin, the ant launcher checks for the JRE version and prevent ant from launching with older JRE. However, if you configure to run your ant build with an external Ant runtime (configure Ant Home in the classpath to point to the external Ant 1.9.x runtime), it does not block ant runtime from launching.

Below is the source code of the ant launching method in org\eclipse\ant\internal\launching\launchConfigurations\AntLauchDelegate.java 


First download Apache Ant 1.9.9 and extract it. Then, configure external ant runtime in the ant build launcher and change the Ant Home in the Classpath tab.








That's it. Now the ant build file can be executed in Eclipse with JRE6.