Save a java class instance in Oracle
Hi,
I would like to save a java object into an oracle table in order to use it later.
Can you tell me if it is possible?
thanks in advance.
Michael.
you have to place the java class in BLOB, and read it in and out as a pure binary file....... buth otherwise it should be possible
Similar Messages
-
Binding a JavaFX variable to a Java class instance variable
Hi,
I am pretty new to JavaFX but have been developing in Java for many years. I am trying to develop a JavaFX webservice client. What I am doing is creating a basic scene that displays the data values that I am polling with a Java class that extends Thread. The Java class is reading temperature and voltage from a remote server and storing the response in an instance variable. I would like to bind a JavaFx variable to the Java class instance variable so that I can display the values whenever they change.
var conn: WebserviceConnection; // Java class that extends Thread
var response: WebserviceResponse;
try {
conn = new WebserviceConnection("some_url");
conn.start();
Thread.sleep(10000);
} catch (e:Exception) {
e.printStackTrace();
def bindTemp = bind conn.getResponse().getTemperature();
def bindVolt = bind conn.getResponse().getVoltage();
The WebserviceConnection class is opening a socket connection and reading some data in a separate thread. A regular socket connection is used because the server is not using HTTP.
When I run the application, the bindTemp and bindVolt are not updated whenever new data values are received.
Am I missing something with how bind works? Can I do what I want to do with 'bind'. I basically want to run a separate thread to retrieve data and want my UI to be updated when the data changes.
Is there a better way to do this than the way I am trying to do it?
Thanks for any help in advance.
-RichardHi,
If you don't want to constantly poll for value change, you can use the observer design pattern, but you need to modify the classes that serve the values to javafx.
Heres a simple example:
The Thread which updates a value in every second:
// TimeServer.java
public class TimeServer extends Thread {
private boolean interrupted = false;
public ValueObject valueObject = new ValueObject();
@Override
public void run() {
while (!interrupted) {
try {
valueObject.setValue(Long.toString(System.currentTimeMillis()));
sleep(1000);
} catch (InterruptedException ex) {
interrupted = true;
}The ValueObject class which contains the values we want to bind in javafx:
// ValueObject.java
import java.util.Observable;
public class ValueObject extends Observable {
private String value;
public String getValue() {
return this.value;
public void setValue(String value) {
this.value = value;
fireNotify();
private void fireNotify() {
setChanged();
notifyObservers();
}We also need an adapter class in JFX so we can use bind:
// ValueObjectAdapter.fx
import java.util.Observer;
import java.util.Observable;
public class ValueObjectAdapter extends Observer {
public-read var value : String;
public var valueObject : ValueObject
on replace { valueObject.addObserver(this)}
override function update(observable: Observable, arg: Object) {
// We need to run every code in the JFX EDT
// do not change if the update method can be called outside the Event Dispatch Thread!
FX.deferAction(
function(): Void {
value = valueObject.getValue();
}And finally the main JFX code which displays the canging value:
// Main.fx
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import threadbindfx.TimeServer;
var timeServer : TimeServer;
var valueObjectAdapter : ValueObjectAdapter = new ValueObjectAdapter();
timeServer = new TimeServer();
valueObjectAdapter.valueObject = timeServer.valueObject;
timeServer.start();
Stage {
title: "Time Application"
width: 250
height: 80
scene: Scene {
content: Text {
font : Font {
size : 24
x : 10, y : 30
content: bind valueObjectAdapter.value;
}This approach uses less cpu time than constant polling, and changes aren't dependent on the polling interval.
However this cannot be applied to code which you cannot change obviously.
I hope this helps. -
In which directory should i keep java class files in oracle apps
hi
I have one problem, In which Top & directory should i keep java class files in oracle apps
krishnaHi
By itself its available in oracle\visappl\au\11.5.0\java\
thats were the location needs to be placed in the apps.zip.
Thanks
Riyas -
Calling a java class in my oracle database from a oracle stored procedure
my oracle stored procedure is:
create or replace
PROCEDURE openpdffile
AS LANGUAGE JAVA
NAME 'pdfopenbook.mainbook()';
it is valid and so is this java class;
import java.sql.*;
import oracle.jdbc.*;
public class pdfopenbook //class pdfopen
public static void mainbook(String args[]) //main function
try //try statement
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "c:\\temp
final_book.pdf");
// Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "sol.exe");
} catch (Exception e) //catch any exceptions here
System.out.println("Error" + e ); //print the error
but i get the error:
onnecting to the database caprs.
ORA-29531: no method mainbook in class pdfopenbook
ORA-06512: at "CAPRS.OPENPDFFILE", line 1
ORA-06512: at line 2
Process exited.
Disconnecting from the database caprs.
it says there is no mainbook method but there is, what am i doing wrong??
Thanks,
DougPass String[] as an argument to mainbook():
create or replace PROCEDURE openpdffile
AS LANGUAGE JAVA
NAME 'pdfopenbook.mainbook(java.lang.String[])';Have you posted it on the Database forum?
Regards,
Nick -
Java class integration with Oracle Identity Manager 9.1.0.2
Hello Friends,
I have a java class that is responsible for sending notifications, my question is how do the relationship of this class with the Oracle Identity Manager 9.1.0.2 so you can take the class and notify users when an application is approved or rejected.
Any recommendation for this process.
Thanks for the support
Edited by: JLK on Jun 12, 2012 5:20 PMHi
Java class integration with OIM happen through concept of adapters. You can go through OIM documentation of how to create adapters.
In your case you should create a process task adapetrs adn attach it on the Approved response code in your approval process.
Desingn Console --> Process management --> Process definition --> <Apprlication Process Ex: AD User>.
Alternatively you can also send notification using OIM OOTB email templates.
Regards
user12841694 -
Calling a java class from an oracle stored procedure
my oracle stored procedure is:
create or replace
PROCEDURE openpdffile
AS LANGUAGE JAVA
NAME 'pdfopenbook.mainbook()';
it is valid and so is this java class;
import java.sql.*;
import oracle.jdbc.*;
public class pdfopenbook //class pdfopen
public static void mainbook(String args[]) //main function
try //try statement
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "c:\\temp\\final_book.pdf");
// Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "sol.exe");
} catch (Exception e) //catch any exceptions here
System.out.println("Error" + e ); //print the error
but i get the error:
onnecting to the database caprs.
ORA-29531: no method mainbook in class pdfopenbook
ORA-06512: at "CAPRS.OPENPDFFILE", line 1
ORA-06512: at line 2
Process exited.
Disconnecting from the database caprs.
it says there is no mainbook method but there is, what am i doing wrong??
Thanks,
Doughttp://wiki.answers.com/Q/Can_you_call_a_java_function_from_an_oracle_stored_procedure
-
Java Class path for Oracle package compilation
Hello
I am trying to send mail with file attachment, this part is
done by java program, it is compiled & working fine.
I am trying to compile the same java program at SQL prompt so
that I can build a package to execute that Java program from
Oracle. As java prog requires other class files
(javax.mail.*,javax.mail.internet.*,javax.activation.*) to be
include , those class path is set at their respective location
of OS.
Other Java programs are compiling fine from SQL but for this
mail prog, it is giving error as it is not finding the location
of the include files.
Can anyone tell me from which class path does Oracle 8i compiles
Java program ? any additional information reqdng this issue ?
thanksHello Suresh Vemulapalli
Thanks for replay & suggestion, I compiled using loadjava on
OS & it is working fine
regards
Prakash K.B. -
How to Return ten records into java class by using oracle stored procedure
Hello sir/Friends
There is a procedure that returns 10 records from the oracle table and i want to display all 10 records into the table in java class.
Please reply
Thanking you.When you execute the stored procedure it will return your results as a ResultSet. Iterate over itto get the values you need then do with them as you please.
List<MyObject> results = new ArrayList<MyObject>();
MyObject mo = null;
ResultSet rs = stmt.executeQuery("SELECT a_value FROM a_table");
while (rs.next())
mo = new MyObject();
mo.setValue(rs.getString(1));
results.add(mo);
} -
Java Class Instance Referencing Question...
Perhaps i worded that title poorly, but this is what I am talking about...
This is an example, much simpler than what i am working on.
class Alive(){
public boolean alive;
public Alive(){
alive = true;
public kill(){
alive = false;Now let us say that I want two things to reference this...let us just assume that class person has an instance of class Alive in it called living;
Person x, y;
x.living = new Alive();
y.living = x.living;
y.living.kill();is x dead? in other words, did changing the status if y.living after saying it was equal to x.living alter x.living? If not, is it possible to do this?You only have one instance of Alive, but multiple References. By calling the kill method you are killing the alive on both x and y. Because it is the same Alive object.
-
Unable to get database connection from loaded java class in oracle
Hi all,
I am trying to call java class method from oracle function, but getting below exception, while creating connection.
SQL> select charge_calculation(1,'2011-06-01', 'E') from dual;
select charge_calculation(1,'2011-06-01', 'E') from dual
ERROR at line 1:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.ExceptionInInitializerError
inside main method
inside main method1
inside main method2
inside main method3
inside main method3
Exception in thread "Root Thread" java.lang.ExceptionInInitializerError
at javax.crypto.Cipher.getInstance(DashoA12275)
at oracle.security.o5logon.O5LoginClientHelper.decryptAES(Unknown Source
at oracle.security.o5logon.O5LoginClientHelper.generateOAuthResponse(Unk
nown
Source)
at
oracle.jdbc.driver.T4CTTIoauthenticate.marshalOauth(T4CTTIoauthenticate.java)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:367)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
501)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
at
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
at java.sql.DriverManager.getConnection(DriverManager.java)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at SPEodPricing.spEodPricing(SPEODPRICING:98)
at SPEodPricing.main1(SPEODPRICING:47)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.SunJCE_b.<clinit>(DashoA12275)
... 13 more
Caused by: java.security.PrivilegedActionException: java.io.IOException
at java.security.AccessController.doPrivileged(Native Method)
... 14 more
Caused by: java.io.IOException
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java)
at sun.net.www.protocol.jar.URLJarFile$1.run(URLJarFile.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:165)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:43)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.ja
va:102)
at
sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:1
24)
at javax.crypto.SunJCE_d.a(DashoA12275)
at javax.crypto.SunJCE_b.g(DashoA12275)
at javax.crypto.SunJCE_b.e(DashoA12275)
at javax.crypto.SunJCE_q.run(DashoA12275)
... 15 more
SQL> select charge_calculation(1,'2011-06-01', 'E') from dual;
select charge_calculation(1,'2011-06-01', 'E') from dual
ERROR at line 1:
ORA-29549: class BBVA_MERGED.SPEodPricing has changed, Java session state
cleared
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64
bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
JAVA Sample code:-
public String method1(int pi_ctry_id,String pi_cur_busi_date ,String pi_eod_bod_flag)
System.out.println("inside main method1");
CachedRowSet tmplcrs = null;
HashMap resMap = new HashMap();
Double ln_candidate_extra = 0.0;
Double ln_calculate_on_val = 0.0;
int lv_calculate_on = 0;
int lv_cand_attribute = 0;
// int pi_ctry_id = 0;
// String pi_cur_busi_date = null;
int pi_bch_id = 0;
// String pi_eod_bod_flag = null;
Date ldt_cur_busi_date = null;
Date lstr_next_calc_date = null;
int li_bch_id = 0;
int li_chg_ac_branch = 0;
int calFrequency = 0;
DbUtils dbObj = new DbUtils();
Map reqMap = new HashMap();
CachedRowSet updtcrs = null;
Connection conn = null;
try
System.out.println("inside main method2");
reqMap.put("pi_ctry_id", ""+pi_ctry_id);
reqMap.put("pi_cur_busi_date", ""+pi_cur_busi_date);
reqMap.put("pi_eod_bod_flag", ""+pi_eod_bod_flag);
System.out.println("inside main method3");
Class.forName("oracle.jdbc.driver.OracleDriver");
// Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@10.1.56.85:1521:orcl", "bbva_merged", "bbva_merged");
// conn = DriverManager.getConnection("jdbc:oracle:thin:@10.1.50.104:1521:cmsdb6", "bbva_base", "bbva_base");
System.out.println("inside main method3");
conn = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.50.129)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.50.130)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = BBVASIT)))", "BBVA_MERGED", "BBVA_MERGED");
conn.setAutoCommit(false);
System.out.println("inside main method4");
}29532, 00000, "Java call terminated by uncaught Java exception: %s"
// *Cause: A Java exception or error was signaled and could not be
// resolved by the Java code.
// *Action: Modify Java code, if this behavior is not intended. -
Hello experts,
I am new in oracle forms.I am using oracle forms 11g with weblogic 10.3.5 at windows 7.Someone please clear me that the injection of java programing in oracle forms is through BEANS item only or I can use it(java class) as a part of my oracle forms.I mean I have a Java class.Could I use this java class inside my oracle forms without using Beans Item.
Thank You
regards
aaadityaIn forms you can use java in two different ways
1. On the client-side. Using java-beans you can extend the client-functionality of forms. The code will run on the client-computer in the context of the applet.
2. On the server-side. Using the java-importer you can build a PL/SQL-wrapper around a java-class and so use the java-code in your forms-PL/SQL
What is your reuqirement? -
Generate Java class from Oracle Type defined in Package w/ JPublisher
I was wondering if its possible to generate a Java class for an Oracle Type defined in a Package? I know passing the package name to JPublisher (SQL <package_name>) causes all Oracle Types in the Package to have a Java class generated for them but I'd like to be able to do this for an individual Type defined in a Package (something like SQL <package_name>.<type_name>).
Thanks for any information you can give me.Hi Marinel,
The support for XSD import is limited on 10.1.2. If you can, you should consider moving to the 10.1.3 preview as the support for document style web services has improved. The other option will be to inline the schema in your WSDL.
Eric. -
Problem when loading simple java class in Oracle
Hi,
I am using loadjava to load the java class in the oracle database. But it is failing. Can some one please help me out with this.
Command.
loadjava -thin -user username/password@zrtph0ja:1521:database -resolve firstProcedure.class
Errors:
Error while computing shortname of firstProcedure
ORA-06550: line 1, column 13:
PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error while computing shortname of firstProcedure
ORA-06550: line 1, column 13:
PLS-00201: identifier 'DBMS_JAVA.SHORTNAME' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-29521: referenced name java/io/PrintStream could not be found
ORA-29521: referenced name java/lang/Object could not be found
ORA-29521: referenced name java/lang/String could not be found
ORA-29521: referenced name java/lang/StringBuffer could not be found
ORA-29521: referenced name java/lang/System could not be found
loadjava: 7 errors
Please help.
Regards
Sudhir
nullU havent installed JServer in ur DBMS.
Read the Oracle 8i JServer Manual for
manually installing the Oracle JVM. -
Error loading a java class to oracle db
hi,
my oracle server: 8i Enterprise Edition Release 8.1.7.0.0
i want to load a simple java class into my oracle server.
java source:
public class Ping
java.lang.String server;
public static void main(java.lang.String[] args)
System.out.println(new Ping().runCmd(args[0]));
public static java.lang.String runCmd(String cmd)
boolean result=false;
int timeout=5000;
try {
java.net.InetAddress byName=java.net.InetAddress.getByName(cmd);
result=byName.isReachable(timeout);
catch(java.io.IOException e)
e.printStackTrace();
java.lang.String retVal=java.lang.Boolean.toString(result);
return retVal;
after compiling the java file. i'm using loadjava at dos prompt.
loadjava -user uname/pwd@db -resolve Ping.class
this command results in
ORA-29545: badly formed class:
loadjava: 1 errors
alternatively i had used a command
loadjava -user uname/pwd@db -noverify -resolve Ping.class
this command results in
Error while turning off verifier
ORA-29532: Java call terminated by uncaught Java exception: java.security.Ac
cessControlException: the Permission (oracle.aurora.security.JServerPermission V
erifier ) has not been granted by dbms_java.grant_permission to SchemaProtection
Domain(SMSPGS|PolicyTableProxy(SMSPGS))
ORA-29545: badly formed class:
loadjava: 2 errors
but user is having sufficient rights (javasyspriv)
what is wrong above, please help me.
regards,
s.mohamed asifhi,
thanks for your response
Ping.class just checks whether the specified node is reachable or not.
result=byName.isReachable(timeout);
the jdk loaded in oracle DB is older one and the method above java.net.InetAddress.isReachable(java.lang.int) is available since
jdk 1.5
source:
public class Ping
java.lang.String server;
public static void main(java.lang.String[] args)
System.out.println(new Ping().runCmd(args[0]));
public static java.lang.String runCmd(String cmd)
boolean result=false;
int timeout=5000;
try {
java.net.InetAddress byName=java.net.InetAddress.getByName(cmd);
result=byName.isReachable(timeout);
catch(java.io.IOException e)
e.printStackTrace();
java.lang.String retVal=java.lang.Boolean.toString(result);
return retVal;
}how to load the new jdk set into existing oracle db server and replace the existing jdk.
what can be done to achieve this ?
regards,
s.mohamed asif -
Is there a way to create a Java class based on what's defined in a schema?
I have a set of schemas that define what messages I will get as an XML stream (sent as UDP packets). Is there a way to parse the schemas into a set of java classes that match the fields in the schema? If so, next think would be to feed a string or byte array to instances of these objects and have a method that parses it and fills all the fields. But is the first part possible? Somebody linked http://www.cafeconleche.org/books/xmljava/chapters/ in another thread, but that seems to be for regular XML, not schema, unless I'm confused which is entirely possible, I'm new to XML and using it in Java in this way.
For future reference, [Java API for XML Binding|http://www.dummies.com/WileyCDA/DummiesArticle/Building-Custom-Code-with-Java-API-for-XML-Binding-JAXB-.id-1489,subcat-BUILDING.html] (JAXB) allows for [generation of Java classes|http://www.oracle.com/technology/pub/articles/marx-jse6.html] from XML Schema (or even DTD) using its xjc compiler.
Maybe you are looking for
-
How to run Microsoft Office on MacBook Pro
I need to run Microsoft Office on MacBook Pro. What are my available options?
-
What is the replacement of operation MESSG in ECC 6.0.
Dear Team: Version: 4.6C upgraded to ECC 6.0. In a rule, we had an operation MESSG but this is not supporting in ECC 6.0. When we click on Check the Rule, showing a message as "Operation has not been entered in table 52A0". If changed, please let me
-
SSL for Apex 4.0 with PL/SQL Embedded Gateway
Hello I'm trying to implement ssl to already installed apex 4.0. Os version: Red Hat Enterprise Linux Server release 5.5 (Tikanga) Oracle Database 11.2.0.3 I used the following note to configure ssl for apex: http://wiki.shellprompt.net/bin/view/Apex
-
How work Authorization Group in cv02n ?
Dear Gurus i would like to know how i can use the Authorization Group in cv02n? Is possible use this objcet in order to enable the some user to change document data ? Thanks a lot Daniele
-
I have a new computer now with windows 8. Old one was windows 7. The itunes library contains all I expect on new computer. Ipod will not sync with content. It says it is syncing but only picks up 1 tune. Solution please. I am on itunes 64 but it make