SetElement - setArray method

Has anyone found a good example using either a setElement or setArray method in a Jpublisher generated class...
All we can get it to do is throw a negative array index error...
//Jpub generated collection object - table
TxTable tx = new TxTable();
//jpub generated record object for Tx table
TxRecord tr = new TxRecord();
//set record column values
tr.setFName("Hello");
tr.setLname("World");
// pass record object to slot 1
tx.setElement(tr, 1);
What am I missing?

u cant do it.
setArray() method is for setting a 'array' value the prepared statement. it is very much similar to setInt(index, intValue) or setString(index,StringValue) methods.
Array is thehe mapping in the Java programming language for the SQL type ARRAY.

Similar Messages

  • SetArray Method

    Hi,
    I am trying to update Array datatype in Oracle.
    I am getting java.sql.Array object from database since I can't create descriptor
    from
    weblogic pool using JNDI.
    Now I have this Array but its just a pointer, How can I update values in this
    array.
    here is the code
    ... after creating connection
    Array array=null;
    while (rs.next()){
    array = rs.getArray("myarray");
    String[] mystringarray = (String[])array.getArray();
    for (int i = 0; i < mystringarray.length; i++) {
    scores="student no." + i;
    However I need to know how to update this Array?
    I want to call --
    PreparedStatement pstmt =                          conn.prepareStatement("{call test_package.newarray(?)}");
    pstmt.setArray(1, array);
    pstmt.executeUpdate();
    If I cannot update this way bec its a pointer to recordset, how do I go about
    updating?
    thanks

    Actually you are not using OracleConnection's createARRAY method. Your code says 'cstmt.createARRAY' and cstmt is presumablyl a calleable statement.Hard to see how that could be so given that there is no CallableStatement.createArray() method, nor even an OracleCallableStatement.createArray() method. The only createArray() method mentioned in the document you cited is in OracleConnection.

  • SetArray of PreparedStatement

    Can any one tell me how the setArray is used in PreparedStatement where in the Query takes 2 parameters. Now the requirement is that instead of me running the SQL in loop for different values, I just want to set the array using setArray method of PreparedStatement.
    Snippet of code will be of a great help.

    u cant do it.
    setArray() method is for setting a 'array' value the prepared statement. it is very much similar to setInt(index, intValue) or setString(index,StringValue) methods.
    Array is thehe mapping in the Java programming language for the SQL type ARRAY.

  • 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.

  • Cannot insert String[] objects in PreparedStatements !!!

    Hello guys,
    I'm using PostgreSQL 7.0.3 for a website project.
    I've got a table in the website database system which has a integer array type,
    e.g.
    create table preferences(
    user_id integer references user,
    music varchar(20)[5],
    magazines varchar(20)[5],
    channel varchar(10)[3]
    )I've also got an javabean which holds the use preferences object
    public class userPref{
    private String[] music;
    private String[] magazines;
    private String[] channel;
    private int userId;
    // a constructor which uses reflection
    public userPref(HttpServletRequest request){
    }know i would like to be able to insert some values in that
    table using java.sql library.
    i've got
    Connection con = broker.getConnection(); // the connection pool releases one connection
    PreparedStatement ps = con.prepareStatement;
    ps.setInt(1,user.getId());
    ...But for the rest of the fields, what should I use ?
    I saw that there was setArray method in the PreparedStatement that uses java.sql.Array Class
    Is it the method that I've got to use. If so, do I need to implement it ?
    Please help me,
    touco

    I have no idea if that is the method you have to use or whether it will do what you want, but you do not have to implement it. That is the responsibility of the JDBC driver writer, just like the other 100-odd methods of PreparedStatement.

  • Passing array of timestamps into oracle stored proc

    Hey there,
    I have an interesting problem. I need to pass an array of java.sql.Timestamp into a stored proc.
    I see that the PreparedStatement provides a setArray() method which takes as arguments an int, java.sql.Array
    Anybody know how I can use the java.sql.Array to my advantage here ? Basically, I don't see how I can create a java.sql.Array of Timestamps
    thanks in advance for all your help.
    Manish Mandelia

    The java.sql.Array implementation is provided by your jdbc driver.
    For exemple using Oracle you can obtain an sql.Array with something like this :
    Connection con=getConnection() // get a connection to the DB
    //first declare what type of array you will use in the DB
    // you probably want to replace CHAR(7) by Timestamp here
    PreparedStatement createArray=
    con.prepareStatement("CREATE OR REPLACE TYPE MYARRAY AS VARRAY(100) OF CHAR(7)");
    createArray.execute();          
    //then get an java instance of this Array
    oracle.sql.ArrayDescriptor arrayDescriptor = oracle.sql.ArrayDescriptor.createDescriptor("MYARRAY",con);
    // content is used to fill the Array
    String[] content= {"string0", "string1"};
    java.sql.Array sqlArray=new oracle.sql.ARRAY(arrayDescriptor, con, content);               
    // then call your stored procedure
    java.sql.CallableStatement callStmt=con.prepareCall("call MyStoredProcedure(?)");
    // passing the array as an argument
    callStmt.setArray(1,sqlArray);
    callStmt.execute();
    As you can see the code is quite database specific.
    hope that helps.

  • Emptying a Binary Tree

    Hello,
    The problem I'm having is how to empty a binary tree. Here is my code for MyBinaryTree:
    public class MyBinaryTree implements BinaryTree {
       private BinaryTreeNode root;
       protected static int numNodes;
       private static String tree = "";
        * Constructor that creates a binary tree with a root.
        * @param r The root node
        * @param num The number of nodes
       public MyBinaryTree(BinaryTreeNode r, int num) {
          root = r;
          numNodes = num;
        * Method to make the binary tree empty.
       public void makeEmpty() {
          root.left = null;
          root.right = null;
          root = new BinaryTreeNode(null,null,null,null,null);
          numNodes = 0;
        * Method to make a root with key k and element el.
        * @param k The key of the root
        * @param el The element in the root
       public void makeRoot(Comparable k, Object el) {
          root = new BinaryTreeNode(k,el);
          numNodes++;
        * Method to return the root of the binary tree.
        * @return The root of the tree
       public BinaryTreeNode root() {
          return root;
        * Method to return the left child of a node.
        * @param node The node whose left child is wanted.
        * @return The left child of the node
        * @see NoNodeException
       public BinaryTreeNode leftChild(BinaryTreeNode node) throws NoNodeException {
          if (node.left == null) throw new NoNodeException("No left child!");
          else return node.leftChild();
        * Method to set the left child of node "node".
        * @param node The node to be given a left child
        * @param child The node to be set as left child
       public void setLeftChild(BinaryTreeNode node, BinaryTreeNode child) {
          node.setLeftChild(child);
          numNodes++;
        * Method to return the right child of a node.
        * @param node The node whose right child is wanted.
        * @return The right child of the node
        * @see NoNodeException
       public BinaryTreeNode rightChild(BinaryTreeNode node) throws NoNodeException{
          if (node.right == null) throw new NoNodeException("No right child!");
          else return node.rightChild();
        * Method to set the right child of node "node".
        * @param node The node to be given a right child
        * @param child The node to be set as right child
       public void setRightChild(BinaryTreeNode node, BinaryTreeNode child) {
          node.setRightChild(child);
          numNodes++;
        * Method to return the parent of a node.
        * @param node The node whose parent is wanted.
        * @return The parent of the node
        * @see NoNodeException
       public BinaryTreeNode parent(BinaryTreeNode node) throws NoNodeException {
          if (node.p == null) throw new NoNodeException("No parent!");
          else return node.parent();
        * Method to set the parent of node "node".
        * @param node The node to be given a parent
        * @param pt The node to be set as parent
       public void setparent(BinaryTreeNode node, BinaryTreeNode pt) {
          node.setParent(pt);
          numNodes++;
        * Method to return the key of the specified node.
        * @param node The node with the key to be returned
        * @return The key of the node
       public Comparable getKey(BinaryTreeNode node) {
          return node.getKey();
        * Method to set the key of the specified node.
        * @param node The node for which the key will be set.
        * @param k The key to be set.
       public void setKey(BinaryTreeNode node, Comparable k) {
          node.setKey(k);
        * Method to get the element in the specified node.
        * @param node The node with the element to be returned.
        * @return The element in the node.
       public Object getElement(BinaryTreeNode node) {
          return node.getElement();
        * Method to put an element into the specified node.
        * @param node The node that will have an element put in it.
        * @param o The element to be inserted.
       public void setElement(BinaryTreeNode node, Object o) {
          node.setElement(o);
        * Method to add a left child to the specified node.
        * @param theNode The node that the left child will be added to.
        * @param k The key associated with the left child.
        * @param el The element in the left child.
       public void addLeftChild (BinaryTreeNode theNode, Comparable k, Object el) {
          BinaryTreeNode temp = new BinaryTreeNode(k,el);
          temp.setParent(theNode);
          theNode.setLeftChild(temp);
          numNodes++;
        * Method to add a right child to the specified node.
        * @param theNode The node that the right child will be added to.
        * @param k The key associated with the right child.
        * @param el The element in the right child.
       public void addRightChild (BinaryTreeNode theNode, Comparable k, Object el) {
          BinaryTreeNode temp = new BinaryTreeNode(k,el);
          temp.setParent(theNode);
          theNode.setRightChild(temp);
          numNodes++;
        * Method to remove the left child of the specified node.
        * @param theNode The node which the left child will be removed.
       public void removeLeftChild(BinaryTreeNode theNode) {
          ((BinaryTreeNode)(theNode.left)).p = null;
          theNode.left = null;
          numNodes--;
        * Method to remove the right child of the specified node.
        * @param theNode The node which the right child will be removed.
       public void removeRightChild(BinaryTreeNode theNode) {
          ((BinaryTreeNode)(theNode.right)).p = null;
          theNode.right = null;
          numNodes--;
        * Private method to perform an inorder traversal on the tree.
        * @param t A MyBinaryTree object
        * @param n The starting node.
       private static String inorderPrint(MyBinaryTree t, BinaryTreeNode n) {
          String spaces = "";
          for (int i = 0; i < (numNodes - 1)/2; i++) spaces += " ";
          if (n.left != null || n.right != null) inorderPrint(t,t.leftChild(n));
          tree += spaces + n.getElement();
          if (n.left != null || n.right != null) inorderPrint(t,t.rightChild(n));
          return tree;
        * Private method to perform an inorder traversal on the tree.
        * @param t A MyBinaryTree object
        * @param n The starting node.
        * @param pos The current position in the tree.
        * @return A tree with an asterix beside the current position
       private static String inorderPrint2(MyBinaryTree t, BinaryTreeNode n,
                                           BinaryTreeNode pos) {
          String spaces = "";
          for (int i = 0; i < (numNodes - 1)/2; i++) spaces += " ";
          if (n.left != null || n.right != null) inorderPrint2(t,t.leftChild(n),pos);
          if (n.getElement() == pos.getElement()) tree += spaces + n.getElement() + "*";
          else tree += spaces + n.getElement();
          if (n.left != null || n.right != null) inorderPrint2(t,t.rightChild(n),pos);
          return tree;
        * Method to return a String representation of the binary tree.
        * @return String representation of the binary tree
       public String toString() {
          if (root.getElement() == null) return "*** Tree is empty ***";
          else {
             MyBinaryTree temp = new MyBinaryTree(root,numNodes);
             return inorderPrint(temp,root);
        * Method to return a String of the binary tree with an asterix beside the
        * current position.
        * @param currentPosition The current position.
        * @return A String of the tree with an asterix by the current position
       public String toString(BinaryTreeNode currentPosition) {
          if (root.getElement() == null) return "*** Tree is empty ***";
          else {
             MyBinaryTree temp = new MyBinaryTree(root,numNodes);
             return inorderPrint2(temp,root,currentPosition);
    }Those are all the methods I'm allowed to have. When I run makeEmpty, it seems to work, but then if I do makeRoot, the old tree prints again. It's quite bizarre. Any tips on how to empty the tree correctly?

    Here is the BinaryTreeNode code.
    public class BinaryTreeNode {
        // Instance variables (Note: they are all "private")
        protected Comparable key;           // The key at this node
        protected Object element;          // The data at this node
        protected BinaryTreeNode left;     // Left child
        protected BinaryTreeNode right;    // Right child
        protected BinaryTreeNode p;        // The Parent
        // Constructors
        BinaryTreeNode( Comparable theKey, Object theElement, BinaryTreeNode lt,
                        BinaryTreeNode rt, BinaryTreeNode pt  ) {
            key      = theKey;
            element  = theElement;
            left     = lt;
            right    = rt;
            p        = pt;
        BinaryTreeNode( Comparable theKey, Object theElement) {
            key      = theKey;
            element  = theElement;
            left     = null;
            right    = null;
            p        = null;
        // return the key attached to this node
        public Comparable getKey() {
            return key;
        // set the key attached to this node to be Comparable k
        public void setKey(Comparable k) {
            key = k;
        // return the element attached to this node
        public Object getElement() {
            return element;
        // set the element attached to this node to be Object o
        public void setElement(Object o) {
            element = o;
        // return left child
        public BinaryTreeNode leftChild() {
            return left;
        // set left child to be node n
        public void setLeftChild(BinaryTreeNode n) {
            left = n;
        // return right child
        public BinaryTreeNode rightChild() {
            return right;
        // set right child to be node n
        public void setRightChild(BinaryTreeNode n) {
            right = n;
        // return parent
        public BinaryTreeNode parent() {
            return p;
        // set parent to be node n
        public void setParent(BinaryTreeNode n) {
            p = n;
    }

  • StringIndexOutOfBoundsException using ARRAY data type

    Hi all.
    JDK 1.5.0_03, Oracle 9.2.0.4, 9i thin drivers.
    I'm trying to use the ARRAY data type to submit a large amount of data to a stored procedure. Unfortunatley I'm getting an error when using the oracleCAllableStatement.setArray method. I've successfully set up my types in the database, and I can create my StructDescriptor and ArrayDescriptor objects but that's as far as I get.
    Here's my code:
    connection = ConnectionManager.getRawConnection(DatabaseProperties.CSA_DB);
    connection.setAutoCommit(false);
    ARRAY array = getDatabaseArray(timeSeriesList, date, connection);
    String result = new String();
    statement = (OracleCallableStatement)connection.prepareCall("{call DATA_LOAD.ARCHIVE_TIMESERIES(?, ?)");
    statement.setARRAY(1, array);
    statement.registerOutParameter(2, OracleTypes.VARCHAR, result);
    statement.execute();
    LOG.info(result);
    connection.commit();
    The line highlighted is where it fails. The exception is below. Unfortunatley its a Java exception rather than a Oracle one so not much help there.
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 40
         at java.lang.String.charAt(Unknown Source)
         at oracle.jdbc.driver.OracleSql.handleODBC(OracleSql.java:123)
         at oracle.jdbc.driver.OracleSql.parse(OracleSql.java:69)
         at oracle.jdbc.driver.OracleConnection.nativeSQL(OracleConnection.java:1181)
         at oracle.jdbc.driver.OracleStatement.expandSqlEscapes(OracleStatement.java:6412)
         at oracle.jdbc.driver.OracleStatement.parseSqlKind(OracleStatement.java:6401)
         at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:152)
         at oracle.jdbc.driver.OracleCallableStatement.<init>(OracleCallableStatement.java:77)
         at oracle.jdbc.driver.OracleCallableStatement.<init>(OracleCallableStatement.java:48)
         at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1134)
         at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:988)
         at com.db.csa.systems.csa.timeseries.DataArchivedTimeSeriesProvider.archiveTimeseriesForDate(DataArchivedTimeSeriesProvider.java:46)
         at com.db.csa.experiments.TimeseriesArchiver.main(TimeseriesArchiver.java:26)
    I'm now completely stuck as short of decompiling the class that's throwing the exception I have no idea what's going on.
    Anyone got any ideas?
    Thanks, Rob
    Message was edited by:
    user470390

    Hi,
    Shouldn't:
    statement = (OracleCallableStatement)connection.prepareCall("{call DATA_LOAD.ARCHIVE_TIMESERIES(?, ?)");be this:
    statement = (OracleCallableStatement)connection.prepareCall("{call DATA_LOAD.ARCHIVE_TIMESERIES(?, ?)}");i.e. have a closing brace?
    - Mark

  • Updating VARRAYs usin PrepareStatement

    I have the folling code:
    // Read array from recordset
    ARRAY x =
    ttProvider.rs.getARRAY( ttProvider.X );
    String b[] = (String[])x.getArray();
    My problem is that I want to use the OraclePrepereStatement.setARRAY(index, ARRAY) but I dont know how to manipulate the ARRAY type. There is no setArray method.
    Please respond asap.
    Claus Christensen, Autocom Aps
    null

    i went through a lot of that wiki article but it
    didnt tell me how i can make 1. im using a derby
    database
    http://db.apache.org/derby/docs/10.2/ref/rrefsqlj37836.html
    That a good life lesson as well. The Wiki article was the general background,
    but if you want specific information about product X, consider reading
    the documentation for product X.

  • Oracle, SELECT IN and PreparedStatement.setArray

    I want to execute the following query: SELECT * FROM SOMETABLE WHERE IDFIELD IN (?)
    The number of values in the IN list is variable. How can I do this with a prepared statement?
    I am aware of the different alternatives:
    1) Keep a cache of prepared statement for each sized list seen so far.
    2) Keep a cache of prepared statements for different sizes (1, 5, 10, 20) and fill in the left over parameter positions with the copies first value.
    They both have the disadvantage that there could be many prepared statements for each query that get used once, and never used again.
    I have tried this:
    stmt.execute ("CREATE OR REPLACE TYPE LONGINTLIST AS TABLE OF NUMBER(15)");
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor ("LONGINTLIST", conn);
    long idValues [] = {2, 3, 4};
    oracle.sql.ARRAY paramArray = new oracle.sql.ARRAY (desc, conn, idValues);
    PreparedStatement query = conn.prepareStatement ("SELECT * FROM MYTABLE WHERE ID_FIELD IN (?)");
    query.setArray (1, paramArray);
    But Oracle gives a data conversion error.
    I then tried this:
    PreparedStatement query = conn.prepareStatement ("SELECT * FROM MYTABLE WHERE ID_FIELD IN (SELECT * FROM TABLE (?))");
    This works and the rows are returned, but the Oracle optimizer does not like it very much, since it always does a full table scan even though there is a primary key index on ID_FIELD.
    Any ideas?
    I also tried this:
    OraclePreparedStatement oraQuery = (OraclePreparedStatement) query;
    oraQuery.setARRAY (1, paramArray);
    But same behavior.
    Roger Hernandez

    Please re-read the original message. As I mentioned,
    I am aware of the two commonly used alternatives.No actually the most used alternative is to build the SQL dynamically each time.
    I know how to get both of them to work, and have used
    both alternatives in the past. The downside to both
    these approaches is that you need to save multiple
    prepared statements for each query. What I am trying
    to find is a way of having only one saved prepared
    statement for a query having a variable number of IN
    clause parameters.You could probably use a stored procedure that takes an 'array' and then do the processing in the stored proc to handle each array element.
    However, your database might not support that stored procs or arrays. Or it might not cache it with arrays. And the overhead of creating the array structure or processing it in the proc might eat any savings that you might gain (even presuming there is any savings) by using a prepared statement in the first place. Of course given that you must be using an automated profiling tool and have a loaded test environment you should be able to easily determine if this method saves time or not.
    Other than that there are no other solutions.

  • ActiveX Object Creation method to pass to an Invoke Node

    Hi!
    I'm trying to optimize the way in which I use MathCAD from LabVIEW.  One of my VIs is having really poor performance in terms of execution speed and memory usage.
    My VI converts a 2D LabVIEW array of doubles into a 2d Mathcad matrix and puts that matrix into a Mathcad worksheet.  The issue is that you do not just pass the 2d array of doubles into the SetValue invoke node as a variant.  You have to create a Mathcad.MatrixValue object, and then pass the object to the SetValue invoke node.
    Here is the example code provided in the Mathcad developers manual:
    SetElement Method
    var m = CreateObject("Mathcad.MatrixValue");
    for(row = 49; row >=
    0; --row)
    for(col = 9; col >= 0;
    --col)
    var val = row + col;
    m.SetElement(row, col, val);
    Here is my implimentation in LabVIEW:
    Here is my SubVI
     Here is my main VI:
    My SubVI is running out of memory and throwing the following error:
     Exception occured in mplrun: Exception of type 'System.OutOfMemoryException' was thrown. in NL SubVIs Library.lvlib:Convert LabVIEW 2d Array to MathCAD Variant Matrix (SubVI).vi->test.vi
    It doesn't always throw the error.  When I watch the memory consumption of LabVIEW it goes up to about 250k and then drops to 90k and slowly builds back up to 250k.  Initialy starting the code takes awhile too on my computer.  From start of VI until first loop iteration it is about 20 seconds, and then about 150-250ms after that.  Not very good performance.
    Any advice on how to optimize this code would be appreciated.  I'm not really sure when I should close some of these references.  I tried closing the reference in my converting SubVI, but I guess that destroys it so MathCAD can't use it.
    I'm in LabVIEW 2009.  Any help is appreciated. 
    Thanks for your time and input!
    -Nic

    I'm not sure this will solve your problems but it should help.  You need to close ALL of your references to Mathcad objects when you're done using them.  That means you need to close the reference to the Mathcad MatrixValue after you pass it to Mathcad (to do this you'll need to convert it back from a variant, or pass the reference directly out of your subVI), and you should also close the reference to the matrix that you get back after you've converted it to a LabVIEW array.  Otherwise you'll continuously allocate more and more memory rather than allowing it to be reused.
    Less importantly, you should also close your references to IMathcadWorksheets and IMathcadWorksheet (but since you only open them once it's not causing your memory problems).

  • PreparedStatement.setArray() ... again

    Hi Joe;
    I am aware that weblogic pool driver does not support Oracle Array's
    via .setArray. This is because Oracle Array's require
    ArrayDescriptor, and when I call this class with a Weblogic Pool
    Connection, a ClassCastException is thrown because the Connection
    object is not an OracleConnection.
    Is there anyway I can use PreparedStatement.setArray() without
    getting this ClassCastException? Are there any known workarounds that
    prevents me from having to use Oracle Specific classes?
    I am using WLS 6.1sp4 on Oracle 9i
    Thanks,
    [email protected]

    Paul Rowe wrote:
    Hi Joe;
    I am aware that weblogic pool driver does not support Oracle Array's
    via .setArray. This is because Oracle Array's require
    ArrayDescriptor, and when I call this class with a Weblogic Pool
    Connection, a ClassCastException is thrown because the Connection
    object is not an OracleConnection.
    Is there anyway I can use PreparedStatement.setArray() without
    getting this ClassCastException? Are there any known workarounds that
    prevents me from having to use Oracle Specific classes?
    I am using WLS 6.1sp4 on Oracle 9iHi. In 6.1sp5 we implement a method on pool connections, getVendorConnection(),
    which for those intractible cases where Oracle secretly requires a specific class
    (it's secret because the method signatues says it takes a java.sql.Connection),
    we provide a way to get a direct reference to the pooled oracle connection.
    This is dangerous, because it gives application code a backdoor to the pooled
    resource, and we can never again guarantee that future pool users are getting
    sole access to the connection. Therefore, by default we will close and replace
    any pooled connection after it is exposed in this way. Read the docs on this option,
    and I can give advice too on the safe things to do with an exposed connection,
    and later, how to retrieve the performance lost to the pool having to replace
    exposed connections....
    Joe
    >
    >
    Thanks,
    [email protected]

  • Java.sql.PreparedStatement.setArray( ) not found in J2SE v1.3.1?

    Why do I get the error method setArray(int, Array) not found in interface java.sql.PreparedStatement? As per on-line documentation the method is available since version 1.2.
    In JDeveloper help I have read that...
    "JDeveloper uses J2SE definitions to describe an installed J2SE environment. This environment can be either a JRE (Java Runtime Engine) or an SDK. Note that if you are using a JRE, some features may not be available. Every JDeveloper project uses a J2SE definition to determine what version of the Java API to compile and run with."
    Is my problem because my JDeveloper installation is using a JRE and not an SDK?

    Sounds like a SQL problem. Not an expert in DB2 bu you might want to try INSERT INTO SESSION (col1name, col2name) VALUES (?,?);
    Edited by: Kungen on Sep 19, 2007 6:46 AM

  • Need help with a remove method..

    Hello. I'm getting started on a project here to implement a recursive remove method that will remove any number from a list. I was given a test that the method must pass, but I'm having some trouble getting started. This is my second interaction with the idea of recursion and it's a bit difficult for me.
    Here is the test I'm writing the method for:
    public void testRemove() {
              int element=0;
              boolean inList = false;
              for (int i = -10; i < 11; i++)list.insert(i);
              int numElements = list.length();
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-1)));
              element = -10;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-2)));
              element = 10;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-3)));
              //does remove work when element's value greater than value of last item in list
              element = 20;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-3)));
              //does remove work when element's value less than value of first item in list
              element = -20;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-3)));
              System.out.printf("%s\n", "testRemove " + list.toString());
         }Now, clearly I need to test whether or not the number being removed is in the list (too low/too high), but I'm stuck trying to implement this.
    If anyone can give me any ideas or direction it would be greatly appreciated.

    Thanks for the quick reply, from what I had gathered and what you posted I'm starting to see where I need to go from here. I had gotten as far as if list is null return null, and the cod that you posted makes sense, but implementing it into the source code I already have will be troubling for me. The code as you presented it I have no trouble understanding, for example:
    if (list.data == data) return list.next;
    list.next=remove(list.next, data);Is clear to me, however I don't know how to implement that into my code. This is the code for the insert method:
         private Node<ElementType> insertp(Node<ElementType> list, ElementType element) {
              if ( (list == null) || ( element.compareTo(list.getElement() ) < 0 ) ) {
                   // test for insert at head or before current node
                   Node<ElementType> newNode = new Node<ElementType>(element, null);
                   newNode.setNext(list);
                   return newNode;
              else if (list.getNext() == null) { // list with one element
                   Node<ElementType> newNode = new Node<ElementType>(element, null);
                   list.setNext(newNode);         // element goes at end
              else if ( element.compareTo(list.getNext().getElement()) < 0 ) { // insert after list
                   Node<ElementType> newNode = new Node<ElementType>(element, list.getNext());
                   //newNode.setNext(list.getNext());
                   list.setNext(newNode);
              else {
                   insertp(list.getNext(), element); // find insertion point
              return list;
         }I'm still struggling to understand all of the code there. the element.compareTo() and everything. If you (or some one else) can explain to me what is going on with those methods, I may be able to implement it myself. Also, this may be of some use, these are the methods I have available to me:
    public class Node<E> {
      // Instance variables:
      private E element;
      private Node<E> next;
      /** Creates a node with null references to its element and next node. */
      public Node() {
        this(null, null);
      /** Creates a node with the given element and next node. */
      public Node(E e, Node<E> n) {
        element = e;
        next = n;
      // Accessor methods:
      public E getElement() {
        return element;
      public Node<E> getNext() {
        return next;
      // Modifier methods:
      public void setElement(E newElem) {
        element = newElem;
      public void setNext(Node<E> newNext) {
        next = newNext;
      public String toString() {
           return element.toString();
    }

  • How to dump array created by 'getrows method' into spreadsheet??

    hi,
    I'm sorry but I'm not goot as English.
    I'm trying to dump oo4o dynasets into farpoint spreadsheet without looping.
    first, I created the array of variant type through the 'getrows' method of oo4o.
    the 'getrows' method copies records from a Dynaset into a two-dimensional array. The first subscript identifies the field and the second identifies the row number.
    Then I found the method 'setarray' of spreadsheet but this method dumps a array into spread
    beginning with the row number. In result the spreadsheet views the recordset that the rows
    and the columns are exchanged.
    Please, Advice about my trying.

    MESSAGE FROM THE FORUMS ADMINISTRATORS and COMMUNITY
    This thread will be deleted_ within 24 business hours. You have posted
    an off-topic question in an area clearly designated for discussions
    about the features and functionality of the forums site. Community
    members looking to help you with your question won't be able to find
    it in this category.
    Please use the "Search Forums" element on the left panel to locate
    a forum based on your topic. A more appropriate forum for this post
    could be:
    New to Java http://forum.java.sun.com/forum.jspa?forumID=54

Maybe you are looking for