EBS QRCODE
http://www.swetake.com/qrcode/java/qr_java.html
qrcode_java0.50beta10.tar
[root@ebs12vis ~]# su - applmgr
[applmgr@ebs12vis ~]$ cd $JAVA_BASE
[applmgr@ebs12vis java]$ pwd
/d01/applmgr/VIS/apps/apps_st/comn/java
[applmgr@ebs12vis java]$ ll
total 24
drwxr-xr-x 25 applmgr dba 12288 Jan 12 12:41 classes
drwxr-xr-x 2 applmgr dba 4096 Jan 11 16:45 lib
[applmgr@ebs12vis java]$ mkdir $JAVA_BASE/com
[applmgr@ebs12vis java]$ chmod 777 $JAVA_BASE/com
[applmgr@ebs12vis java]$ cd $JAVA_BASE/com
[applmgr@ebs12vis com]$ pwd
/d01/applmgr/VIS/apps/apps_st/comn/java/com
[applmgr@ebs12vis com]$ ll
total 996
-rw-r--r-- 1 root root 1010702 Jun 12 15:23 qrcode_java0.50beta10.tar.gz
[applmgr@ebs12vis com]$ tar -zxvf qrcode_java0.50beta10.tar.gz
qrcode_java0.50beta10/
qrcode_java0.50beta10/docs/
qrcode_java0.50beta10/docs/constant-values.html
qrcode_java0.50beta10/docs/overview-tree.html
qrcode_java0.50beta10/docs/index-all.html
qrcode_java0.50beta10/docs/deprecated-list.html
qrcode_java0.50beta10/docs/allclasses-frame.html
qrcode_java0.50beta10/docs/allclasses-noframe.html
qrcode_java0.50beta10/docs/index.html
qrcode_java0.50beta10/docs/packages.html
qrcode_java0.50beta10/docs/com/
qrcode_java0.50beta10/docs/com/swetake/
qrcode_java0.50beta10/docs/com/swetake/util/
qrcode_java0.50beta10/docs/com/swetake/util/package-frame.html
qrcode_java0.50beta10/docs/com/swetake/util/package-summary.html
qrcode_java0.50beta10/docs/com/swetake/util/package-tree.html
qrcode_java0.50beta10/docs/com/swetake/util/Qrcode.html
qrcode_java0.50beta10/docs/package-list
qrcode_java0.50beta10/docs/help-doc.html
qrcode_java0.50beta10/docs/stylesheet.css
qrcode_java0.50beta10/lib/
qrcode_java0.50beta10/lib/Qrcode.jar
qrcode_java0.50beta10/README.txt
qrcode_java0.50beta10/samples/
qrcode_java0.50beta10/samples/QrAppletSample.java
qrcode_java0.50beta10/samples/QrAppletSample.html
qrcode_java0.50beta10/samples/sample.java
qrcode_java0.50beta10/samples/QrAppletSample.jar
qrcode_java0.50beta10/src/
qrcode_java0.50beta10/src/com/
qrcode_java0.50beta10/src/com/swetake/
qrcode_java0.50beta10/src/com/swetake/util/
qrcode_java0.50beta10/src/com/swetake/util/qrcode_data/
qrcode_java0.50beta10/src/com/swetake/util/Qrcode.java
[applmgr@ebs12vis com]$ cp $JAVA_BASE/com/qrcode_java0.50beta10/lib/Qrcode.jar $JAVA_BASE/com
SELECT *
FROM DBA_REGISTRY
WHERE COMP_ID = 'JAVAVM';
If not exists execute $ORACLE_HOME/javavm/install/initjvm.sql
[applmgr@ebs12vis com]$ loadjava -u apps/apps@VIS -r -v -f -genmissing -s -grant public $JAVA_BASE/com/Qrcode.jar
SELECT *
FROM DBA_OBJECTS X
WHERE 1=1
AND X.OBJECT_TYPE LIKE 'JAVA%'
AND UPPER(X.OBJECT_NAME) LIKE '%QRCODE%';
/var/tmp/qrcode
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED QRCodeEncoder
AS import java.awt.image.BufferedImage;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import com.swetake.util.Qrcode;
/**
* 二维码生成器
*/
public class QRCodeEncoder {
/**
* 生成二维码(QRCode)图片
*
* @param content
* @param imgPath
*/
public void encoderQRCode(String content, String imgPath) {
try {
Qrcode qrcodeHandler = new Qrcode();
qrcodeHandler.setQrcodeErrorCorrect('M');
qrcodeHandler.setQrcodeEncodeMode('B');
qrcodeHandler.setQrcodeVersion(7);
System.out.println(content);
byte[] contentBytes = content.getBytes("gb2312");
BufferedImage bufImg = new BufferedImage(140, 140,
BufferedImage.TYPE_INT_RGB);
Graphics2D gs = bufImg.createGraphics();
gs.setBackground(Color.WHITE);
gs.clearRect(0, 0, 140, 140);
// 设定图像颜色 > BLACK
gs.setColor(Color.BLACK);
// 设置偏移量 不设置可能导致解析出错
int pixoff = 2;
// 输出内容 > 二维码
if (contentBytes.length > 0 && contentBytes.length < 120) {
boolean[][] codeOut = qrcodeHandler.calQrcode(contentBytes);
for (int i = 0; i < codeOut.length; i++) {
for (int j = 0; j < codeOut.length; j++) {
if (codeOut[j][i]) {
gs.fillRect(j * 3 + pixoff, i * 3 + pixoff, 3, 3);
}
}
}
} else {
System.err.println("QRCode content bytes length = "
+ contentBytes.length + " not in [ 0,120 ]. ");
}
gs.dispose();
bufImg.flush();
File imgFile = new File(imgPath);
// 生成二维码QRCode图片
ImageIO.write(bufImg, "png", imgFile);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param args
* the command line arguments
*/
public static void main(String[] args) {
String imgPath = "/var/tmp/qrcode/QRCode.png";
String content = "Oracle EBS Repository,你好,世界";
QRCodeEncoder handler = new QRCodeEncoder();
handler.encoderQRCode(content, imgPath);
System.out.println("encoder QRcode success");
}
}
CREATE OR REPLACE PROCEDURE cux_get_qrcode
AS
LANGUAGE JAVA
NAME 'QRCodeEncoder.main(java.lang.String[])' ;
set serveroutput on
call dbms_java.set_output(5000);
execute cux_get_qrcode;