Is it possible to pass a string representing a class name in java as an arg

Hi, this is probably a bit of a stupid question, but one that has me quite confused all the same!
Is it possible to pass a string or class name etc. representing a type of class in java, to a method so that instead of having to redefine a method with say the following args:
public SolarPanels[] bestPVPanels(int budget, int percent) {
        HashMap<Integer, SolarPanels> panelsMap    = new HashMap<Integer, SolarPanels>();
}As at present needing to create a methods bestWindTurbine() and many others exactly the same, but for the type, I would instead like to be able to create a method like:
public Object[] bestRenewable(int budget, int percent, String aClassName) {
        HashMap<Integer, aClassName > renewableMap    = new HashMap<Integer, aClassName >();
}But cant sus how to do this as passing a String is off course going to cause problems unless its it possible to cast a string to a class name, any help or advance would be much appreciated.
Thanks in advance
Pat Nevin

pNev wrote:
But cant sus how to do this as passing a String is off course going to cause problems unless its it possible to cast a string to a class nameIt's not. You can do things like
Class.forName(classNameInString);But that will only return a Class object.
And as Java generics are erased at runtime, passing the class name to the method is useless as it is too late to use it anyways.
Ah, Peter's way is what I was thinking of. Too early in the morning.
Edited by: Kayaman on 23.6.2010 10:02

Similar Messages

  • Is it possible to pass a string from an applet to the web site?

    Hi, everybody!
    Is it possible to pass a String from an applet to a web site (as a field value in a form, an ASP variable, or anything else). Basically, I have a pretty large String that is being edited by an applet. When a user clicks on the submit button, a different page will show up which has to display the modified string. The String is pretty large so it doesn't fit into the URL variable.
    Please, help!
    Thank you so much!

    Why do you want to do this in Java?
    Javascript is the correct language for these type of situations.
    for instance:
    in the head of your html document:
    <script language=javascript type="text/javascript">
    createWindow(form){
    if(form.text.value!=""){
    newDoc = new document
    newDoc.write(form.text.value)
    newWin = window.open(document,'newWin','width=200;height=150')
    </script>
    in the body:
    <form onSubmit="createWindow(this)">
    <p>
    Enter a String:<input type=text size=30 name="text">
    </p><p>
    <input type=submit value="submit"> 
    <input type=reset value="reset">
    </p>
    </form>

  • How to convert a String variable as class name and method name?

    i have two classes
    class Student
    public String insertStudent(String sname)
    { return("Student has been inserted ");     }
    class Teacher
    public String execute(String methodName, String className)
    {  //return statement of the method 'insertStudent' in the class 'Student'; }
    }Now, i have a class with the main method. Here, i would like to call the method *'insertStudent'* of class *'Student'*
    using the method *'execute'* of class *'Teacher',* passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Can anyone please help me out. Thanks
    regards,
    chinglai

    You should have just added that as a comment on your [initial posting|http://forums.sun.com/thread.jspa?threadID=5334953] instead of starting a new thread.
    Now, i have a class with the main method. Here, i would like to call the method 'insertStudent' of class 'Student'using the method 'execute' of class 'Teacher', passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Why oh why? What do you want to achieve?
    Let me tell you: there is a way to do what you try to do, but it's not recommended and should be used only very sparingly. Especially not in anything like your code, that resembles normal business logic (as opposed to an application framework such as Spring, for example).
    Can you explain what exactly you want to do with that? Why should a Teacher be able to call any random method ony any other class. And what good would that do?

  • How to Pass a String as a MovieClip Name?

    Hi everyone! I'm back with more doubts
    I created 4  buttons with 4 animations each, one for each state (using tweens), so I  have that imense list of 16 "addEventListeners" (don't know if there's  another way to do it). But everything is working as I would like.
    The  problem is that I'm trying to create only 4 functions to take care of  all the 4 buttons and those 16 eventListeners.
    This is  part of my AS3 file (still with the "traces", 5 secs of animation to  check the animations and all).
    empresa_btn.addEventListener(MouseEvent.MOUSE_OVER, isOver);
    empresa_btn.addEventListener(MouseEvent.MOUSE_OUT, isOut);
    empresa_btn.addEventListener(MouseEvent.MOUSE_DOWN, isDown);
    empresa_btn.addEventListener(MouseEvent.MOUSE_UP, isUp);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_OVER, isOver);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_OUT, isOut);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_DOWN, isDown);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_UP, isUp);
    var mouseState:String;
    var mouseActive:String;
    var txt:String;
    empresa_btn.over.alpha = 0; empresa_btn.down.alpha = 0;
    parceiros_btn.over.alpha = 0; parceiros_btn.down.alpha = 0;
    function isOver (e:MouseEvent):void {
         mouseActive = e.currentTarget.name;
         mouseState = "isOver";
         trace (mouseActive + " " + mouseState);
         var isOver:Tween = new Tween(empresa_btn.over, "alpha", Strong.easeOut, empresa_btn.over.alpha, 1, 5, true);
    function isOut (e:MouseEvent):void {
         mouseActive = e.currentTarget.name;
         mouseState = "isOut";
         trace (mouseActive + " " + mouseState);
         var isOut:Tween = new Tween(empresa_btn.over, "alpha", Strong.easeOut, empresa_btn.over.alpha, 0, 5, true);
    Now, what I'm trying to do is use the var "mouseActive"  that is returning the right button names inside the Tween as the  movieClips.
    The problem is that "e.currentTarget.name" is not the  "movieClip" itself... it's just a String with the name of the movieClip.
    Example:  whenever I try to do something like this:
    var isOut:Tween = new Tween(mouseActive.over, "alpha", Strong.easeOut, mouseActive.over.alpha, 0, 5, true);
    It will return an error cause, as I said, mouseActive is not a  movieClip, it's just a String (at least I think).
    I already  thank you for the help (again)
    And please, mind my nickname

    Ned Murphy wrote:
    You're welcome.
    As a further opportunity to reduce code, since all your listeners are identical...
    var btnArray:Array = new Array(btnNames go here, no quotes);
    for(var i:uint=0; i<btnArray.length; i++){
         btnArray[i].addEventListener(...OVER...);
         btnArray[i].addEventListener(...OUT...);
         etc... including where you set alpha = 0
    Gosh Ned! I had about 25 big lines of code, including things like "buttonMode = true" and now I have less than 10
    This is totally crazy! I always tried to understand this array thing and always failed. It's complicated but your code made some sense after a while
    I'm running out of "thanks" to give you hehe. Everything is working just fine but one little thing. I have a sound that plays when a button is clicked. It's working fine but everytime I open the swf the sound autoplay once =/
    I'm using this code:
    var btnSound:Sound = new clickSound(); //"clickSound" is the className I choosed when exported the sound to AS from the library
    and then, inside the function MOUSE_DOWN I have:
    btnSound.play();
    Everything is working but I always hear the button sound playing one time when I open the swf. Do you know why?
    Well, you already helped me a lot. Even more that I could have asked for.
    Thanks!

  • Passing a string as an object name...how?

    I've searched all over the place for a solution to this to no avail.
    I have a program that reads input from a text file. The text file holds information on student IDs, so it look something like this:
    "ID_1234"
    "ID_1235"
    "ID_1236"
    So, every line of the text file has a student ID.
    I have a class called Student, that takes the student ID as a parameter, so I can create a Student object pretty easily by going, for example:
    Student newStudent = new Student("ID_1234");
    Now, my problem is that I want to read the contents of the text file that is given to me and create an object for each student, and use as a name for that object the student's ID. I have the program reading the data from the text file no problem, it's just the object name assignment I'm having trouble with.
    //Start code
    private void readInStudents(String fileName){
    BufferedReader reader = new BufferedReader (new FileReader (studentIDFile.txt));
    String line = reader.readLine();
    while(line != null)
    Student line = new Student(line);
    //End code
    Ideally I would like this to crate three Student objects, with the names "ID_1234", "ID_1235", and "ID_1236" respectively.
    However, this is not the case as I get an error when assigning "line" as the object name in the line within the while loop.
    Any help would be much appreciated!!!!!!
    Many thanks.

    elsombreron wrote:
    Thanks to all for your quick replies. I ended up using an ArraList to store the objects without needing to give them all a dynamic name.
    I come from a purely procedural programming background where the sort of assignment I was trying to do would work, so still have to get used to OO style.
    Thanks again.Huh? I don't see what procedural vs object oriented has to do with it.
    FORTRAN, COBOL, C and Ada (pre 95) are all procedural languages and as far as I can remember, you could not do that in any of them.
    Perhaps many scripting languages allow this. The various *nix shells come to mind.
    What languages are you referring to that have tis feature?

  • Passing a string as the name of a Mouse Event Listener function?

    Hello,
    I am trying to essentially pass a string as a function name into an event listener, but I am not sure how to approach this.  Is there a way to convert a string into a function?  I am not sure how to word my question, so I apologize.
    Here is some code I have for me to show you what I am doing.
    package{
         //some import statements
         public class changes extends MovieClip{
              var functionName:String
              var aBox:Sprite;
              public function changes(){
                       functionName = "testThis";
                       createButtonBox(16, 16, 32, 32,  functionName);
              public function createButtonBox(anX:Number, aY:Number, aWidth:Number, aHeight:Number, aFunction:String){
                   aBox = new Sprite();
                   //Some drawing box code
                   aBox.addEventListener(MouseEvent.CLICK,[aFunction]()?)
                   addChild(aBox)
              public function aFunction(event:MouseEvent){
                   trace("test");
    Am I on the right track or is this not possible?
    Anyhow, thank you in advance.

    I guess I misworded my question.  Essentially what I am trying to do is create buttons that have functions called to from an event listener, referenced by a string like this:
    public class Document{
         var functionName:String;
         public function Document(){
                 createAButton("Test Button A", 32, 32, "testThis");
                 createAButton("Test Button B", 64, 64, "testThis2");
         public function createAButton(textOnButton:String, anX:Number, aY:Number, functionToCallTo:String){
                   var aButton:Sprite = new Sprite();
                   //draw the button
                   //set a textfieldup for the button to have
                  aButton.addEventListener(MouseEvent.CLICK, functionToCallTo)
         public function testThis(event:MouseEvent){
                   trace("testA");
         public function testThis2(event:MouseEvent){
                    trace("testB");
    Unfortunately aButton.addEventListener(MouseEvent.CLICK, functionToCallTo) gives me a coercian error, which is a given.
    aButton.addEventListener(MouseEvent.CLICK, [functionToCallTo]()) gives me TypeError: Error #1006: value is not a function.
    I mean I could create a bunch of if statements, but for the number of functions I plan to call to, like about 25 or so, that is pretty tedious.

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • How to access a method of a class which just known class name as String

    Hi,
    Now I have several class and I want to access the method of these class. But what I have is a String which contain the complete name of the class.
    For example, I have two class name class1and class2, there are method getValue in each class. Now I have a String containing one class name of these two class. I want to access the method and get the return value.
    How could I do?
    With Class.forName().newInstance I can get a Object. but it doesn't help to access and execute the method I want .
    Could anybody help me?
    Thanks

    Or, if Class1 and Class2 have a common parent class or interface (and they should if you're handling them the same way in the same codepath)...Class c = Class.forName("ClassName");
    Object o = c.newInstance(); // assumes there's a public no-arg constructor
    ParentClassOrInterface pcoi = (ParentClassOrInterface)o;
    Something result = pcoi.someMethod(); Or, if you're on 5.0, I think generics let you do it this way: Class<ParentClassOrInterface> c = Class.forName("ClassName");
    // or maybe
    Class<C extends ParentClassOrInterface> c = Class.forName("ClassName");
    ParentClassOrInterface pcoi = c.newInstance();
    Something result = pcoi.someMethod();

  • Is possible to pass array/list as parameter in TopLink StoredProcedureCall?

    Hi, We need to pass an array/List/Vector of values (each value is a 10 character string) into TopLink's StoredProcedureCall. The maximum number of elements on the list is 3,000 (3,000 * 10 = 30,000 characters).
    This exposed two questions:
    1. Is it possible to pass a Vector as a parameter in TopLink's StoredProcedureCall, such as
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("STORED_PROCEDURE_NAME");
    call.addNamedArgument("PERSON_CODE");
    Vector strVect = new Vector(3000);
    strVect.add(“ab-gthhjko”);
    strVect.add(“cd-gthhjko”);
    strVect.add(“ef-gthhjko”);
    Vector parameters = new Vector();
    parameters.addElement(strVect);
    session.executeQuery(query,parameters);
    2. If the answer on previous question is yes:
    - How this parameter has to be defined in Oracle’s Stored Procedure?
    - What is the maximum number of elements/bytes that can be passed into the vector?
    The best way that we have found so far was to use single string as a parameter. The individual values would be delimited by comma, such as "ab-gthhjko,cd-gthhjko,ef-gthhjko..."
    However, in this case concern is the size that can be 3,000 * 11 = 33, 000 characters. The maximum size of VARCHAR2 is 4000, so we would need to break calls in chunks (max 9 chunks).
    Is there any other/more optimal way to do this?
    Thanks for your help!
    Zoran

    Hello,
    No, you cannot currently pass a vector of objects as a parameter to a stored procedure. JDBC will not take a vector as an argument unless you want it to serialize it (ie a blob) .
    The Oracle database though does have support for struct types and varray types. So you could define a stored procedure to take a VARRAY of strings/varchar, and use that stored procedure through TopLink. For instance:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("STORED_PROCEDURE_NAME");
    call.addNamedArgument("PERSON_CODE");
    oracle.sql.ArrayDescriptor descriptor = new oracle.sql.ArrayDescriptor("ARRAYTYPE_NAME", dbconnection);
    oracle.sql.ARRAY dbarray = new oracle.sql.ARRAY(descriptor, dbconnection, dataArray);
    Vector parameters = new Vector();
    parameters.addElement(dbarray);
    session.executeQuery(query,parameters);This will work for any values as long as you are not going to pass in null as a value as the driver can determine the type from the object.
    dataArray is an Object array consisting of your String objects.
    For output or inoutput parameters you need to set the type and typename as well:
      sqlcall.addUnamedInOutputArgument("PERSON_CODE", "PERSON_CODE", Types.ARRAY, "ARRAYTYPE_NAME"); which will take a VARRAY and return a VARRAY type object.
    The next major release of TopLink will support taking in a vector of strings and performing the conversion to a VARRAY for you, as well as returning a vector instead of a VARRAY for out arguments.
    Check out thread
    Using VARRAYs as parameters to a Stored Procedure
    showing an example on how to get the conection to create the varray, as well as
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/varray/index.html on using Varrays in Oracle, though I'm sure the database docs might have more information.
    Best Regards,
    Chris

  • How to pass a string from a child thread to a parent thread ?

    I have a Server class listening to a particular port continuously using TCP Sockets . Whenever a client connects to this server socket, a new thread is created to obtain the data from the client socket. The following code shows how this is done -
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.*;
    public class TransportHandler extends Thread{
              ServerSocket server_socket;
              int myListeningPort;
              public String clientReq = "";
              public TransportHandler() throws IOException{
                   super();
                   myListeningPort = 80;
                   CreateServSocket();
              //throw the socket exception outside, so that it can be handled
              public TransportHandler(int port) throws IOException{
                   super();
                   myListeningPort = port;          
                   CreateServSocket();
              private void CreateServSocket() throws IOException{
                            //create serversocket
                   server_socket = new ServerSocket(myListeningPort);
              public void printmsg(){
                   System.out.println(clientReq);
              @Override
              public void run() {
                   // TODO Auto-generated method stub
                   StartListening();
              public void StartListening(){
                   while(true){
                        //loop forever listening to connections
                        try {
                             Socket clientSocket = server_socket.accept();
                                             //create new thread to handle client connection
                             Thread clientthread = new Thread(new ClientConnectionHandler(clientSocket));
                             clientthread.setName("Client Handler");
                             clientthread.start();
                             printmsg();
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
              public void StoreReq(String msg){
                   clientReq.concat(msg);
              private class ClientConnectionHandler implements Runnable{
                   Socket ClientSock;
                   BufferedReader sockReader;
                   InputStreamReader isReader;
                   String messageFromClient;
                   public ClientConnectionHandler(Socket sock){
                        ClientSock = sock;
                        try {
                             isReader = new InputStreamReader(ClientSock.getInputStream());
                             sockReader = new BufferedReader(isReader);
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                   @Override
                   public void run() {
                        // TODO Auto-generated method stub
                        int c= 0;
                        try {
                             while( (messageFromClient = sockReader.readLine())!= null){
                                  StoreReq(messageFromClient);  
                             //System.out.println("clientreq = "+clientReq);
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
    }The TransportHandler is instantiated from another class HttpMessageHandler as shown below -
    import java.io.IOException;
    public class HttpMessageHandler {
         public static void main(String[] args){
              try {
                   TransportHandler server = new TransportHandler();
                   server.start();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }So in the above code when the server.start() is executed, the run() method in TransportHandler is executed. How do I get the string contained in clientReq in HttpMessageHandler after the data from client socket is fully read ?
    Edited by: turing09 on Dec 12, 2009 2:13 PM

    Okay, to make my problem more clear to you - basically I am trying to create a simple Http Server, wherein the HttpMessageHandler is an interface between the Http layer & the Transport layer (represented by TransportHandler class). I am trying to code it bottom-up. In my design I require the TransportHandler class to get the client http request data from the TCP socket and pass it onto the HttpMessageHandler class.
    At the same time TransportHandler class must continuously listen to the port to receive other connections. For every client connection, the TransportHandler creates a new ClientHandler thread & this new thread gets the data. The TransportHandler instance & the ClientHandler instance are running in seperate threads. The HttpMessageHandler is running in the main thread. Please note: the member variable clientReq is private & not public
    The problem I am facing here is that even when the ClientHandler thread finishes, I am not able to print the client request data in HttpMessageHandler thread.
    I am able to print the String in the run() method of ClientHandler but not in HttpMessageHandler main() method.
    Any solutions for this?
    Edited by: turing09 on Dec 12, 2009 5:24 PM
    Edited by: turing09 on Dec 12, 2009 5:25 PM

  • Passing (byref) String from Java to C++ via JNI

    I wish to pass a string to a C++ Dll as a parameter in a function. The problem is that I don't know howto receive back the data after it is filled in the C++ dll. I am trying to do what is called passing parameters by reference.
    Java Code:
    public class ABKeyBoard {
    public native long leerBanda(int pista, String datos);
    public static void main(String[] args) {
    String datos=new String();
    System.loadLibrary("ABKeyBoard");
    new ABKeyBoard().leerBanda(1,datos);
    System.out.println(datos); //the content of datos here is empty.
    C++ Code:
    Java_ABKeyBoard_leerBanda(JNIEnv *env, jobject obj,jint pista, jstring datos)
         char buffer[2024];
         memset(buffer,     0x00,     sizeof(buffer));
         strcpy(buffer, "xxxx");
         datos = env->NewStringUTF(buffer);
    return;
    Thanks for your help.

    In java every parameter are always passed by value.
    The datos parameter is a local copy of the string
    reference you pass to the method.This is wrong. The String passed to the native method is the same String object you use in Java. Although everything is passed by value in Java, what is actually passed by value is the reference to the String. This means that you can modify the object you pass, but you are not allowed to change the reference to point to a totally different object. That is where the problem is coming in.
    The trouble is that it is illegal to modify a String, even from native code. If you need to make changes in-place to the text, pass an array of chars (if your native code uses Unicode), an array of bytes (if it uses normal 8-bit characters) or a StringBuffer. You can legally modify any of these data structures with the new data. But the StringBuffer object is the only one whose length can be changed after it is created. Unfortunately it is also the hardest to use from JNI.
    Generally I think you should always pass arrays of bytes/chars to native code instead of Strings when possible. They can be modified in place, and you can use String's methods to get a byte-array in the platform's proper encoding. Using the GetStringUTFChars method is problematic because UTF only maps directly onto ASCII in the case of characters which are in the set of 7-bit ASCII characters. Your code will do wrong things if your String happens to contain some other character, unless your native code expects UTF format strings.
    The good news is that C(++) functions which return results in their arguments do not ordinarily change the length. So you should be able to allocate a byte[] or char[] ahead of time of the appropriate size (don't forget to add the trailing null, which is not a component of Java strings). I think byte[] or char[] is the best answer because you can easily map those onto C-style arrays with Get[Primitive]ArrayRegion; the return of that is suitable for passing directly to native code, as long as you have remembered the null-terminator. For instance you could do (*env)->GetByteArrayRegion(env, javaArray, 0, arrayLength, CArray) and then your CArray would be changed to point at the contents of the javaArray (note: it does not copy data into CArray, it changes CArray to point at the array contents, so do not allocate memory for CArray first). Then when you do ReleaseByteArrayRegion the results will be propagated back to Java.

  • Passing XML String via HTTP Sender

    Hello everyone,
    currently we try to find a solution on the following requirement - maybe you have useful advice for us:
    8 different business documents can be sent via a web-interface to SAP XI via the http sender adapter. We already have a customized JCo Class that takes only one input parameter (containining the XML string of the business document).
    I think the easiest way would be to receive the XML string from the web-interface and pass it directly on to the JCo-Class in a Java Mapping.
    Is it possible to create a generic message type for all 8 types of XML documents that contains just one element holding the XML as string? By doing so we could use the same URL for all 8 different XML types and pass it directly on as input paramenter to the JCo Class.
    Do you have any idea how to do this?
    Thank you very much.

    Does the HttpURLConnection conn send the string along with the headerYes.

  • Is it possible to pass parameters for the action in the confirmation dialog

    I tried it but a null pointer exception is occuring. Is it possible to pass parameters ,if s give the solution....
    Thanks and regards.
    Karthik.

    Hi Karthi,
    Directly it is not possible. You can achieve it by this way.
    1>     Create 2 Event Handlers  say “OK” and “OKTest”.
    public void OK(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin OK(ServerEvent)
        String param = "abc";
        wdThis.OKTest(wdEvent,param);
        //@@end
    public void OKTest(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String paramtest )
        //@@begin OKTest(ServerEvent)
         wdComponentAPI.getMessageManager().reportSuccess("Param : "+paramtest);
        //@@end
    2>     Code for popup.
                    String dialog = "No of Rows : ";
                    IWDConfirmationDialog confDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(dialog,wdThis.wdGetAPI().getViewInfo().getViewController().findInEventHandlers("OK"),"OK");
                    confDialog.setTitle("Test Window");
                    confDialog.show();
    /thread/66776 [original link is broken]
    Regards,
    Mithu

  • Is it possible to pass a null value to a method?

    is it possible to pass a null value to a method?
    like this
    public String getParameterXX(String testvalue)
    String strX = "whatever";
    if(testvalue!=null)
    strX = strX + " man " ;
    Is this possible ?
    is this legal
    String i = getParameterXX(null);

    I also ran a similar code using null in a method, it just considers null as another string and concatenates it so
    public String getParameterXX(String testvalue)
    String strX = testvalue+"whatever";
    return strX;
    public static void main(String [] args)
    Test tt = new Test();
    String i = tt.getParameterXX(null);
    System.out.println(i);
    Gives me "nullwhatever"

  • Is it possible to pass blob from java to PL/SQL ?

    Hi, I try to bind a PL/SQL function who return a blob to a java class :
    Signature of java method :
        public static Blob getBLOB(int aId, String aJDBC) {Create PL/SQL function :
    create or replace function aa_java(myPiId in number,myPiJDBC in varchar2) return blob
    as language java
    name 'zip.ReadBLOB.getBLOB(int,java.lang.String) return java.sql.Blob';
    /In java code, my blob has the right size (150 Ko) but in PL/SQL, size = 0 !!!
    Any ideas ?

A: Is it possible to pass blob from java to PL/SQL ?

Thank you, but I think I have a Java problem...
Here is my code :
package zip;
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
public class ReadBLOB {
    public static BLOB getBLOB(int aId, String aJDBC) {
        BLOB vBlob = null;
        try {
            DriverManager.registerDriver(new OracleDriver());
            Connection connection = DriverManager.getConnection(
                aJDBC,
            PreparedStatement stat = connection
                .prepareStatement("select image from aa_blob where id="+aId);
            ResultSet rs = stat.executeQuery();
            if (rs.next()) {
                vBlob = (BLOB) rs.getBlob(1);
                System.out.println("Taille 1 : "+vBlob.length());
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        return vBlob;
    public static void main(String[] args) throws Exception {
        BLOB vBlob = getBLOB(1, "jdbc:oracle:thin:@vdn-ceg5:1521:DEV5");
        System.out.println("Taille 2 : "+vBlob.getLength());
}When I run the main method, I have :
Taille 1 : 150260
Taille 2 : 86
!!!!????!!!!????

Thank you, but I think I have a Java problem...
Here is my code :
package zip;
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
public class ReadBLOB {
    public static BLOB getBLOB(int aId, String aJDBC) {
        BLOB vBlob = null;
        try {
            DriverManager.registerDriver(new OracleDriver());
            Connection connection = DriverManager.getConnection(
                aJDBC,
            PreparedStatement stat = connection
                .prepareStatement("select image from aa_blob where id="+aId);
            ResultSet rs = stat.executeQuery();
            if (rs.next()) {
                vBlob = (BLOB) rs.getBlob(1);
                System.out.println("Taille 1 : "+vBlob.length());
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        return vBlob;
    public static void main(String[] args) throws Exception {
        BLOB vBlob = getBLOB(1, "jdbc:oracle:thin:@vdn-ceg5:1521:DEV5");
        System.out.println("Taille 2 : "+vBlob.getLength());
}When I run the main method, I have :
Taille 1 : 150260
Taille 2 : 86
!!!!????!!!!????

Maybe you are looking for

  • Rendering problem in output of Pages 5.1

    Has anyone else seen a print rendering problem when trying to print a table in Pages 5.1? All my text in tables is jagged and lower-resolution than other text: (Printed from Pages 5.1 (1769) on a HP Color LaserJet CP2025 from a retina MacBook Pro ori

  • Oracle BI Publisher - Passing multiple wildcard search to a bind variable

    Hi, Please help me in resolving the below mentioned issue: I have developed a report in oracle BI Publisher with a SQL query. While scheduling the report to run I used to pass mutilple parameters like CGAMSVC08,RLCSVC51 If the pass the parameter with

  • Can we send message to receiver depending on another receiver

    Hi, I configured two receivers(different target strcures ) without BPM.now i need to send message to receiver 2 if  receiver 1 message sucessfully processed . can we handle?

  • Need help for sql statement

    Hi, Need help to write sql statement. create table t_dt ( dt_start date, dt_end date, amount number); insert into t_dt values('1-Jan-10','10-Feb-10',12); insert into t_dt values('11-Feb-10','10-Mar-10',10); insert into t_dt values('11-Mar-10','20-Apr

  • Time Machine has been excluding items for hours... and counting!

    I have been using time capsule for several years now. But today I brought a new hard drive to use with Time Machine. It's a Western Digital My Book Network drive. Plugged it in selected the new disk and started to back up. For hours now it has been '