ClassCastException from OraclePreparedStatement.setArrayInternal() method

The following code throws a ClassCastException from oracle.jdbc.driver.OraclePreparedStatement.setArrayInternal() method line# 5886 when cs.setArray() is executed.
Connection conn = getConnection(); // Returns a java.sql.Connection instance
CallableStatement cs = conn.prepareCall(queryString);
cs.setArray(1, new UsnArray(usns)); // UsnArray implements java.sql.Array
cs.registerOutParameter(2, Types.INTEGER);
cs.execute();
This works if I create the CallableStatement on an oracle.jdbc.driver.OracleConnection instance and use an oracle.sql.ARRAY instance in the setArray() method call. A JDBC-compliance driver shouldn't be expecting the applications to use driver-specific classes. The application can pass any instance of type java.sql.Array in the setArray() method call.
Is this a bug in the driver?
Driver information from ojdbc14.jar manifest.mf file:
Manifest-Version: 1.0
Specification-Title: Oracle JDBC driver classes for use with JDK14
Sealed: true
Created-By: 1.4.2_08 (Sun Microsystems Inc.)
Implementation-Title: ojdbc14.jar
Specification-Vendor: Oracle Corporation
Specification-Version: Oracle JDBC Driver version - "10.2.0.2.0"
Implementation-Version: Oracle JDBC Driver version - "10.2.0.2.0"
Implementation-Vendor: Oracle Corporation
Implementation-Time: Tue Jan 24 08:55:21 2006
Name: oracle/sql/converter/
Sealed: false
Name: oracle/sql/
Sealed: false
Name: oracle/sql/converter_xcharset/
Sealed: false
--------------------------------------------------------------------------------------------------

Let me elaborate on your last two replies: it doesn't matter what other drivers support; it doesn't matter what your "intention" was; all that matters is whether the implementation adheres to the specification or not. If it is not, it is not compliant to the specification (period). It is a very strong statement to say that "You must use oracle.sql.ARRAY." I'm not quite sure you understand the meaning and motivation behind standards like JDBC and J2EE and standards bodies like ANSI. This is very obvious when you say that "This is a limitation of the expressiveness of the Java type system."
If you think the JDBC compliance only mandates that "A driver is only required to accept a value that is of the concrete class defined by the driver," which is not mentioned anywhere in the spec anyway, then Sun would have simply defined the setArray method as "public void setArray(int i, oracle.sql.ARRAY x)" (one for each driver available) instead of saying "public void setArray(int i, java.sql.Array x)". It also clearly says that if a specification is not supported by a driver, in which case it must be specified in the DatabaseMetaData, the driver must throw a SQLEception. Bur your claim completely contradicts everything. You can also refer links like this on the Web: http://archives.postgresql.org/pgsql-jdbc/2003-07/msg00294.php.
I don't know what you mean by "The JDBC spec is not as precise as it could be." The relevant requirements have been clearly stated throughout Chapter 13 “Statements” and in Appendix B "Data Type Conversion Tables" in JDBC 3.0 spec (Chapter 8 Section 3 "Arrays" in JDBC 2.1 spec).
A JDBC driver may provide underlying data source-specific features in addition to those mandated by the JDBC specification. Applications that try to take advantage these additional features may decide to “stick” with a specific driver and import driver-specific classes. But these additional features cannot substitute the basic requirements.

Similar Messages

  • How can i take off my master card from my payment methods on my apple account

    my mastercard seems to be declined so i cant make any purchases but i also cant update any apps or download any free apps is there any way i can take off my mastervard from my payment methods?

    You can add an iTunes gift card, then remove the credit card. But, I'm afraid you're still gonna have to contact iTunes support to re-enable your account:
    http://www.apple.com/support/itunes/

  • How to call a EJB method from Session bean method

    Hi all,
    I'm new to J2EE programming. I have a simple doubt .
    I have already created a lookup method for EJB bean in Session bean .
    My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
    Please provide me an example code .
    Thanks in advance.

    InitialContext ctx = new InitialContext();
         GeneralEditor editor = (GeneralEditor) ctx
                        .lookup("GeneralEditorBean/remote");
              GeneralService service = (GeneralService) ctx
                        .lookup("GeneralServiceBean/remote");
              LanMu lm = new LanMu();
              lm.setName("shdfkhsad");
              editor.add(lm);

  • How to get value from Thread Run Method

    I want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that it seems that scope of the variable gets lost resulting to null value in the called method/class..
    How can I get the variable with the value?
    This is sample code:
    public class SampleSynchronisation
    public static void main(String df[])
    sampleThread sathr= new sampleThread();
    sathr.start();
    System.out.println("This is the value from the run method "+sathr.x);
    /* I should get Inside the run method::: But I get only Inside */
    class sampleThread extends Thread
         public String x="Inside";
         public void run()
              x+="the run method";

    I think this is what you're looking for. I hold up main(), waiting for the results to be concatenated to the String.
    public class sampsynch
        class SampleThread extends Thread
         String x = "Inside";
         public void run() {
             x+="the run method";
             synchronized(this) {
              notify();
        public static void main(String[] args) throws InterruptedException {
         SampleThread t = new sampsynch().new SampleThread();
         t.start();
         synchronized(t) {
             t.wait();
         System.out.println(t.x);
    }

  • Calling a method from a static method

    hello all,
    I'm calling a non-static method from a static method (from the main method). To overcome this i can make the method i am calling static but is there another way to get this to work without making the method that is being called static?
    all replies welcome, thanks

    When you call a non-static method, you are saying you are calling a method on an object. The object is an instance of the class in which the method is defined. It is a non-static method, because the instance holds data in it's instance variables that is needed to perform the method. Therefore to call this kind of method, you need to get (or create an instance of the class. Assuming the two methods are in the same class, you could do
    public class Foo
         public static void main(String[] args)
                Foo f = new Foo();
                f.callNonStaticMethod();
    }for instance.

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]
        {

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Pete
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • How can I get the variable with the value from Thread Run method?

    We want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that scope of the variable gets lost resulting to null value in the called method/class..
    How can I get the variable with the value?
    This is sample code:
    public class SampleSynchronisation
         public static void main(String df[])
    sampleThread sathr= new sampleThread();
    sathr.start();
    System.out.println("This is the value from the run method "+sathr.x);
    // I should get Inside the run method::: But I get only Inside
    class sampleThread extends Thread
         public String x="Inside";
         public void run()
              x+="the run method";
    NB: if i write the variable in to a file I am able to read it from external method. This I dont want to do

    We want to access a variable from the run method of a
    Thread externally in a class or in a method. I presume you mean a member variable of the thread class and not a local variable inside the run() method.
    Even
    though I make the variable as public /public static, I
    could get the value till the end of the run method
    only. After that scope of the variable gets lost
    resulting to null value in the called method/class..
    I find it easier to implement the Runnable interface rather than extending a thread. This allows your class to extend another class (ie if you extend thread you can't extend something else, but if you implement Runnable you have the ability to inherit from something). Here's how I would write it:
    public class SampleSynchronisation
      public static void main(String[] args)
        SampleSynchronisation app = new SampleSynchronisation();
      public SampleSynchronisation()
        MyRunnable runner = new MyRunnable();
        new Thread(runner).start();
        // yield this thread so other thread gets a chance to start
        Thread.yield();
        System.out.println("runner's X = " + runner.getX());
      class MyRunnable implements Runnable
        String X = null;
        // this method called from the controlling thread
        public synchronized String getX()
          return X;
        public void run()
          System.out.println("Inside MyRunnable");
          X = "MyRunnable's data";
      } // end class MyRunnable
    } // end class SampleSynchronisation>
    public class SampleSynchronisation
    public static void main(String df[])
    sampleThread sathr= new sampleThread();
    sathr.start();
    System.out.println("This is the value from the run
    method "+sathr.x);
    // I should get Inside the run method::: But I get
    only Inside
    class sampleThread extends Thread
    public String x="Inside";
    public void run()
    x+="the run method";
    NB: if i write the variable in to a file I am able to
    read it from external method. This I dont want to do

  • Returning more than one value/object from an EJB method

    Hi,
    I have the follong method in the remote interface of my EJB:
    void createSomeObject( MyObject obj1, List returnList1, Map returnMap1);
    Since i want to return a List (returnList1) and a Map(returnMap1) from my EJB method "createSomeObjects", i am passing these as parameters thinking they will be passed by reference and the client(servlet) gets the changes the EJB made to these objects.
    But it doesn't seem to be working, the EJB is filling the List and Map objects and the servlet doesn't get it (pass by value problem).
    My understading is that, all parameters to an EJBs are passed by value(because they are remote calls, the RMI thing), let me know if this right.
    Is there any workaround apart from the following alternative?
    Alternatives:
    1. Wrap "List list1" and "Map map1" in another model and return this instead of passing them as parameters.
    Thanks
    Vasu

    My understading is that, all parameters to an EJBs
    are passed by value(because they are remote calls,
    the RMI thing), let me know if this right.Yes, that is correct - which you should know from your introduction to J2EE reading.
    Is there any workaround apart from the following
    alternative?
    Alternatives:
    1. Wrap "List list1" and "Map map1" in another model
    and return this instead of passing them as
    parameters.No.

  • How to remove the recursion from the following method

    Hi All,
    Can u plz help me to remove the recursion from the following method.
    The problem here is that recursion cann't be removed easily here as there is no any end condition.
    hopefully waiting for the help....
    Reema.
    private FilterStatement processCustomExpressions(FilterStatement statement,
              DistinguishedName tenant, LdapDao ldapDao)
              throws NameNotFoundException,
              LDAPServerException, NamingException {
         HashMap relMap = new HashMap();
         HashMap replaceMap = new HashMap();
         Vector relVec = null;
              FilterSubExpressions expressions = statement.getExpressions();
              FilterPartIterator it = (FilterPartIterator)expressions.iterator();
              while (it.hasNext()) {
                   FilterExpression e = (FilterExpression)it.next();
                   if (e instanceof CustomExpression) {
                        CustomExpression ce = (CustomExpression)e;
                        try {
                             FilterExpression fe = ce.createExpression();
                             if (fe instanceof RelationshipExpression) {
                                  RelationshipExpression re = (RelationshipExpression)fe;
                                  it.replace(re);
                                  relVec = (Vector) relMap.get(re.name);
                                  if(relVec == null) {
                                       relVec = new Vector();
                                       relVec.add(re);
                                  }else {
                                       relVec.add(re);
                                       it.remove();
                                  relMap.put(re.name, relVec);
                             } else if (fe instanceof SystemExpression) {
         SystemExpression se = (SystemExpression)fe;
         it.replace(se);
                        } catch (FilterEvaluationException fe) {
                             traceLogger.exception(Level.DEBUG_MIN, this,
                                  "processCustomExpressions(" + statement.toString() + ")", fe);
                             SystemLog.getInstance().logError(this,
                                  "processCustomExpressions(" + statement.toString() + ")", fe.getMessage());
              replaceRelationshipExpressions(statement, tenant, ldapDao, relMap);
              processContainerBasedExpressions(tenant, ldapDao, relMap, replaceMap);
              FilterSubStatements statements = statement.getStatements();
              FilterStatement temp = null;
              if (statements.size() != 0) {          
                   FilterPartIterator iter = (FilterPartIterator)statements.iterator();
                   while (iter.hasNext()) {
                        temp = (FilterStatement)iter.next();
                        temp = processCustomExpressions(temp, tenant, ldapDao);
                        iter.replace(temp);
              if(!replaceMap.isEmpty())
                   return replaceContainerBasedExpressions(statement, replaceMap);
              return statement;
         }

    I think one of the reasons that noone will reply to your posting is that you take it a bit too easy. First of all, please use the "code" button to format your code listings. Then it will look like this (see below) and everybody can at least read it!
    private FilterStatement processCustomExpressions(FilterStatement statement,
                                                    DistinguishedName tenant,
                                                    LdapDao ldapDao)
            throws NameNotFoundException, LDAPServerException, NamingException {
        HashMap relMap = new HashMap();
        HashMap replaceMap = new HashMap();
        Vector relVec = null;
        FilterSubExpressions expressions = statement.getExpressions();
        FilterPartIterator it = (FilterPartIterator) expressions.iterator();
        while (it.hasNext()) {
            FilterExpression e = (FilterExpression) it.next();
            if (e instanceof CustomExpression) {
                CustomExpression ce = (CustomExpression) e;
                try {
                    FilterExpression fe = ce.createExpression();
                    if (fe instanceof RelationshipExpression) {
                        RelationshipExpression re = (RelationshipExpression) fe;
                        it.replace(re);
                        relVec = (Vector) relMap.get(re.name);
                        if (relVec == null) {
                            relVec = new Vector();
                            relVec.add(re);
                        else {
                            relVec.add(re);
                            it.remove();
                        relMap.put(re.name, relVec);
                    else if (fe instanceof SystemExpression) {
                        SystemExpression se = (SystemExpression) fe;
                        it.replace(se);
                catch (FilterEvaluationException fe) {
                    traceLogger.exception(Level.DEBUG_MIN, this,
                                "processCustomExpressions("
                                + statement.toString()
                                + ")",
                            fe);
                    SystemLog.getInstance().logError(this,
                                "processCustomExpressions("
                                + statement.toString()
                                + ")",
                            fe.getMessage());
        replaceRelationshipExpressions(statement, tenant, ldapDao, relMap);
        processContainerBasedExpressions(tenant, ldapDao, relMap, replaceMap);
        FilterSubStatements statements = statement.getStatements();
        FilterStatement temp = null;
        if (statements.size() != 0) {
            FilterPartIterator iter = (FilterPartIterator) statements.iterator();
            while (iter.hasNext()) {
                temp = (FilterStatement) iter.next();
                temp = processCustomExpressions(temp, tenant, ldapDao);
                iter.replace(temp);
        if (!replaceMap.isEmpty())
            return replaceContainerBasedExpressions(statement, replaceMap);
        return statement;
    }Second, when you cannot understand your own code anymore, simplify it! As far as I can see, there are two "main" processes (i.e. loops) in your method, where the second one calls the method recursively. Split the method into two. Furthermore, write a third method that processes the iterated elements and call that method from out of the loops.
    I did'nt analyse your method and have no idea what it does at all. I'm merely telling my first impression.
    Good luck.

  • How do you call a java class from the main method in another class?

    Hi all,
    How do you call a java class from the main() method in another class? Assuming the two class are in the same package.
    Thanks
    SI
    Edited by: okun on May 16, 2010 8:40 PM
    Edited by: okun on May 16, 2010 8:41 PM
    Edited by: okun on May 16, 2010 8:47 PM

    georgemc wrote:
    To answer your impending question, either the method you're calling has to be static, or you need an instance of that other class to invoke it against. Prefer the latterAnd to your impending question after that: no, don't use the Singleton pattern.

  • Passing array from JS to method of applet

    There is unable in IE pass array of values from javascript to method of applet, but in Mozilla it's working fine. In IE i have got exception:
    Exception:
    java.lang.Exception: setTest{0} :no such method exists
         at sun.plugin.com.JavaClass.getMethod1(Unknown Source)
         at sun.plugin.com.JavaClass.getDispatcher(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    java.lang.Exception: java.lang.Exception: setTest{0} :no such method exists
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    JavaScript code:
    var testArr=[];
        testArr[0]=1;
        testArr[1]=2;
        testArr[2]=3;
        document.sync.setTest(testArr);
    Applet method:
    public void setTest(Object[] test){
            System.out.println("Test "+test.length);
            for (Object o: test){
                System.out.println(o.toString());
        }How do passing in IE?

    yes, MAYSCRIPT just allow to call methods. but as i know it's unable to pass simply array from js to applet and from applet to js. so i convert array of values to String and in applet i use StringTokenizer to parsing. Thanks. ;)

  • Is there a way to get "clientId" from an action method?

    Actions and action listeners are similar, but there is an important difference. The listener does not return a view for navigation, but an action does not get the ActionEvent parameter, and hence does not have a trivial way to get at the client id that invoked it.
    Sometimes its seems you need both.
    If an action can fail and you cannot know for certain until the action is attempted (for example, a database operation), it is nice to be able to queue a message to the component that invoked the action and redisplay the view which now contains the error indication. On success however, an new view should be navigated to.
    This requires that the action get at a client id, and often the logical client id is of the component the user used to invoke the action. Is there a built in way to get this id from an action method?
    Ideally an action should have the signature Object action(ActionEvent) or am I missing something?

    hanafey wrote:
    Unfortunately this requires both action and actionListener be specified in the viewThere is a nasty workaround possible where you get the clientId of the invoked button from the RequestParameterMap so that you can only use the UICommand action method, but I wouldn't recommend that.
    and if the listener is forgotten the message will get attached in the wrong place, or end up global.Isn't that just a developer fault?
    Also, is'nt there a (tiny) concern about multi-threaded failure if a user happens to have two windows open on the same application?Not if your bean is request scoped. If your bean is session scoped, then the user have to be very fast, or your server have to be very slow. With very I really mean very+.
    The other way I considered was via binding, but his also burdens the view with an extra attribute.What is your functional requirement after all? Sounds like to me that you rather need f:setPropertyActionListener or f:attribute. Also see http://balusc.blogspot.com/2006/06/communication-in-jsf.html for some examples and new insights.

  • Calling  functions from a synchronize method

    =can we call a synchronize method or a simple method from a sysnchronize method.
    @lam

    You can every second wednesday afternoon. Sometimes it works on morning as well, but it's not guarnteed (depends on position of Jupiter and Mars to Venus, except for easter). But take care of fridays, especially 13th (we all heard the story, when the whole internet went down..).
    /bullshitmode=off
    ... yes, you can,... ;)
    Edited by: slowfly on 27.03.2009 12:36

  • Sending files from the remote method

    hi,
    I would like to know if we can send a File object, i.e. a file as the return value from the remote method on the server side accessed by the client.
    Actually, i want to make the files stored at the server system accessible to the client system. how to achieve it?

    java.io.File implements java.io.Serializable so the previous answer is formally incorrect. However you need to be aware that that would only send the File object, which is essentially the filename, not its contents. I'm sure that what the poster meant to say.
    You can send the contents as well in a number of ways but you have to write it by hand. There's no easy way out of the box.

  • Pass an object from a static method

    Hi,
    I'm trying to pass a reference to an object from a static method, but I get an error when compiling.
    Say for example I have this:
    public class obj1 {
    public void myMethod (int i, Object ob, etc...) {
    ...and I want to call this method from a method that looks like this:
    public class obj2 {
    public static int anotherMethod(...) {
    obj1.myMethod(1,this,...);
    ...Can I pass a reference from obj2 to obj1 any other way?
    Thanks alot.

    how can I get a reference to obj2 then?Pay no attention to zdude's answer - it's nonsense.
    You're confused about basic Java concepts. obj2 is a class, not an object. References point to objects, not classes. There is no obj2 object in the code you show, so you cannot have a reference to an obj2 object.
    Maybe if you post some more code, we can get an idea of what you're trying to do. You might want to try the New to Java forum.

Maybe you are looking for

  • New effects problem on library loops

    My Logic has been performing close to flawless since I've had it. An update installed today and a new problem has arisen that I can not find a way to fix. Whenever the project tempo is different than the loop tempo, for example, when a drum loop in t

  • How do I share an iMovie file for use on 1st or 2nd generation Apple TV

    How do I share an finished imovie file for use on 1st or 2nd generation apple TV?

  • Help XSQL Servelet

    Hi! Could any please help in XSQL SERVELET I downloaded the xsql servelet for genrating XML pages. But when I run the demo file that come with it, It gives me this error : " Oracle XSQL Servlet Page Processor 1.0.0.0.0 XSQL-004: Could not acquire a d

  • To Synchronize or not to synchronize that is the question

    I find myself using static methods a lot since they are very convenient in that you don't have to instantiate an object and populate members, etc. rather its often more convenient just pass something in and get something out. However, I'm not crystal

  • Working with 1440 x1080 footage?

    I'm going to be working with some footage shot at 1440 x1080 (interlaced I believe) with an AVCHD camera. I will have other footage shot at 1920 x 1080 that needs to be edited with it. 1. Anyone know why a camera would be designed to shoot footage at