Is it possible in java to pass reference of object in Java?

Hello,
I'm relativily new to Java but I have "solid" knowledge in C+ and C# .NET+.
Is it possible in java to pass reference of object in Java? I read some articles about weakreferences, softreferences, etc. but it seems that it's not what I'm looking for.
Here is a little piece of code I wrote:
package Software;
import java.util.Random;
* @author Rodrigue
public class RandomText
    private Random rand = new Random();
    private Thread t;
    private String rText = "Rodrigue";
    public RandomText()
        t = new Thread()
            @Override
            public void run()
                try
                    while(true)
                        UpdateText();
                        sleep(100);
                catch(InterruptedException ex)
        t.start();
    private void UpdateText()
        int i = rand.nextInt();
        synchronized (rText)
            rText = String.valueOf(i);
    public String GetText()
        return rText;
}It's just a class which start a thread. This class updates a text with a random integer 10 times per second.
I would like to get a reference on the String rText (like in C++ ;) yes I know, I must think in Java :D). So, like that, I could get one time the reference, thanks to the GetText function, and update the text when my application will repaint. Otherwise, I always have to call the GetText method ... which is slow, no?
Are objects passed by reference in java? Or, my string is duplicated each time?
Thank you very much in advance!
Rodrigue

disturbedRod wrote:
Ok, "Everything in Java is passed by value. Objects, however, are never passed at all.". Reference of object is passed by value too.
But, how to solve my problem in Java_? I have an object which is continually modified in a thread. From an another side, this object is continually repainted in a form.I'm not sure I totally understand your problem. If you pass a reference to an object, then both the caller and the method point to the same object. Changing the internal state of the object (e.g. by calling a setter method) through one reference will be observed through both references, since they both point to the same object.
No, calling a method is not particularly slow. Especially if it's just a simple getter method that returns the value of a member variable.
If this is happening in a multithreaded context, you'll have to use proper synchronization to ensure that each thread sees the others' changes.

Similar Messages

  • Java Portlet - Passing control to object outside renderBody

    Is there a problem passing control outside renderBody in a Java Servlet portlet.
    I get an error using the below, the portlet just stops. Its fine when I put the code inside renderBody:
    public class ObtainMap extends BaseManagedRenderer {
    public void renderBody(PortletRenderRequest pr) throws PortletException {
    pProcessMapRequest pPMR = new pProcessMapRequest();
    //Pass in the portal renderer
    pPMR.pr = pr;
    //call the main function
    pPMR.pProcessRequest();
    class pProcessMapRequest extends Object{
    Thanks...
    etc

    Does the log say which class can not be found?
    How have you added the pProcessMapRequest class to the CLASSPATH?

  • Passing array of objects from java to oracle.

    Hi,
    We have the following structure in oracle.
    We have a nested table type of varchar2(50).
    type var_tab is table of varchar2(50);
    We have one object type with one member as varchar2 and another one as var_tab type.
    type attribute_obj is object(
    attrib_name varchar2(100)
    ,attrib_val var_tab
    Then we have table type of that object type,
    type table_tab is table of attribute_obj;
    Then we have one object type with one member as varchar2,another member as integer and another one as table_tab type.
    type prod_obj is object(
    pr_name varchar2(100), tb_flag integer
    ,pr_attrib table_tab
    Then we have table type of this object type,
    type prod_tab as table of prod_obj;
    So, the total structure is something like this;
    'OS','OS_NAME', 'Windows'
    'Linux'
    'UNIX'
    'OS_VERSION','XP'
    'RED HAT'
    'SOLARIS'
    so, basically we have
    x prod_tab:=prod_tab();
    x(3):=prod_obj('OS',0,table_tab(attribute_obj('OS_NAME',var_tab('Windows','Linux','UNIX')),attribute_obj('OS_VERSION','XP','RED HAT','SOLARIS'))));
    And this how we call the procedure ---
    all_prod_comb_pkg.sp_main(x)
    The procedure deifinition is -
    procedure sp_main ( p_prod_arr prod_tab);
    Please suggest a way so that we can implement the same structure in Java and then call the procedure using that array of objects.
    regards,
    Dipankar.

    Dipankar,
    There's a separate example of how to map Oracle OBJECTs to JDBC STRUCTs.
    Study that one and combine the two. Not difficult (in my opinion :-)
    Or search the JDBC forum for the words "STRUCT" and "ARRAY".
    (What, you want me to do your coding for you?)
    Good Luck,
    Avi.

  • Passing reference to a function as a parameter?

    Is it possible to pass a reference to a function as a parameter to a function in Java? If so, how would I do this?

    banker2010 wrote:
    georgemc wrote:
    banker2010 wrote:
    georgemc wrote:
    banker2010 wrote:
    ner0 wrote:
    Is it possible to pass a reference to a function as a parameter to a function in Java? If so, how would I do this?how do you pass a reference? where did you get this idea?Where did you get the idea you couldn't? Not from the old "Java is pass-by-value" thing, I hope. Because references are indeed passed. By value. Think about itgeorge, doesnt the book say an address or a pointer is passed in? where did you get the idea that java passes references? NO! it does not! and nobody does! never!I said "think about it"
    Don't tell me, we're mocked by valoo or some such rubbishyeah, think! the bits that are passed in represent an address or a pointer, NOT a reference! who or what passes a reference!
    demock yourself!Bye bye, daffy

  • How to pass a file into a java method

    I am trying to pass a file into a java method so I can read the file from inside the method. How can I do this? I am confident passing int, char, arrays etc into methods as I know how to identify them in a methods signature but I have no idea how to decalre a file in a mthods signature. Any ideas please ?
    Thanks

    Hi,
    Just go thru the URL,
    http://www6.software.ibm.com/devtools/news1001/art24.htm#toc2
    I hope you will get a fair understanding of 'what is pass by reference/value'.
    You can pass Object reference as an argument.
    What Pablo Lucien had written is right. But the ideal situation is if you are not modifying the
    file in the calling method, then you can pass the String (file name) as an argument to the called method.
    Sudha

  • How to pass Objects from Java App to JavaFX Application

    Hello,
    New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.
    Any help is appreciated.
    Thanks
    I have my Java app calling my treeviewer JavaFX as
    -- Java Application --
    public class EPMFrame extends JFrame {
    Customer _custObj
    private void categoryAction(ActionEvent e)   // method called by Toolbar
            ocsCategoryViewer ocsFX;    //javaFX treeviewer
            ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.
                                                  // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value
    public class ocsCategoryViewer extends Application {
    String _customer;
    @Override
        public void start(Stage primaryStage) {
         TreeView <String> ocsTree;
         TreeItem <String> root , subcat;
      TreeItem <String> root = new TreeItem <String> ("/");
            root.setExpanded(true);
             ocsTree = new TreeView <String> (root);
             buildTree();     // this uses the Customer Object.
            StackPane stkp_root = new StackPane();
            stkp_root.getChildren().add(btn);
            stkp_root.getChildren().add(ocsTree);
            Scene scene = new Scene(stkp_root, 300, 250);
            primaryStage.setTitle("Tree Category Viewer");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            _customer = args[0];      // temporarily trying to pass in string.
            launch(args);

    JavaFX and Swing integration is documented by Oracle - make sure you understand that before doing further development.
    What are you really trying to do?  The answer to your question depends on the approach you are taking (which I can't really work out from your question).  You will be doing one of:
    1. Run your Swing application and your JavaFX application as different processes and communicate between them.
    This is the case if you have both a Swing application with a main which you launch (e.g. java MySwingApp) and JavaFX application which extends application which you launch independently (e.g. java MyJavaFXApp).
    You will need to do something like open a client/server network socket between the applications and send the data between them.
    2. Run a Swing application with embedded JavaFX components.
    So you just run java MySwingApp.
    You use a JFXPanel, which is "a component to embed JavaFX content into Swing applications."
    3. Run a Java application with embedded Swing components.
    So you just run java MyJavaFXApp.
    You use a SwingNode, which is "used to embed a Swing content into a JavaFX application".
    My recommendation is:
    a. Don't use approach number one and have separate apps written in Swing and Java - that would be pretty complicated and unwarranted for almost all applications.
    b. Don't mix the two toolkits unless you really need to.  An example of a real need is that you have a huge swing app based upon the NetBeans platform and you want to embed a couple of JavaFX graphs in there.  But if your application is only pretty small (e.g., it took less than a month to write), just choose one toolkit or the other and implement your application entirely in that toolkit.  If your entire application is in Swing and you are just using JavaFX because you think its TreeView is easier to program, don't do that; either learn how to use Swing's tree control and use that or rewrite your entire application in JavaFX.  Reasons for my suggestion are listed here: JavaFX Tip 9: Do Not Mix Swing / JavaFX
    c. If you do need to mix the two toolkits, the answer of which approach to use will be obvious.  If you have a huge Swing app and want to embed one or two JavaFX components in it, then use JFXPanel.  If you have a huge JavaFX app and want to embed one or two Swing components in it, use a SwingNode.  Once you do start mixing the two toolkits be very careful about thread processing, which you are almost certain screw up at least during development, no matter how an experienced a developer you are.  Also sharing the data between the Swing and JavaFX components will be trivial as you are now running everything in the same application within the virtual machine and it is all just Java so you can just pass data around as parameters to constructors and method calls, the same way you usually do in a Java program, you can even use static classes and data references to share data but usually a dependency injection framework is better if you are going to do that - personally I'd just stick to simply passing data through method calls.

  • Java programming language uses call by reference for objects?

    Is Java programming language uses call by reference for objects?

    Yes. You make calls to an object via itsreference.
    No.Yes, you're referring to passing a reference into a
    method in which case the value of the
    reference is passed.I believe the OP is using the term "call by reference" to mean "pass by reference." The two are interchangable, AFAIK. So, while "making calls to an object via its reference" is correct, I don't believe it's germane to the question.

  • Can we pass Reference cursor using dblink

    Can we pass reference cursor from one DB to another DB using DBlink?
    I feel like it is not possible because the memory structure of same will be available in other DB.
    Could you please let me know whether we can give a work around which will solve the issue.
    Regards,
    Balu

    Balu, cursor is a memory area which contains parsed SQL statement and everything needed for
    the execution of the SQL command. That, of course, is instance specific and carrying it over to another DB using db-link would make no sense whatsoever.

  • Java.lang.IllegalArgumentException: References to entities are not allowed

    Hi,
    I am using Berkely DB(native edition) 5.0.21 version. I have a couple classes as defined below:
    Class - 1:
    package bdb.test;
    import java.util.List;
    import com.sleepycat.persist.model.Entity;
    import com.sleepycat.persist.model.PrimaryKey;
    @Entity
    public class Employee {
         @PrimaryKey
         private String id ;
         private String name;
         private List<Employee> reportingManagers ;
         public String getId() {
              return id;
         public void setId(String id) {
              this.id = id;
         public String getName() {
              return name;
         public void setName(String name) {
              this.name = name;
         public List<Employee> getReportingManagers() {
              return reportingManagers;
         public void setReportingManagers(List<Employee> managers) {
              this.reportingManagers = managers;
    Class - 2 :
    package bdb.test;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    import java.util.List;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.persist.EntityStore;
    import com.sleepycat.persist.PrimaryIndex;
    import com.sleepycat.persist.StoreConfig;
         public class BDBTest{
              public static void main(String agrs[]){
                   Environment myEnv;
                   EntityStore store;
                   try {
                        EnvironmentConfig myEnvConfig = new EnvironmentConfig();
                        myEnvConfig.setCacheSize(30000);
                        StoreConfig storeConfig = new StoreConfig();
                        myEnvConfig.setAllowCreate(true);
                        myEnvConfig.setInitializeCache(true);
                        storeConfig.setAllowCreate(true);
                        try {
                        // Open the environment and entity store
                        myEnv = new Environment(new File("c:\\BDBTEST\\"), myEnvConfig);
                        store = new EntityStore(myEnv, "MyStore", storeConfig);
                        PrimaryIndex<String, Employee> primaryIndex = store.getPrimaryIndex(String.class, Employee.class);
                        // write Employee
                        Employee employee = buildEmployee("E1", "EMP1");
                        primaryIndex.putNoReturn(employee);
                   } catch (FileNotFoundException fnfe) {
                        System.err.println(fnfe.toString());
                        System.exit(-1);
                   } catch(DatabaseException dbe) {
                        System.err.println("Error opening environment and store: " +
                        dbe.toString());
                        System.exit(-1);
              public static Employee buildEmployee(String id,String name){
                   Employee employee = new Employee();
                   employee.setId(id);
                   employee.setName(name);
                   employee.setManagers(buildManager());
                   return employee;
              public static List<Employee> buildManager(){
                   List <Employee> managers = new ArrayList<Employee>();
                   Employee manager1 = new Employee();
                   manager1.setId("M111");
                   manager1.setName("Manager1");
                   Employee manager2 = new Employee();
                   manager2.setId("M222");
                   manager2.setName("Manager2");
                   managers.add(manager2);
                   return managers;
    While running the Class 2, I am getting the following exception :
    Exception in thread "main" java.lang.IllegalArgumentException: References to entities are not allowed: bdb.test.Employee
         at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:94)
         at com.sleepycat.persist.impl.ObjectArrayFormat.writeObject(ObjectArrayFormat.java:137)
         at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:114)
         at com.sleepycat.persist.impl.ReflectionAccessor$ObjectAccess.write(ReflectionAccessor.java:398)
         at com.sleepycat.persist.impl.ReflectionAccessor.writeNonKeyFields(ReflectionAccessor.java:258)
         at com.sleepycat.persist.impl.ReflectionAccessor.writeNonKeyFields(ReflectionAccessor.java:255)
         at com.sleepycat.persist.impl.ComplexFormat.writeObject(ComplexFormat.java:528)
         at com.sleepycat.persist.impl.ProxiedFormat.writeObject(ProxiedFormat.java:116)
         at com.sleepycat.persist.impl.RecordOutput.writeObject(RecordOutput.java:114)
         at com.sleepycat.persist.impl.ReflectionAccessor$ObjectAccess.write(ReflectionAccessor.java:398)
         at com.sleepycat.persist.impl.ReflectionAccessor.writeNonKeyFields(ReflectionAccessor.java:258)
         at com.sleepycat.persist.impl.ComplexFormat.writeObject(ComplexFormat.java:528)
         at com.sleepycat.persist.impl.PersistEntityBinding.writeEntity(PersistEntityBinding.java:103)
         at com.sleepycat.persist.impl.PersistEntityBinding.objectToData(PersistEntityBinding.java:83)
         at com.sleepycat.persist.PrimaryIndex.putNoOverwrite(PrimaryIndex.java:474)
         at com.sleepycat.persist.PrimaryIndex.putNoOverwrite(PrimaryIndex.java:449)
         at bdb.test.BDBTest.main(BDBTest.java:42)
    Question : In the above example reportingManagers is also a list of Employee classes. Can't I self reference a object with in the same object ? How do I store list of reportingManagers in this example? Any help is highly appreciated.
    Thanks,
    Bibhu

    Hi Sandra,
    Thanks for the reply.
    Is there any restrictions in Berkeley DB to store cyclic referencing objects?
    API documentation for Entity annotation talks about cyclic references in one of section but contradicts the same in another section. Please refer the link below:
    [ http://download.oracle.com/docs/cd/E17076_02/html/java/com/sleepycat/persist/model/Entity.html]
    Following sections of this documentation contradicts each other. I have highlighted both of them in bold.
    Other Type Restrictions:
    Entity classes and subclasses may not be used in field declarations for persistent types. Fields of entity classes and subclasses must be simple types or non-entity persistent types (annotated with Persistent not with Entity).
    If a field of an Entity needs to reference an object, the referenced object should be marked with @Persistent and not with @Entity. So, self referencing is not possible as the main class would have been marked with @Entity.
    Embedded Objects
    As stated above, the embedded (or member) non-transient non-static fields of an entity class are themselves persistent and are stored along with their parent entity object. This allows embedded objects to be stored in an entity to an arbitrary depth.
    There is no arbitrary limit to the nesting depth of embedded objects within an entity; however, there is a practical limit. When an entity is marshalled, each level of nesting is implemented internally via recursive method calls. If the nesting depth is large enough, a StackOverflowError can occur. In practice, this has been observed with a nesting depth of 12,000, using the default Java stack size. This restriction on the nesting depth of embedded objects does not apply to cyclic references, since these are handled specially as described below.
    Self referencing is possible.
    Object Graphs
    When an entity instance is stored, the graph of objects referenced via its fields is stored and retrieved as a graph. In other words, if a single instance is referenced by two or more fields when the entity is stored, the same will be true when the entity is retrieved. When a reference to a particular object is stored as a member field inside that object or one of its embedded objects, this is called a cyclic reference. Because multiple references to a single object are stored as such, cycles are also represented correctly and do not cause infinite recursion or infinite processing loops. If an entity containing a cyclic reference is stored, the cyclic reference will be present when the entity is retrieved.
    My question:
    In the above first highlighted section says to store a referenced/embedded object it needs be marked with @Persistent and not with @Entity annotation. That rules out storage of cyclic referencing object since the main object would have been already marked with @Entity annotation. The second section indicates having support for cyclic references.
    So, Is it possible to store cyclic referencing objects in BDB? if yes, how it should be done?
    Thanks,
    Bibhu
    Edited by: user12848956 on Jan 20, 2011 7:19 AM

  • Java is pass by value or pass by refrence

    Can any one explain whetherjava is pass by value or pass by refrence.

    Everything in Java is passed "by value". Everything.
    Pass-by-value
    - When an argument is passed to a function, the invoked function gets a copy of the original value.
    - The local variable inside the method declaration is not connected to the caller's argument; any changes made to the values of the local variables inside the body of the method will have no effect on the values of the arguments in the method call.
    - If the copied value in the local variable happens to be a reference (or "pointer") to an object, the variable can be used to modify the object to which the reference points.
    Some people will say incorrectly that objects are passed "by reference." In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory.... The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made through one reference variable are visible through the other. There is exactly one parameter passing mode -- pass by value -- and that helps keep things simple.
    -- James Gosling, et al., The Java Programming Language, 4th Edition
    [Pass-by-Value Please (Cup Size continued)|http://www.javaranch.com/campfire/StoryPassBy.jsp]

  • Passing information from applet  to  java script  of same browser

    Hi
    i want to pass some information from applet button click to same browser window html elements where applet exist. how it can be possible
    Thanks
    Dev

    Use JSObject:
    html file:
         <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                  height="0" width="0" >
            <param name="code" value="someApplet.class" />
            <!--[if !IE]> Mozilla/Netscape and its brethren -->
            <object classid="java:someApplet.class"
                    height="0" width="0"
                    mayscript=true>
            </object>
            <!-- <![endif]-->
          </object>
    <LABEL id="lblOutputText">This text is the HTML text </LABEL>applet
    // new class for jsObject!!!! compile this: javac -classpath "C:\Program Files\Java\jre1.5.0\lib\plugin.jar" someApplet.java
    // since jaws.jar does not exsist anymore
    // in 1.4.0 to compile: javac -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
    // for msjvm use the -source 1.3 -target 1.1 option so the command looks like this:
    // javac -source 1.3 -target 1.1 -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
    import netscape.javascript.*;
    public class someApplet extends java.applet.Applet {
        JSObject win;
        public void init() {
             try{
                 win = JSObject.getWindow(this);
    // you need win.eval("window.close();"); // to close the window. if the current window is not a popup
    // opened by a parent with window.open than the user will get a waring, your next question probably will
    // be "can I stop this warning" and the answer is simple: NO
                 JSObject textBoxLabel = (JSObject) win.eval("document.getElementById('lblOutputText')");
                 textBoxLabel.setMember("innerHTML", "<center><h1>Some text from applet</h1></center>");
            }catch(Exception e){
                 e.printStackTrace();
    }

  • Problem in passing values from AS to Java

    Hi,
    I am using Remote Object(Flex 3) for passing the data
    between java and flex. I am using the BlazeDS as the bridge. I have
    to pass an array collection containing value objects to the java
    method. I have created the value object in both the client side(AS)
    and server side (java) and registered my AS value object using
    [RemoteClass(alias="class name")]. Now the problem is the
    array collection is goinhg to the back end but when i try to get
    the values in the value objects using the corresponding getters, i
    am getting null values. Can some one suggest me the solution.
    Following is my AS value object
    package ascript
    [RemoteClass(alias="com.category.dao.CatgVO")]
    public class CatgVO
    private var catg_id:String;
    private var parent_catg_id:String;
    private var catg_name:String;
    private var catg_desc:String;
    private var created_by:String;
    private var created_date:String;
    private var catg_status:String;
    private var blooper:String;
    private var catg_modifieddate:String;
    private var catg_modifieduserid:String;
    * @return the catg_id
    public function getCatg_id():String {
    return catg_id;
    * @param catg_id the catg_id to set
    public function setCatg_id(catg_id:String):void {
    this.catg_id = catg_id;
    * @return the parent_catg_id
    public function getParent_catg_id():String {
    return parent_catg_id;
    * @param parent_catg_id the parent_catg_id to set
    public function setParent_catg_id(parent_catg_id:String):void
    this.parent_catg_id = parent_catg_id;
    * @return the catg_name
    public function getCatg_name():String {
    return catg_name;
    * @param catg_name the catg_name to set
    public function setCatg_name(catg_name:String):void {
    this.catg_name = catg_name;
    * @return the catg_desc
    public function getCatg_desc():String {
    return catg_desc;
    * @param catg_desc the catg_desc to set
    public function setCatg_desc(catg_desc:String):void {
    this.catg_desc = catg_desc;
    * @return the created_by
    public function getCreated_by():String {
    return created_by;
    * @param created_by the created_by to set
    public function setCreated_by(created_by:String):void {
    this.created_by = created_by;
    * @return the created_date
    public function getCreated_date():String {
    return created_date;
    * @param created_date the created_date to set
    public function setCreated_date(created_date:String):void {
    this.created_date = created_date;
    * @return the catg_status
    public function getCatg_status():String {
    return catg_status;
    * @param catg_status the catg_status to set
    public function setCatg_status(catg_status:String):void {
    this.catg_status = catg_status;
    * @return the blooper
    public function getBlooper():String {
    return blooper;
    * @param blooper the blooper to set
    public function setBlooper(blooper:String):void {
    this.blooper = blooper;
    * @return the catg_modifieddate
    public function getCatg_modifieddate():String {
    return catg_modifieddate;
    * @param catg_modifieddate the catg_modifieddate to set
    public function
    setCatg_modifieddate(catg_modifieddate:String):void {
    this.catg_modifieddate = catg_modifieddate;
    * @return the catg_modifieduserid
    public function getCatg_modifieduserid():String{
    return catg_modifieduserid;
    * @param catg_modifieduserid the catg_modifieduserid to set
    public function
    setCatg_modifieduserid(catg_modifieduserid:String):void {
    this.catg_modifieduserid = catg_modifieduserid;
    Regards
    Kranthi

    Hi there. That's a perfectly reasonable question.
    Take a look at the section of the Flex documentation with the title "Explicitly mapping ActionScript and Java objects" in the Data Access section of the doc.
    http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_4.html
    Your BananaVO ActionScript class needs a RemoteClass metadata tag that will tell the AMF deserialization code on the server what Java class to map the object to.
    Hope that helps.
    -Alex

  • How to pass a refcursor to a java stored proc

    Hi all,
    Please forgive me as I am new to Java and JDeveloper....
    I want to pass a refcursor to a java stored proc. Does anyone know how to accomplish this?
    Thanks,
    dayneo

    Hi,
    As Avi has indicated, you can map ref cursor to java.sql.ResultSet
    here are Call Specs and a code snippet from chapter 3 in my book.
    procedure rcproc(rc OUT EmpCurTyp)
    as language java
    name 'refcur.refcurproc(java.sql.ResultSet[])';
    function rcfunc return EmpCurTyp
    as language java
    name 'refcur.refcurfunc() returns java.sql.ResultSet';
    * Function returning a REF CURSOR
    public static ResultSet refcurfunc () throws SQLException
    Connection conn = null;
    conn = DriverManager.getConnection("jdbc:oracle:kprb:");
    ((OracleConnection)conn).setCreateStatementAsRefCursor(true);
    Statement stmt = conn.createStatement();
    ((OracleStatement)stmt).setRowPrefetch(1);
    ResultSet rset = stmt.executeQuery("select * from EMP order by empno");
    // fetch one row
    if (rset.next())
    System.out.println("Ename = " + rset.getString(2));
    return rset;
    Kuassi

  • Passing array of Types to java class

    I am trying to pass a user defined type (that is an array) from PL/Sql to a javaclass. Here are the definitions that make-up the parameter to pass from PL/Sql to Java (uri_digest_array):
    CREATE OR REPLACE TYPE uri_digest as object (uri VARCHAR2(256),
    digest_value CLOB);
    CREATE OR REPLACE TYPE uri_digest_array AS VARRAY(10) OF uri_digest;
    In Oracle-land, java classes are published to PL/Sql by way of the following definition. Note that the intent here is to have compatible data-types.
    CREATE OR REPLACE FUNCTION SIGNRETURNINGXML (p_array IN uri_digest_array)
    RETURN LONG
    AS LANGUAGE JAVA
    NAME 'SignReturningXml.main(oracle.sql.Array) return java.lang.String';
    Here is a fragment of the java class code:
    class SignReturningXml {
    public static String main(String [] [] signItems ) // I have no idea what datatype to use here!
    { . . . . The code in here would process the passed array normally from first entry to last.
    Currently I get the following error:
    PLS-00311: the declaration of
    "SignReturningXml.main(oracle.sql.Array) return
    java.lang.String" is incomplete or malformed
    I could use some suggestions on resolving the datatype conflicts. Any ideas? Has anyone tried this kind of thing?
    Thanks,
    Michael

    Michael,
    At the risk of another [non] useful response, I meant that you should try searching the "Ask Tom" Web site, because usually you will find an answer to your question that has already been asked by someone else. Perhaps these will be helpful:
    [url=http://asktom.oracle.com/pls/ask/f?p=4950:8:1320383202207153292::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:8908169959941
    ]Can I Pass a nested table to Java from a pl/sql procedure
    [url=http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:712625135727
    ]passing arrays into pl/sql stored procedures
    Good Luck,
    Avi.

  • Is it possible to use 32-bit firefox with 64-bit java plugin?

    Is it possible to use 32-bit firefox with 64-bit java plugin?
    I'd like to use 32-bit firefox and I already install 64-bit java plugin.
    Is that a right choice not to install 32-bit java plugin?
    Will these cause problem?
    Thanks in advance.
    Regards,
    Sean

    Nope - you need the 32bit Java to go with the 32bit Firefox if you want Java to run

Maybe you are looking for

  • Saving file to database

    Hello i am designing a website for my company  so my clients can easily view project reports and progress. i want to create a database that will allow me to upload updated drawing files and provide a download link and description so my clients can do

  • Save physical channel information in a configuration file and reuse it in another VI

    Dear all, I would like to do a pair of VIs. The first VI configures all psychical channels and store the task information (or physical channel name information) in a file and the second VIs can access this file and use the saved information. Can anyb

  • Adding a background window

    I have a JFrame with a set size that now needs to have the possibility to be maximized. BUT, I want to keep the size used previously. Ie I want to put the present window into a new window with the proportions and restrictions kept. I'll try to descri

  • Lost itunes music and forgotten password

    I had an ipod classic and had my home broken into and that was taken along with all my music i had purchased. I had forgotten my password and did not have it saved so my question is what happens to all that music i had paid for?

  • 7985 Video Phone Logo Background Replacement

    I need to place or replace select different our Company's Logo with the initial Cisco Logo to the Video Phone 7985, anyone to help me to know the Screen Size of 7985 and the corresponding Script.