How to Use Com ports on oracle forms
Hai,
how we can use com port to communicate to the device like Pole Display(output device) or fixed scaneer (input device) having serial port(Input device) in oracle forms.
Thanks & regards
For web forms you will probably need to create a PJC and/or use webutil and make calls to the device's API.
Similar Messages
-
How to use unicode fonts in Oracle forms 10g?
Hi I am working in forms 10g for quite a long time, the software that I have developed so far are all in English language. Now I have requirements to use Bengali Fonts in Forms 10g. I am facing difficulties doing that. Please reply with help. Thanks
Hasan Al MamunCheck this forum post (though that is for 6i, it would be of helpful for you)
How to use unicode fonts in Oracle forms 10g?
-Arun -
How to use Java Script in Oracle Forms 10g
Hello,
Appreciate if anyone could help me using Java Script in Oracle Forms 10g?
Thanks
GMThank you for your reply. I was reading on the metalink that we could use the to call the java script from oracle Forms 10g (Doc ID 265863.1)
Example:
WEB.SHOW_DOCUMENT ('javascript:void(window.open("http://www.oracle.com","","location=no,toolbar=no,menubar=no,status=no,"));self.close()','_blank');
I tried it but it did not open the any window as it claims. Am I missing anything? Is there any IE related setting which I need to modify for the above to work?
Regards
GM -
How to use BULK COLLECT in oracle forms
hi gurus,
I am using oracle forms
Forms [32 Bit] Version 10.1.2.0.2 (Production)
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionI wanna use bulk collect from database table lets say <employees>
while working on database level with collections and records it's working very well for me, but when I try to use that technique on oracle forms it hits me error
error 591 this feature is not supported in client side programmingI know I can use cursors to loop through the records of oracle tables ,
but I'm convenient while using collections and arrays
for example
Set Serveroutput On
Declare
Type Rec_T Is Record (
Empid Number ,
Empname Varchar2(100)
Type V_R Is Table Of Rec_T Index By Binary_Integer;
V_Array V_R;
Begin
Select Employee_Id , First_Name
Bulk Collect
Into V_Array
From Employees;
For Indx In V_Array.First..V_Array.Last Loop
Dbms_Output.Put_Line('employees id '||V_Array(Indx).Empid ||'and the name is '||V_Array(Indx).Empname);
End Loop;
End;I wanna use this same way on oracle forms , for certain purposes , please guide me how can I use ...
thanks...For information, you can use and populate a collection within the Forms application without using the BULK COLLECT
Francoisactually I want to work with arrays , index tables ,
like
record_type (variable , variable2);
type type_name <record_type> index by binary_integer
type_variable type_name;
and in main body of program
select something
bulk collect into type_variable
from any_table;
loop
type_variable(indx).variable , type_variable(indx).variable2;
end loop;
this is very useful for my logic on which I am working
like
type_variable(indx).variable || type_variable(indx-1);
if it's possible with cursors then how can I use cursor that can fullfill my this logic@Francois
if it's possible then how can i populate without using bulk collect?
thanks
and for others replies: if I can use stored procedures please give me any example..
thanks -
How to use java programe in oracle form
Hello Expert,
My Config is : -
Forms [32 Bit] Version 11.1.1.3.0 (Production)
Jdeveloper - 10.1.3
I want to use the java programe in form builder. I create the one java class in Jdeveloper -
package demo;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
public class get_info{
public static void main(String[] args){
ch_add();
public static void ch_add()
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
/*System.out.println("Current IP address : " + ip.getHostAddress()); */
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
byte[] mac = network.getHardwareAddress();
/*System.out.print("Current MAC address : "); */
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++)
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
System.out.println(sb.toString());
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (SocketException e){
e.printStackTrace();
and this into Formweb.cfg and default.env and also add into Form_class_path. After that i import this java into forms.
Code genertated -
PACKAGE BODY get_info IS
-- DO NOT EDIT THIS FILE - it is machine generated!
args JNI.ARGLIST;
-- Constructor for signature ()V
FUNCTION new RETURN ORA_JAVA.JOBJECT IS
BEGIN
args := NULL;
RETURN (JNI.NEW_OBJECT('demo/get_info', '()V', args));
END;
-- Method: main ([Ljava/lang/String;)V
PROCEDURE main(
a0 ORA_JAVA.JARRAY) IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_OBJECT_ARG(args, a0, '[Ljava/lang/String;');
JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'main', '([Ljava/lang/String;)V', args);
END;
-- Method: ch_add ()V
PROCEDURE ch_add IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'ch_add', '()V', args);
END;
-- Method: wait (J)V
PROCEDURE wait(
obj ORA_JAVA.JOBJECT,
a0 NUMBER) IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_LONG_ARG(args, a0);
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(J)V', args);
END;
-- Method: wait ()V
PROCEDURE wait(
obj ORA_JAVA.JOBJECT) IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '()V', args);
END;
-- Method: wait (JI)V
PROCEDURE wait(
obj ORA_JAVA.JOBJECT,
a0 NUMBER,
a1 NUMBER) IS
BEGIN
args := JNI.CREATE_ARG_LIST(2);
JNI.ADD_LONG_ARG(args, a0);
JNI.ADD_INT_ARG(args, a1);
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(JI)V', args);
END;
-- Method: equals (Ljava/lang/Object;)Z
FUNCTION equals(
obj ORA_JAVA.JOBJECT,
a0 ORA_JAVA.JOBJECT) RETURN BOOLEAN IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_OBJECT_ARG(args, a0, 'java/lang/Object');
RETURN JNI.CALL_BOOLEAN_METHOD(FALSE, obj, 'demo/get_info', 'equals', '(Ljava/lang/Object;)Z', args);
END;
-- Method: toString ()Ljava/lang/String;
FUNCTION toString(
obj ORA_JAVA.JOBJECT) RETURN VARCHAR2 IS
BEGIN
args := NULL;
RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'demo/get_info', 'toString', '()Ljava/lang/String;', args);
END;
-- Method: hashCode ()I
FUNCTION hashCode(
obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
BEGIN
args := NULL;
RETURN JNI.CALL_INT_METHOD(FALSE, obj, 'demo/get_info', 'hashCode', '()I', args);
END;
-- Method: getClass ()Ljava/lang/Class;
FUNCTION getClass(
obj ORA_JAVA.JOBJECT) RETURN ORA_JAVA.JOBJECT IS
BEGIN
args := NULL;
RETURN JNI.CALL_OBJECT_METHOD(FALSE, obj, 'demo/get_info', 'getClass', '()Ljava/lang/Class;', args);
END;
-- Method: notify ()V
PROCEDURE notify(
obj ORA_JAVA.JOBJECT) IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notify', '()V', args);
END;
-- Method: notifyAll ()V
PROCEDURE notifyAll(
obj ORA_JAVA.JOBJECT) IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notifyAll', '()V', args);
END;
BEGIN
NULL;
END;
Now i want to call the o/p of Java programe in oracle text item. Please help me. It's very urgent. I am not good in Java.Sir i use java importer.
PACKAGE BODY get_info IS
-- DO NOT EDIT THIS FILE - it is machine generated!
args JNI.ARGLIST;
-- Constructor for signature ()V
FUNCTION new RETURN ORA_JAVA.JOBJECT IS
BEGIN
args := NULL;
RETURN (JNI.NEW_OBJECT('demo/get_info', '()V', args));
END;
-- Method: main ([Ljava/lang/String;)V
PROCEDURE main(
a0 ORA_JAVA.JARRAY) IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_OBJECT_ARG(args, a0, '[Ljava/lang/String;');
JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'main', '([Ljava/lang/String;)V', args);
END;
-- Method: ch_add ()V
PROCEDURE ch_add IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(TRUE, NULL, 'demo/get_info', 'ch_add', '()V', args);
END;
-- Method: wait (J)V
PROCEDURE wait(
obj ORA_JAVA.JOBJECT,
a0 NUMBER) IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_LONG_ARG(args, a0);
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(J)V', args);
END;
-- Method: wait ()V
PROCEDURE wait(
obj ORA_JAVA.JOBJECT) IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '()V', args);
END;
-- Method: wait (JI)V
PROCEDURE wait(
obj ORA_JAVA.JOBJECT,
a0 NUMBER,
a1 NUMBER) IS
BEGIN
args := JNI.CREATE_ARG_LIST(2);
JNI.ADD_LONG_ARG(args, a0);
JNI.ADD_INT_ARG(args, a1);
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'wait', '(JI)V', args);
END;
-- Method: equals (Ljava/lang/Object;)Z
FUNCTION equals(
obj ORA_JAVA.JOBJECT,
a0 ORA_JAVA.JOBJECT) RETURN BOOLEAN IS
BEGIN
args := JNI.CREATE_ARG_LIST(1);
JNI.ADD_OBJECT_ARG(args, a0, 'java/lang/Object');
RETURN JNI.CALL_BOOLEAN_METHOD(FALSE, obj, 'demo/get_info', 'equals', '(Ljava/lang/Object;)Z', args);
END;
-- Method: toString ()Ljava/lang/String;
FUNCTION toString(
obj ORA_JAVA.JOBJECT) RETURN VARCHAR2 IS
BEGIN
args := NULL;
RETURN JNI.CALL_STRING_METHOD(FALSE, obj, 'demo/get_info', 'toString', '()Ljava/lang/String;', args);
END;
-- Method: hashCode ()I
FUNCTION hashCode(
obj ORA_JAVA.JOBJECT) RETURN NUMBER IS
BEGIN
args := NULL;
RETURN JNI.CALL_INT_METHOD(FALSE, obj, 'demo/get_info', 'hashCode', '()I', args);
END;
-- Method: getClass ()Ljava/lang/Class;
FUNCTION getClass(
obj ORA_JAVA.JOBJECT) RETURN ORA_JAVA.JOBJECT IS
BEGIN
args := NULL;
RETURN JNI.CALL_OBJECT_METHOD(FALSE, obj, 'demo/get_info', 'getClass', '()Ljava/lang/Class;', args);
END;
-- Method: notify ()V
PROCEDURE notify(
obj ORA_JAVA.JOBJECT) IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notify', '()V', args);
END;
-- Method: notifyAll ()V
PROCEDURE notifyAll(
obj ORA_JAVA.JOBJECT) IS
BEGIN
args := NULL;
JNI.CALL_VOID_METHOD(FALSE, obj, 'demo/get_info', 'notifyAll', '()V', args);
END;
BEGIN
NULL;
END;
I read both document which is given by you.
Basicaly i don't know how to call java program in form builder.
I wrote this code on When-button-pressed
DECLARE
jo ora_java.jobject;
rv varchar2(1500);
ex ora_java.jobject;
BEGIN
jo := get_info.new;
rv:=get_info.ch_add(jo );
EXCEPTION
WHEN ORA_JAVA.JAVA_ERROR then
message (' Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR );
message('');
WHEN ORA_JAVA.EXCEPTION_THROWN then
ex := ORA_JAVA.LAST_EXCEPTION;
message(' Unable to call out to Java ' ||Exception_.toString (ex ) );
message(' Unable to call out to Java ' ||Exception_.toString (ex ) );
END;
No error comes and no output comes. I want the client MAC ID. please guide me where i need to change the code. -
How to use Java Beans in Oracle Forms 11g at 64 bit windows7
Hello Experts,
I am using Oracle forms 11.1.2.2.0 with weblogic 10.3.6 generic at windows 7 64 bit.
My java version is jdk1.7.0_51.
Now I have a htmlbutton.jar (which is for bean item in oracle form and this jar file works well for oracle forms 11g 32 bit windows 7 environment).
I have takken steps:
1:-Put jar file in home\java folder.
2:-add this jar file into archive in formsweb.cfg.
3:-Add this this jar file(which is in my home- java folder) in form_class path in registry.
Now when I try to locate this jar file in my oracle form.There is no such jar file.what are the steps to use this jar file in oracle forms bean item.
Please told me what is wrong here.
thank you
regards
aaditya.It is unclear where you are having a problem. Is your issue at runtime (when the form runs in the browser) or when working in the Builder on the form?
Also be aware that you will need to sign your jar and include some new manifest entries. Refer to the Java 7u51 documentation and blogs that discuss the changes.
https://blogs.oracle.com/java-platform-group/entry/new_security_requirements_for_rias
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html -
How to use BEAN in an oracle forms at client side
Hello,
I am new in oracle forms.I am using
OS-Windows 7.
Forms [32 Bit] Version 11.1.2.1.0 (Production)
weblogic 10.3.5
Now I want know that how to use bean item in an oracle forms.
Thank You.Hello,
You copy the corresponding JAR file that contains the Java BEan in your <DEVSUITE_HOME>/forms/java folder, then you add its name to the archive tags of the forsweb.cfg file.
This done, you add a Bean Area to your canvas, set its Implementation Class property with the full class name, then you can communicate with the bean via the GET_CUSTOM_PROPERTY() and SET_CUSTOM_PROPERTY() built-in.
Google could also give you more information.
Francois -
How To use JFree chart in Oracle Forms 11g ?
Hi all
I had a graph in oracle forms6i I would like to convert them to 11g forms as graph builder is not supported by oracle forms 11g while goggling came to knew that there is Jfree chart through which we can develop the same as 6i graph..but unable to find any demo or Document Can any one help me regarding this please..?
thanks in advanceHello,
Oracle has the FormsGraph Bean, that you can take from the forms10g or forms11g demo pack (see the Forms home page on OTN).
Francois -
How to use BULK COLLECT in Oracle Forms 11g
Forms is showing error that "Feature is not support in Client Side Program" when i am trying to impliment Bulk collect in Forms 11g.
i need to load full data from DB to my form becuase using cursor is very slow....
Is there any method/Work around to achieve this ....declare
type arr is table of emp%rowtype ;
lv_arr arr;
begin
select * bulk collect in to lv_arr from emp;
/*written code here to process the data and write in to file*/
end;Unless you are inserting/updating the data you are holding in the array into a database table I don't think there is much peformance gain in using bulk-collect in conjunction with writing a file. Bulk processing will increase performance by minimizing context switches from the SQL to the PL/SQL engine, nothing more, nothing less.
In any case bulk processing is not available in forms, if you really need to make use of it you need to do it in a stored procedure.
cheers -
How to use DLL function in Oracle Forms 5.0?
for instance, the FindWindowA function in "user32.dll"
please advise, thanksTake a look at ORA_FFI package.
-
How to use MICR fonts in Adobe forms (webdynpro java
Hi,
We have a requirement where we need to print some MICR codes (for checks) through Adobe Forms.
I have installed some true type MICR fonts in windows and Adobe Font Manager (in ADS) as well.
It is visible in the Adobe Form design time (Font palette) and when I use the font for text, it is visible in preview too. But when I run the web dynpro application, in the online form it is converted into Standard font (Times new Roman).
Is there anyway to handle this issue.
Please let me know.
I am using NWDS 7.0.1
Adobe Live cycle designer 7.1
SAP NW 2004s SP14
Thank you,
VasuCheck this forum post (though that is for 6i, it would be of helpful for you)
How to use unicode fonts in Oracle forms 10g?
-Arun -
Help : Unable to use Java Beans in Oracle forms 6i
Hi ,
I have been trying to run few sample code to understand how to use Java beans in oracle forms 6i .But have been largely unsuccessfull.
It will be great if somebody can provide me with some simple form( and java code )which uses java beans concept to give some data to the java program and receive some data from it . Pls inform me about the settings that need to be done.
If you guys know it then pls take the pains of writing a simple form and java code.
i hope somebody will respond because your reply is very necesary for me to proceed.
U can email me the code > [email protected]
Thanks in advance.Thanks for your reply Francois.
Actually i am not facing problem understanding the programming technique.
I think the problem at my end is more of a cofiguration one.I am using forms version 6i
on oracle 8.
Every time i set the imlementation class property of the bean area it gives an error 13010 which translates to that "the class being mentioned is not extending the IView class".
The class i have written extends VBean so i am not sure why this error is occuring.
I think if oracle (correctly) finds the java class to use then i will be able to proceed.
Pls reply.
If you have some code that is working fine then pls send it to me.And also inform is some environment variables have to be set for its use. -
Attach Forms With Comm Port in Oracle Forms
I am trying to make connection of Oracle forms Builder with my device using comm port but i dnt know the complete procedure to attach the comm with oracle forms also i have no idea to convert asquii data to normal form.Please any one help me to attach comm port with my oracle forms and also convert asqui code which is showing on hyper terminal into normal data.Also I am using oracle forms 6i
Make a java component (PJC) and use a rxtx library (http://rxtx.qbang.org/wiki/index.php/Examples) ...
I have made a PJC to use a RS232 port from oracle forms for Hypercom POS terminal..
Here is my code (in short i will post a component on PJC site (here I can't post a complete code because of 30000 char limit ;) )..
If you look in method "public void init(IHandler handler) " I make a download of rxtxSerial.dll from my forms server and then I call System.loadLibrary("rxtxSerial");"
In other way you must put the dll in windows/system32 path.. This dll is native library for rs232 communication.
If you look at the method "public void doTransaction" you can see the initialization of comm port...
With inputStream and OutputStream you read and write datas to/from your rs232 port..
p.s: the code is not complete but you can see how I made the rs232 communication (also the code is not final ;) )
====================================================
public class PosTerminalPjc extends VBean {
private static final long serialVersionUID = -8814623494538014849L;
Properties res = new Properties();
SerialPort serialPort;
OutputStream os;
InputStream is;
CommPortIdentifier portId;
Enumeration portList;
IHandler mHandler;
Random randomGenerator = new Random();
char STX = 2;
char ETX = 3;
char EOT = 4;
char ACK = 6;
char NAK = 15;
char FS = 28;
private static final ID COMPORT = ID.registerProperty("COMPORT"); // serial port (COM1,COM2,COM3,...)
private static final ID AMOUNT = ID.registerProperty("AMOUNT"); // amount of the transaction (12)
private static final ID TRANSACTIONTYPE = ID.registerProperty("TRANSACTIONTYPE"); // SALE, REFUND
private static final ID EXECUTE = ID.registerProperty("EXECUTE"); // invoke doTransaction();
//Output parameters to form
private static final ID TRANSACTIONPROCESSED = ID.registerProperty("TRANSACTIONPROCESSED");
private static final ID TRANSACTIONFLAG = ID.registerProperty("TRANSACTIONFLAG");
private static final ID TRANSACTIONNUMBER = ID.registerProperty("TRANSACTIONNUMBER");
private static final ID BATCHNUMBER = ID.registerProperty("BATCHNUMBER");
private static final ID TRANSACTIONDATE = ID.registerProperty("TRANSACTIONDATE");
private static final ID TRANSACTIONTIME = ID.registerProperty("TRANSACTIONTIME");
private static final ID TRANSACTIONAMOUNT = ID.registerProperty("TRANSACTIONAMOUNT");
private static final ID CARDDATASOURCE = ID.registerProperty("CARDDATASOURCE");
private static final ID NUMBERCUSTOMERCARD = ID.registerProperty("NUMBERCUSTOMERCARD");
private static final ID EXPIRATIONDATE = ID.registerProperty("EXPIRATIONDATE");
private static final ID TERMINALID = ID.registerProperty("TERMINALID");
private static final ID MERCHANTID = ID.registerProperty("MERCHANTID");
private static final ID COMPANYNAME = ID.registerProperty("COMPANYNAME");
private static final ID SEQUENTIALNUMBER = ID.registerProperty("SEQUENTIALNUMBER");
private static final ID ERRORDESC = ID.registerProperty("ERRORDESC");
//Events
private static final ID EVT_OK = ID.registerProperty("EVT_OK"); //custom event if all ok
private static final ID EVT_ERR = ID.registerProperty("EVT_ERR"); //custom event if error occured
// state machine variables
long l_timeout;
long l_wait_for = 5000; // pos terminal wait for command (5 seconds)
long l_wait_for_transaction = 62000 * 2; // pos terminal timeout
long l_second = 1000; // one second
byte b_retry = 0;
String dataValue = "";
byte[] readBuffer = new byte[2000]; //2000 bytes buffer to read rs232 stream
String comPort = ""; // local variable to store com port name
// (COM1,COM2,...)
String transactionType = "SALE"; // type of transaction to be executed (SALE
// or REFUND) default SALE
String amount = "0"; // default amount value is set to 0
//output paramerers
String transactionProcessed = "";
String transactionFlag = "";
String transactionNumber = "";
String batchNumber = "";
String transactionDate = "";
String transactionTime = "";
String transactionAmount = "";
String cardDataSource = "";
String numberCustomerCard = "";
String expirationDate = "";
String terminalId = "";
String merchandId = "";
String companyName = "";
String sequentialNumber ="";
String errorDescription;
public PosTerminalPjc() {
super();
System.out.println("============================");
System.out.println("== State machine POS v1.0 ==");
System.out.println("== Peter Valencic (c) ==");
System.out.println("== 03.04.2012 ==");
System.out.println("============================");
System.out.println("java.library.path: "+System.getProperty("java.library.path"));
try {
res.load(this.getClass().getResourceAsStream("/res/language.properties")); // load language file
} catch (Exception ex) {
System.err.println("Err loading language.properties file: "
+ ex.toString());
public void init(IHandler handler)
super.init(handler);
this.mHandler = handler;
System.out.println("init handler ok");
System.out.println("code base: "+handler.getCodeBase());
//load dll from codeBase URL
try
String mylibName = "rxtxSerial.dll";
String URLpath = "http://dekani:7777/forms/java/";
System.out.println("URL: "+ URLpath + mylibName);
URL libUrl = new URL(URLpath+mylibName);
System.out.println("libUrlgetFile: " + libUrl.getFile());
File file = new File(mylibName);
System.out.println(file);
if (!file.exists())
file.createNewFile();
URLConnection urlc = libUrl.openConnection();
InputStream in = urlc.getInputStream();
FileOutputStream out = new FileOutputStream(file);
byte[] buffer = new byte[1048];
int read;
while ((read = in.read(buffer)) != -1){
out.write(buffer, 0, read); // write
out.close();
in.close();
System.loadLibrary("rxtxSerial");
catch(Exception exc)
System.err.println("Exception SystemLoadLibrary: " + exc.toString());
this.showError(res.getProperty("s_dlg_err_title"),res.getProperty("s_lib"));
private void doTransaction() throws Exception {
String sequentialNumber = ""+getRandomInteger(1000,9000,randomGenerator);
String phase = null; // initial null value for state machine phase
long l_ack_timeout = 0; //initial value for acknowledge timeout
// com port check
if (getComPort().trim().equalsIgnoreCase("")) {
this.showError(res.getProperty("s_dlg_err_title"),
res.getProperty("s_com_invalid"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_com_invalid"));
dispatchCustomEvent(ce);
return;
// transaction type chek
System.out.println(this.getTransactionType());
if (!getTransactionType().equalsIgnoreCase("REFUND")
& !getTransactionType().equalsIgnoreCase("SALE")
& !getTransactionType().equalsIgnoreCase("TICKET")
& !getTransactionType().equalsIgnoreCase("VOID")
this.showError(res.getProperty("s_dlg_err_title"),res.getProperty("s_tran_invalid_type"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_tran_invalid_type"));
dispatchCustomEvent(ce);
return;
portList = portId.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
System.out.println(portId.getName());
if (portId.getName().equalsIgnoreCase(this.getComPort())) {
System.out.println("Port is used : "
+ portId.isCurrentlyOwned());
serialPort = (SerialPort) portId.open("ComDriver", 2000);
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_7,
SerialPort.STOPBITS_1, SerialPort.PARITY_EVEN);
serialPort.notifyOnDataAvailable(true);
serialPort.notifyOnOutputEmpty(true);
os = serialPort.getOutputStream();
is = serialPort.getInputStream();
break;
if (portId == null) {
this.showError(res.getProperty("s_dlg_err_title"),res.getProperty("s_com_not_found"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_com_not_found"));
dispatchCustomEvent(ce);
return;
else if (portId.getName().equalsIgnoreCase(this.getComPort()) == false)
this.showError(res.getProperty("s_dlg_err_title"),res.getProperty("s_com_not_found"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_com_not_found"));
dispatchCustomEvent(ce);
return;
// state machine infinite loop
while (true)
// SEND DATA TO POS TERMINAL
if (phase == null)
System.out.println("start phase");
byte[] req = null;
//verify transaction type to be SALE or REFUND
//if REFUND then transaction number must be specified
if (getTransactionType().equalsIgnoreCase("SALE")) {
System.out.println("--> SALE send message to the pos terminal");
System.out.println("--> amount: " + amount);
req = protocolStream("000000"+sequentialNumber+"01100" + FS + amount + FS
+ FS + "+0" + FS + "978" + FS + FS + FS + FS + FS
+ FS + FS + ETX);
else if (getTransactionType().equalsIgnoreCase("REFUND")) {
System.out.println("--> REFUND send message to the pos terminal");
System.out.println("--> amount: " + amount);
System.out.println("--> transaction number: " + getTransactionNumber());
req = protocolStream("000000123405100" + getTransactionNumber() + FS + amount
+ FS + FS + "+0" + FS + "978" + FS + FS + FS + FS
+ FS + FS + FS + ETX);
else if (getTransactionType().equalsIgnoreCase("VOID")) {
System.out.println("--> VOID transaction");
System.out.println("--> amount: " + amount);
System.out.println("--> transaction number: " + getTransactionNumber());
req = protocolStream("000000123410100" + getTransactionNumber() + FS + FS + FS + "+0" + FS + "978" + FS + FS + FS + FS
+ FS + FS + FS + ETX);
else if (getTransactionType().equalsIgnoreCase("TICKET")) {
System.out.println("--> TICKET duplicate");
req = protocolStream("000000123413100" + getTransactionNumber() + FS + FS + FS + "+0" + FS + "978" + FS + FS + FS + FS
+ FS + FS + FS + ETX);
else {
//nothing ;)
os.write(req);
os.flush();
l_ack_timeout = System.currentTimeMillis() + 1500;
//wait for half second
Thread.sleep(500);
l_timeout = System.currentTimeMillis() + l_wait_for; //add some time for timeout
phase = "TO_POS_ACK";
System.out.println("phase: " + phase);
}//phase null
//CHECK IF THE TIMEOUT OCCURED
if (phase.equalsIgnoreCase("TO_POS_ACK") & (l_timeout < System.currentTimeMillis()) & (b_retry < 4))
b_retry += 1;
System.out.println("TIMEOUT: " + b_retry);
l_timeout = System.currentTimeMillis() + l_wait_for;
if (b_retry >= 4) {
System.out.println("Timeout occured");
closePort();
this.showError(res.getProperty("s_dlg_err_title"),res.getProperty("s_timeout"));
break;
//CHECK FOR THE ACKNOWLEDGE (FIRST RESPONSE FROM POS TERMINAL)
if (phase.equalsIgnoreCase("TO_POS_ACK") &
(l_ack_timeout < System.currentTimeMillis())) {
try {
int numBytes = 0;
dataValue = "";
while ((numBytes = is.read(readBuffer)) > 0) {
dataValue += new String(readBuffer, 0, numBytes, "ASCII");
if (dataValue.getBytes().length > 0) {
System.out.println("->first byte: " +
dataValue.getBytes()[0]);
System.out.println("total length: " +
dataValue.getBytes().length);
//check for ack byte
if (dataValue.getBytes()[0] == 6) {
System.out.println(
"<--ACKNOWLEDGE received from pos terminal");
phase = "WAIT_FOR_TRANSACTION";
l_timeout = System.currentTimeMillis() + l_wait_for_transaction;
System.out.println("-> wait for transaction response");
} catch (IOException ev) {
//WAIT FOR TIMEOUT ON MESSAGE (watch dog timer)
if (phase.equalsIgnoreCase("WAIT_FOR_TRANSACTION") &
(l_timeout < System.currentTimeMillis())) {
System.out.println(
"Error receiving response from pos terminal!!!");
closePort();
this.showError(res.getProperty("s_dlg_err_title"),
res.getProperty("s_response_error"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_response_error"));
dispatchCustomEvent(ce);
break;
//WAIT FOR SOME DATA TO COME FROM POS TERMINAL OVER RS232
if (phase.equalsIgnoreCase("WAIT_FOR_TRANSACTION")) {
try {
int numBytes = 0;
dataValue = "";
Thread.sleep(500);
while ((numBytes = is.read(readBuffer)) > 0) {
dataValue += new String(readBuffer, 0, numBytes, "ASCII");
if (dataValue.getBytes().length > 0) {
System.out.println("->first byte: " +
dataValue.getBytes()[0] + "|" +
dataValue.getBytes()[1]);
System.out.println("->ascii: " + dataValue);
System.out.println("total length: " +
dataValue.getBytes().length);
if (dataValue.indexOf("PREKINIL UPORABNIK") != -1) {
System.out.println(
"Uporabnik je prekinil povezavo!");
closePort();
//transaction cancelled by user s_user_cancel
this.showError(res.getProperty("s_dlg_err_title"),
res.getProperty("s_user_cancel"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_user_cancel"));
dispatchCustomEvent(ce);
break;
if (dataValue.indexOf("NAPACEN VNOS") != -1) {
System.out.println("Napačen vnos");
closePort();
//invalid user entry
this.showError(res.getProperty("s_dlg_err_title"),
res.getProperty("s_user_invalid_entry"));
if (this.mHandler != null)
CustomEvent ce = new CustomEvent(this.mHandler, EVT_ERR);
this.setErrorDescription(res.getProperty("s_user_invalid_entry"));
dispatchCustomEvent(ce);
break;
if (dataValue.indexOf("PROSIM POCAKAJ") != -1) {
System.out.println("<-- PROSIM POCAKAJ");
continue;
//preberemo podatke iz stringe terminala
if (dataValue.indexOf("SPREJETO") != -1) {
closePort();
System.out.println("<-- TRANSAKCIJA SPREJETA");
System.out.println(dataValue);
StringTokenizer st = new StringTokenizer(dataValue, "\034" );
String dv = st.nextToken();
sequentialNumber = dv.substring(6,10);
transactionProcessed = dv.substring(1, 3);
transactionFlag = dv.substring(13,15);
transactionNumber = dv.substring(15,21);
batchNumber = dv.substring(21,25);
transactionDate = dv.substring(25,31);
transactionTime = dv.substring(31,37);
transactionAmount = st.nextToken();
st.nextToken(); //Amount exponent
st.nextToken(); //Amount currency
cardDataSource = st.nextToken();
numberCustomerCard = st.nextToken();
expirationDate = st.nextToken();
st.nextToken(); // authorization code
terminalId = st.nextToken();
merchandId = st.nextToken();
companyName = st.nextToken();
System.out.println("================");
System.out.println(transactionProcessed);
System.out.println(transactionFlag);
System.out.println(transactionNumber);
System.out.println(batchNumber);
System.out.println(transactionDate);
System.out.println(transactionTime);
System.out.println(transactionAmount);
System.out.println(cardDataSource);
System.out.println(numberCustomerCard);
System.out.println(expirationDate);
System.out.println(terminalId);
System.out.println(merchandId);
System.out.println(companyName);
if (this.mHandler != null)
System.out.println("dispatch custom event");
CustomEvent ce = new CustomEvent(this.mHandler, EVT_OK);
dispatchCustomEvent(ce);
return;
} catch (IOException ev) {
System.err.println("Exception sm: " + ev.toString());
System.out.print('*');
Thread.sleep(200);
}//end state machine loop
* protocolStream prepare the stream to be send over RS232 to POS terminal
* with LRC cheksum control
* @param data
* @return byte[]
private byte[] protocolStream(String data) {
char STX = (char) 0x02;
String tmp = "" + STX + STX + data + "" + getLRC(data);
System.out.println("PStream: " + tmp);
for (int i = 0; i < tmp.getBytes().length; i++) {
System.out.print(tmp.getBytes() + ":");
return tmp.getBytes();
* close port and stream
private void closePort()
try {
serialPort.close();
is.close();
os.close();
} catch (Exception ee) {
* Longitudinal Redundancy Check (LRC)
* @param packet
* @return String
private String getLRC(String packet) {
char[] splitPacket = packet.toCharArray();
char lrc = 0x00;
for (int x = 0; x < splitPacket.length; x++) {
lrc = (char) (lrc ^ splitPacket[x]);
return "" + (char) lrc;
private String paddingString(String s, int n, char c, boolean paddingLeft) {
if (s == null) {
return s;
int add = n - s.length(); // may overflow int size... should not be a
if (add <= 0) {
return s;
StringBuffer str = new StringBuffer(s);
char[] ch = new char[add];
Arrays.fill(ch, c);
if (paddingLeft) {
str.insert(0, ch);
} else {
str.append(ch);
return str.toString();
public boolean setProperty(ID id, Object value)
if (id.toString().equalsIgnoreCase("COMPORT")) {
setComPort((String)value);
System.out.println("RS232 com port: " + getComPort());
return false;
if (id.toString().equalsIgnoreCase("AMOUNT")) {
this.setAmount((String)value);
System.out.println("Amount value: " + getAmount());
return false;
if (id.toString().equalsIgnoreCase("TRANSACTIONTYPE")) {
this.setTransactionType((String)value);
System.out.println("Transaction Type value: " + this.getTransactionType());
return false;
if (id.toString().equalsIgnoreCase("EXECUTE")) {
System.out.println("Invoke pos terminal");
try
doTransaction();
catch(Exception ex)
System.err.println("Execute Exception>> " + ex.toString());
this.showError(res.getProperty("s_dlg_err_title"),res.getProperty("s_gen_exception"));
return false;
return false;
* Display error message inside oracle form
* @param title
* @param exceptionString
private void showError(String title, String exceptionString) {
JOptionPane.showMessageDialog(this, exceptionString, title, 0);
Edited by: peterv6i.blogspot.com on May 8, 2012 10:18 AM
Edited by: peterv6i.blogspot.com on May 8, 2012 10:20 AM
Edited by: peterv6i.blogspot.com on May 8, 2012 10:21 AM -
How to use java source in Oracle when select by sqlplus.
How to use java source in Oracle when select by sqlplus.
I can create java source in Oracle
import java.util.*;
import java.sql.*;
import java.util.Date;
public class TimeDate
public static void main(String[] args)
public String setDate(int i){
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(new Date((long)i*1000));
System.out.println("Dateline: "
+ calendar.get(Calendar.HOUR_OF_DAY) + ":"
+ calendar.get(Calendar.MINUTE) + ":"
+ calendar.get(Calendar.SECOND) + "-"
+ calendar.get(Calendar.YEAR) + "/"
+ (calendar.get(Calendar.MONTH) + 1) + "/"
+ calendar.get(Calendar.DATE));
String n = calendar.get(Calendar.YEAR) + "/" + (calendar.get(Calendar.MONTH) + 1) + "/" + calendar.get(Calendar.DATE);
System.out.print(n);
return n;
I have table name TEST
ID DATE_IN
1 942685200
2 952448400
When I write jsp I use method setDate in class TimeDate
The result is
ID DATE_IN
1 1999/11/16
2 2003/7/25
Thanks you very much.It is unclear where you are having a problem. Is your issue at runtime (when the form runs in the browser) or when working in the Builder on the form?
Also be aware that you will need to sign your jar and include some new manifest entries. Refer to the Java 7u51 documentation and blogs that discuss the changes.
https://blogs.oracle.com/java-platform-group/entry/new_security_requirements_for_rias
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html -
How can I code this in Oracle Forms?
I have a master-detail form. In the detail block, I have several records. Here is my name table.
ID Name_Type Name
1 old Mike
2 Current John
3 old Peter
4 old Andrew
I would like to create a button trigger which shall perform the following:
1) insert a record into database with a copy of current value. In the above case it will insert create a record for John as name_type = 'OLD'. So we have total of 5 records. Commit the transaction.
2) Scroll through my detail records (5) and go to one specific record and erase the values from it. In the above case, it should find John's record with name_type = 'Current' and erase John from it.
How can I accomplish this in Oracle forms using a button-pressed trigger?Hi,
Simple, using current values you can create new id , 'old' and name so oracle will create record, now refresh block, next using next_record in loop you can find record,erase one and refresh block.
Adinath Kamode
Maybe you are looking for
-
Whenever I try to render my sequences I get a "File Error: The specified file is open and in use by this or another application." And it halts my render until I click okay, which is a problem as I leave sequences to render overnight and they're not c
-
IPhone Calendar reminders sometimes are not shown
You can only hear the sound alert but nothing appears on the screen. Any suggestions? Thanks
-
IPhoto 6 slideshows not full screen!!!
First of all, as this problem has not changed since iPhoto 5.02 on OS X 10.3.9, let me provide you with some background... http://discussions.apple.com/thread.jspa?messageID=1425902� Now, let me detail the problem again. I have a Mac Mini 1.2
-
Hi m new in osb 10g.i want to incorporate error handler.when the endservice is responding error response i need to handle it by throwing custom error to the invoker of the service.can u pls guide me what are the steps i need to follow.i have error xs
-
Spinning beach ball and a restart
During the past two days, I've got three spinning beach balls that just won't quit. So I had to resort to pressing that little button on the fron of my G4 tower for a restart. After that, everything is back to normal. Each time it happened when tryin