-
how to invoke a java program from forms 6i
Hi !
I have a java program that I need to call from the click of a button on the form. The form is being developed on Forms 6i. I am not a java programmer hence dont know how to create a bean out of this program and invoke it. the program is given below. Is there anyone who can help me on this?
Thanks in Advance
Amit
Code to be called
=================
import java.io.*;
import java.lang.*;
import java.sql.*;
import java.util.*;
import oracle.jdbc.driver.*;
public class loadblob {
public static void main(String[] argv) {
if (argv.length < 4) {
System.out.println
("Arguments: ");
System.exit(1);
}
try {
// Grab all the parameters
long id = Long.valueOf(argv[0]).longValue();
String name = argv[1];
long type = Long.valueOf(argv[2]).longValue();
FileInputStream is = new FileInputStream(argv[3]);
// Register an oracle JDBC driver, connect, and disable auto-commit
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci8:@oaxaca","scott","tiger");
conn.setAutoCommit(false);
String sql = "begin " +
"insert into lobtest(id,data) values (?,empty_blob()) "+
"return data into ?; "+
"end;";
OracleCallableStatement ocs =
(OracleCallableStatement) conn.prepareCall(sql);
ocs.setLong(1, id);
ocs.registerOutParameter(2, OracleTypes.BLOB);
ocs.executeUpdate();
OutputStream os = (ocs.getBLOB(2)).getBinaryOutputStream();
// Transfer the data from the file to the blob via the lob locator
byte buffer[] = new byte[1024];
int length;
while ((length = is.read(buffer, 0, 1024)) != -1) {
os.write(buffer, 0, length);
}
// Close up shop...
is.close();
os.close();
ocs.close();
conn.commit();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|