Linklist and dynamic array in java?

how to define linklist object and to build dynamic array in java?

with so little information, all one can do is pointing you to :
http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html

Similar Messages

  • How to declare a dynamic array in java

    I have to use a dynmic array of boolean and the size of this array will defiend throuh the run of the program to explian
    boolean[][] a;
    a=new boolean[number_of_ raw][number_of_ culm];
    after the program run the number_of_ raw and number_of_ culm will defind..so if any body know how to declare this kind of arraies in java please help me.

    My previous post gives me an idea on how to use ArrayList of ArrayList as dynamic 2 dimensional array.
    More info bellow
    ArrayList rows = new ArrayList()
    ArrayList columns_of_row0 = new ArrayList()
    rows.insertAt(0) = columns_of_row0;
    ArrayList columns_of_row1 = new ArrayList()
    rows.insertAt(1) = columns_of_row1;and so on..
    You can't use the code exactly or similar way, it would depend on how this array grows in your application.
    But this and my previous post should give an idea on how to insert and retrieve elements from ArrayList when
    treated as 2 dimensional array.
    Hope this helps.

  • Creating dynamic array

    Can anybody tell me how to create a dynamic array in Java??I dont want to fix size of array,it should take any number of values at runtime.Please tell me the syntax of using dynamic arrays.

    Hi,
    For creating an array of similar data elements, use
    ArrayList., but for storing elements which are in the
    form of object then use Vector...
    Best of Luck..
    R SWrong... the main different between ArrayList and Vector is that Vector was sychronized and ArrayList are not.

  • About dynamic array

    Which one does Java support ?
    Fixed heap-dynamic array or heap-dynamic array.
    I'm so confused ~.~

    so, does it mean that java support both fixed heap
    dynamic array and heap dynamic array?Java supports both static (fixed length) arrays and dynamic (variable length) arrays. The static arrays belong to the core language. The dynamic array implementation, called ArrayList, is part of a standard library, called the Collections Framework. In both cases they're used as objects and thus stored on the heap (it's currently not possible to allocate an object on the stack).

  • Populating a dynamic array with objects and managing it in runtime.

    So I'm another stuck firstyear. I'll try and make my question compact. I'm using Flash CS6 and have drawn an animated character on the stage that consists of separate parts that are animated and its head is a separate class/symbol entirely because it has not only animation, but a state switch timeline as well. This said Head extends the Main that is the character MovieClip.
    I am using a dynamic array to store and .push and .splice objects of another class that would collide with this said Head.
    I also discovered the super() function that is implicitly called as the constructor of the parent in any child class that extends the parent, in this case Head extends Main. The issue is that my collidable object array is populated within the main, within the function that spawns every next collidable object with a TimerEvent. This said function then gets called twice due to the super() call.
    I have tried putting this super() call into an impossible statement in my child class, but it doesn't change a thing, and it was said that this method is unsafe so I don't even know if it should be working.
    However what confuses me the most is when I trace() the .length of my collidable object array at the end of that function. As I said earlier, the original function both spawns an object after a period of Timer(1000) and adds it to the stage as well as adds the object onto the object array, but the super() constructor only duplicates the length call and a creates a copy of the object on the stage, but it does not add the second copy of the object onto the array. The trace() output goes on like so:
    1
    1
    2
    2
    3
    3
    4
    4
    etc.
    I wonder why and I'm really stumped by this.
    Here is the code in question:
    public class Main extends MovieClip {
                        public var nicesnowflake: fallingsnow;
                        var nicesnowflakespawntimer: Timer = new Timer(1000);
                        public var nicesnowflakearray: Array = new Array();
                        public function Main() {
                                  nicesnowflakespawntimer.addEventListener(TimerEvent.TIMER, nicesnowflakespawn);
                                  nicesnowflakespawntimer.start();
                        public function nicesnowflakespawn(event:TimerEvent) : void {
                                  nicesnowflake = new fallingsnow;
                                  nicesnowflake.x = Math.random()* stage.stageWidth;
                                  nicesnowflake.y = - stage.stageHeight + 100;
                                  nicesnowflakearray.push(nicesnowflake);
                                  stage.addChild(nicesnowflake);
                                  trace(nicesnowflakearray.length);
                                  for (var i:Number = 0; i < nicesnowflakearray.length; i++){
                                            nicesnowflakearray[i].addEventListener(Event.ENTER_FRAME, snowhit);
                        public function snowhit(event:Event) : void {
                                  if (nicesnowflakearray[0].y >= 460){
                                            if (nicesnowflakearray[0].y == stage.stageHeight) {
                                            nicesnowflakearray.splice(nicesnowflakearray.indexOf(nicesnowflake), 1);
                                  //if (this.hitTestObject(nicesnowflake)){
                                            //trace("hit");
    I am also fiddling with the collision, but I believe that it would sort itself out when I deal with the array pop and depop properly. However I'm pasting it anyway in case the issue is subtly hidden somewhere I'm not looking for it. And here is the child class:
    public class Head extends Main {
                        public function Head(){
                                  if (false){
                                            super();
                                  this.stop();
    So like what happens at the moment is that the array gets populated by the first object that spawns, but there is two objects on the stage, then when the objects reach stage.460y mark the array splices() the one object away and displays an error:
    "#1010: A term is undefined and has no properties.
              at Main/snowhit()"
    then when the next object spawns, it repeats the process. Why does it trace the array.length as "1, 1, 2, 2, 3, 3, 4, 4, 5, 5, etc" until the despawn point and then goes on to display an error and then starts from 1 again, because if the array length is more than one object at the time when the first object of the array gets spliced away, shouldn't it go on as usual, since there are other objects in the array?
    Thank you very much to whomever will read this through.

    There are multiple problems:
    1. You should add eventlisteners for your objects only once, but you add eventlisteners every time your timer runs to all of your snowflakes, again and again:
                                  for (var i:Number = 0; i < nicesnowflakearray.length; i++){
                                            nicesnowflakearray[i].addEventListener(Event.ENTER_FRAME, snowhit);
    change it to
    nicesnowflake.addEventListener(Event.ENTER_FRAME, snowhit);
    I don`t see why its even necessary to employ this snowflakearray, it would be much straight forward if you simply let the snowflakes take care of themselves.
    2. Then you have to change your enterframe function accordingly
    public function snowhit(event:Event) : void {
                                  if (e.currentTarget.y >= 460){
                                            if (e.currentTarget.y == stage.stageHeight) {
                                            e.currentTarget.removeEventlistener(Event.ENTER_FRAME, snowhit);
                                            removeChild(e.currentTarget);
    3.
                                  //if (this.hitTestObject(nicesnowflake)){
                                            //trace("hit");
    since "this" is a reference to the Main class (root) it surely won`t function as you intend it to.
                                  if (false){
                                            super();
    makes no sense to use a condition that can never be true

  • Java Beans and JSP Arrays

    Hi..
    I am trying to pass a 2D String array to a Java Bean and i am getting
    "java.lang.NoSuchMethodError"
    Any Ideas?
    Thanks
    Joe
    Jsp Call
    Sorts s = new Sorts();
    s.getTotal(items);
    "items[][]" is a 2 dimentional arrays and size can vary..
    Java Bean
    public class Sorts implements Serializable {
    public double getTotal(String sItems[][]){
    double aSum=0;
    for(int i=0;i<sItems[0].length;i++){
    aSum=aSum+(Double.parseDouble(sItems[1])*Double.parseDouble(sItems[2][i]));
    return aSum;

    Can someone show me how to pass a 2 Dimentional Array to a Java Bean method? obviously i am doing something wrong.
    Joe
    Hi..
    I am trying to pass a 2D String array to a Java Bean
    and i am getting
    "java.lang.NoSuchMethodError"
    Any Ideas?
    Thanks
    Joe
    Jsp Call
    Sorts s = new Sorts();
    s.getTotal(items);
    "items[][]" is a 2 dimentional arrays and size can
    vary..
    Java Bean
    public class Sorts implements Serializable {
    public double getTotal(String sItems[][]){
    double aSum=0;
    for(int i=0;i<sItems[0].length;i++){
    aSum=aSum+(Double.parseDouble(sItems[1])*Double.pars
    Double(sItems[2][i]));
    return aSum;

  • How  to Pass String array from Java to PL/SQL  and this use in CURSOR

    hi,
    I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
    This array containing like (SYMPTOM ) to be returned from the java to the
    pl/sql (I am not querying the database to retrieve the information).
    I cannot find an example on this. I will give the PL/SQL block
    create or replace procedure DISEASE_DTL<*** String Array ***> as
    v_SYMPTOM number(5);
    CURSOR C1 is
    select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
    where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
    group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
    order by a.DISEASE_NAME ;
    begin
    for C1rec IN C1 loop
    select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
    insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
    values (SL_ID_SEQ.nextval,
    C1rec.DISEASE_NAME,
    (4/v_SYMPTOM), --------**** 4 is no of array element (n)************
    (1-(4/v_SYMPTOM)));
    end loop;
    commit;
    end DISEASE_DTL;
    Please give the proper solution and step ..
    Thanking you,
    Asish

    I've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
    http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/

  • Call stored function / stored procedure from JAVA/JPA and pass array

    I fail calling a plsql function from java with jpa - it works perfect without the array but its not working with the array:
    PLSQL Function:
    function getHtml(pWhere VARCHAR2 DEFAULT NULL,
    pColSort HTP.STRINGARRAY) return clob is
    begin
    errorhndl.Log(pMessage => 'called');
    htp.prn('das ist der test
    for i in 1 .. pColSort.count loop
    htp.p('
    pColSort['||i||']: '||pColSort(i));
    end loop;
    htp.prn('
    <table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
    htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
    htp.prn('test ende');
    return htp.gHtpPClob;
    exception
    when others then
    null;
    end getHtml;
    PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
    type STRINGARRAY is table of varchar2(256) index by binary_integer;
    JAVA DOA:
    public class ShowReportDOAImpl implements ShowReportDOA {
    private JdbcTemplate jdbcTemplate;
    private SimpleJdbcCall procShowReport;
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
    procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
    .withCatalogName("Show_Report")
    .withFunctionName("getHtml")
    .withoutProcedureColumnMetaDataAccess()
    .declareParameters(
    new SqlParameter("pWhere", Types.VARCHAR),
    new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
    new SqlOutParameter("RETURN", Types.CLOB)
    public String readReport(Long id, ParameterHelper ph) {
    String[] sortCol = {"max", "michi", "stefan"};
    String pWhere = "fritz";
    MapSqlParameterSource parms = new MapSqlParameterSource();
    parms.addValue("pWhere", pWhere);
    parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
    parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
    Clob clob = procShowReport.executeFunction(Clob.class, parms);
    String clobString = "";
    try {
    System.out.println("length: "+new Long(clob.length()).intValue());
    clobString = clob.getSubString(1, new Long(clob.length()).intValue());
    } catch (SQLException e) {
    e.printStackTrace();
    return clobString;
    EXCEPTION IS:
    org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
    org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
    org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
    org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
    org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
    org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
    at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
    at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    root cause
    java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
    oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
    oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
    oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
    org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
    org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
    org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
    org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
    org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
    org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
    org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
    org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
    org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
    org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
    at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
    at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    Please help!!
    Please help!!

    user8374822 wrote:
    PLSQL Function:
    function getHtml(pWhere VARCHAR2 DEFAULT NULL,
    pColSort HTP.STRINGARRAY) return clob is
    begin
    end getHtml;
    PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
    type STRINGARRAY is table of varchar2(256) index by binary_integer;
    JAVA DOA:
    new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),I don't know much (??) java and can't understand your error messages as they are not in english.
    But I have a feeling that the error is because either
    a) "Types.ARRAY" in Java world probably does not map to an index-by table in oracle or
    b) the array must be created as a SQL TYPE and not as a package variable or
    c) both of the above
    You may want to try following approaches
    1) Change the array type declaration to nested table i.e. use "type STRINGARRAY is table of varchar2(256)"
    2) If the above does not work, then create a sql type (using CREATE TYPE statement) to create STRINGARRAY as a SQL type of varchar2(256)
    Hope this helps.

  • Passing Array of java objects to and from oracle database-Complete Example

    Hi all ,
    I am posting a working example of Passing Array of java objects to and from oracle database . I have struggled a lot to get it working and since finally its working , postinmg it here so that it coudl be helpful to the rest of the folks.
    First thinsg first
    i) Create a Java Value Object which you want to pass .
    create or replace and compile java source named Person as
    import java.sql.*;
    import java.io.*;
    public class Person implements SQLData
    private String sql_type = "PERSON_T";
    public int person_id;
    public String person_name;
    public Person () {}
    public String getSQLTypeName() throws SQLException { return sql_type; }
    public void readSQL(SQLInput stream, String typeName) throws SQLException
    sql_type = typeName;
    person_id = stream.readInt();
    person_name = stream.readString();
    public void writeSQL(SQLOutput stream) throws SQLException
    stream.writeInt (person_id);
    stream.writeString (person_name);
    ii) Once you created a Java class compile this class in sql plus. Just Copy paste and run it in SQL .
    you should see a message called "Java created."
    iii) Now create your object Types
    CREATE TYPE person_t AS OBJECT
    EXTERNAL NAME 'Person' LANGUAGE JAVA
    USING SQLData (
    person_id NUMBER(9) EXTERNAL NAME 'person_id',
    person_name VARCHAR2(30) EXTERNAL NAME 'person_name'
    iv) Now create a table of Objects
    CREATE TYPE person_tab IS TABLE OF person_t;
    v) Now create your procedure . Ensure that you create dummy table called "person_test" for loggiing values.
    create or replace
    procedure give_me_an_array( p_array in person_tab,p_arrayout out person_tab)
    as
    l_person_id Number;
    l_person_name Varchar2(200);
    l_person person_t;
    l_p_arrayout person_tab;
    errm Varchar2(2000);
    begin
         l_p_arrayout := person_tab();
    for i in 1 .. p_array.count
    loop
         l_p_arrayout.extend;
         insert into person_test values(p_array(i).person_id, 'in Record '||p_array(i).person_name);
         l_person_id := p_array(i).person_id;
         l_person_name := p_array(i).person_name;
         l_person := person_t(null,null);
         l_person.person_id := l_person_id + 5;
         l_person.person_name := 'Out Record ' ||l_person_name ;
         l_p_arrayout(i) := l_person;
    end loop;
    p_arrayout := l_p_arrayout;
         l_person_id := p_arrayout.count;
    for i in 1 .. p_arrayout.count
    loop
    insert into person_test values(l_person_id, p_arrayout(i).person_name);
    end loop;
    commit;
    EXCEPTION WHEN OTHERS THEN
         errm := SQLERRM;
         insert into person_test values(-1, errm);
         commit;
    end;
    vi) Now finally create your java class which will invoke the pl/sql procedure and get the updated value array and then display it on your screen>Alternatively you can also check the "person_test" tbale
    import java.util.Date;
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    public class ArrayDemo
    public static void passArray() throws SQLException
    Connection conn = getConnection();
    ArrayDemo a = new ArrayDemo();
    Person pn1 = new Person();
    pn1.person_id = 1;
    pn1.person_name = "SunilKumar";
    Person pn2 = new Person();
    pn2.person_id = 2;
    pn2.person_name = "Superb";
    Person pn3 = new Person();
    pn3.person_id = 31;
    pn3.person_name = "Outstanding";
    Person[] P_arr = {pn1, pn2, pn3};
    Person[] P_arr_out = new Person[3];
    ArrayDescriptor descriptor =
    ArrayDescriptor.createDescriptor( "PERSON_TAB", conn );
    ARRAY array_to_pass =
    new ARRAY( descriptor, conn, P_arr);
    OracleCallableStatement ps =
    (OracleCallableStatement )conn.prepareCall
    ( "begin give_me_an_array(?,?); end;" );
    ps.setARRAY( 1, array_to_pass );
         ps.registerOutParameter( 2, OracleTypes.ARRAY,"PERSON_TAB" );
         ps.execute();
         oracle.sql.ARRAY returnArray = (oracle.sql.ARRAY)ps.getArray(2);
    Object[] personDetails = (Object[]) returnArray.getArray();
    Person person_record = new Person();
    for (int i = 0; i < personDetails.length; i++) {
              person_record = (Person)personDetails;
              System.out.println( "row " + i + " = '" + person_record.person_name +"'" );
                        public static void main (String args[]){
         try
                             ArrayDemo tfc = new ArrayDemo();
                             tfc.passArray();
         catch(Exception e) {
                        e.printStackTrace();
              public static Connection getConnection() {
         try
                             Class.forName ("oracle.jdbc.OracleDriver");
                             return DriverManager.getConnection("jdbc:oracle:thin:@<<HostNanem>>:1523:VIS",
                             "username", "password");
         catch(Exception SQLe) {
                        System.out.println("IN EXCEPTION BLOCK ");
                        return null;
    and thats it. you are done.
    Hope it atleast helps people to get started. Comments are appreciated. I can be reached at ([email protected]) or [email protected]
    Thanks
    Sunil.s

    Hi Sunil,
    I've a similar situation where I'm trying to insert Java objects in db using bulk insert. My issue is with performance for which I've created a new thread.
    http://forum.java.sun.com/thread.jspa?threadID=5270260&tstart=30
    I ran into your code and looked into it. You've used the Person object array and directly passing it to the oracle.sql.ARRAY constructor. Just curios if this works, cos my understanding is that you need to create a oracle.sql.STRUCT out of ur java object collection and pass it to the ARRAY constructor. I tried ur way but got this runtime exception.
    java.sql.SQLException: Fail to convert to internal representation: JavaBulkInsertNew$Option@10bbf9e
                        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
                        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
                        at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:239)
                        at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:274)
                        at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:115)
                        at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1314)
                        at oracle.sql.ARRAY.<init>(ARRAY.java:152)
                        at JavaBulkInsertNew.main(JavaBulkInsertNew.java:76)
    Here's a code snippet I used :
    Object optionVal[] =   {optionArr[0]};   // optionArr[0] is an Option object which has three properties
    oracle.sql.ArrayDescriptor empArrayDescriptor = oracle.sql.ArrayDescriptor.createDescriptor("TT_EMP_TEST",conn);
    ARRAY empArray = new ARRAY(empArrayDescriptor,conn,optionVal);If you visit my thread, u'll see that I'm using STRUCT and then pass it to the ARRAY constructor, which works well, except for the performance issue.
    I'll appreciate if you can provide some information.
    Regards,
    Shamik

  • Dynamic array

    how to implement dynamic array size in java...??
    say if i want to add the element in an array then how should i do it..??

    For dynamic array...Vector is the best one i
    est one i think....
    Sigh. Unless other code requires it (for example, JTable's DefaultTableModel),
    Arraylist is preferred over the legacy class Vector.
    And even then I wouldn't recommend ArrayList as the "best" list. What if the OP
    wanted to have a FIFO queue? Would you recommend ArrayList/Vector over
    LinkedList?

  • Dynamic Array resizing

    I have a class with some data members in it. Data for the objects comes frm a XML file. I have to parse out the xml file and create objects. Before reading the XML file i dunno as to how many objects i need to create. I wud like to know a way where I can dynamically increase the size of the object array as I read through the XMl file.
    Thanks in advance,
    Kris.

    This is the source:
    * @(#)ArrayList.java     1.36 01/12/03
    * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
    * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    package java.util;
    * Resizable-array implementation of the <tt>List</tt> interface.  Implements
    * all optional list operations, and permits all elements, including
    * <tt>null</tt>.  In addition to implementing the <tt>List</tt> interface,
    * this class provides methods to manipulate the size of the array that is
    * used internally to store the list.  (This class is roughly equivalent to
    * <tt>Vector</tt>, except that it is unsynchronized.)<p>
    * The <tt>size</tt>, <tt>isEmpty</tt>, <tt>get</tt>, <tt>set</tt>,
    * <tt>iterator</tt>, and <tt>listIterator</tt> operations run in constant
    * time.  The <tt>add</tt> operation runs in <i>amortized constant time</i>,
    * that is, adding n elements requires O(n) time.  All of the other operations
    * run in linear time (roughly speaking).  The constant factor is low compared
    * to that for the <tt>LinkedList</tt> implementation.<p>
    * Each <tt>ArrayList</tt> instance has a <i>capacity</i>.  The capacity is
    * the size of the array used to store the elements in the list.  It is always
    * at least as large as the list size.  As elements are added an ArrayList,
    * its capacity grows automatically.  The details of the growth policy are not
    * specified beyond the fact that adding an element has constant amortized
    * time cost.<p>
    * An application can increase the capacity of an <tt>ArrayList</tt> instance
    * before adding a large number of elements using the <tt>ensureCapacity</tt>
    * operation.  This may reduce the amount of incremental reallocation.<p>
    * <strong>Note that this implementation is not synchronized.</strong> If
    * multiple threads access an <tt>ArrayList</tt> instance concurrently, and at
    * least one of the threads modifies the list structurally, it <i>must</i> be
    * synchronized externally.  (A structural modification is any operation that
    * adds or deletes one or more elements, or explicitly resizes the backing
    * array; merely setting the value of an element is not a structural
    * modification.)  This is typically accomplished by synchronizing on some
    * object that naturally encapsulates the list.  If no such object exists, the
    * list should be "wrapped" using the <tt>Collections.synchronizedList</tt>
    * method.  This is best done at creation time, to prevent accidental
    * unsynchronized access to the list:
    * <pre>
    *     List list = Collections.synchronizedList(new ArrayList(...));
    * </pre><p>
    * The iterators returned by this class's <tt>iterator</tt> and
    * <tt>listIterator</tt> methods are <i>fail-fast</i>: if list is structurally
    * modified at any time after the iterator is created, in any way except
    * through the iterator's own remove or add methods, the iterator will throw a
    * ConcurrentModificationException.  Thus, in the face of concurrent
    * modification, the iterator fails quickly and cleanly, rather than risking
    * arbitrary, non-deterministic behavior at an undetermined time in the
    * future.
    * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
    * as it is, generally speaking, impossible to make any hard guarantees in the
    * presence of unsynchronized concurrent modification.  Fail-fast iterators
    * throw <tt>ConcurrentModificationException</tt> on a best-effort basis.
    * Therefore, it would be wrong to write a program that depended on this
    * exception for its correctness: <i>the fail-fast behavior of iterators
    * should be used only to detect bugs.</i>
    * @author  Josh Bloch
    * @version 1.36, 12/03/01
    * @see         Collection
    * @see         List
    * @see         LinkedList
    * @see         Vector
    * @see         Collections#synchronizedList(List)
    * @since   1.2
    public class ArrayList extends AbstractList
            implements List, RandomAccess, Cloneable, java.io.Serializable
        private static final long serialVersionUID = 8683452581122892189L;
         * The array buffer into which the elements of the ArrayList are stored.
         * The capacity of the ArrayList is the length of this array buffer.
        private transient Object elementData[];
         * The size of the ArrayList (the number of elements it contains).
         * @serial
        private int size;
         * Constructs an empty list with the specified initial capacity.
         * @param   initialCapacity   the initial capacity of the list.
         * @exception IllegalArgumentException if the specified initial capacity
         *            is negative
        public ArrayList(int initialCapacity) {
         super();
            if (initialCapacity < 0)
                throw new IllegalArgumentException("Illegal Capacity: "+
                                                   initialCapacity);
         this.elementData = new Object[initialCapacity];
         * Constructs an empty list with an initial capacity of ten.
        public ArrayList() {
         this(10);
         * Constructs a list containing the elements of the specified
         * collection, in the order they are returned by the collection's
         * iterator.  The <tt>ArrayList</tt> instance has an initial capacity of
         * 110% the size of the specified collection.
         * @param c the collection whose elements are to be placed into this list.
         * @throws NullPointerException if the specified collection is null.
        public ArrayList(Collection c) {
            size = c.size();
            // Allow 10% room for growth
            elementData = new Object[
                          (int)Math.min((size*110L)/100,Integer.MAX_VALUE)];
            c.toArray(elementData);
         * Trims the capacity of this <tt>ArrayList</tt> instance to be the
         * list's current size.  An application can use this operation to minimize
         * the storage of an <tt>ArrayList</tt> instance.
        public void trimToSize() {
         modCount++;
         int oldCapacity = elementData.length;
         if (size < oldCapacity) {
             Object oldData[] = elementData;
             elementData = new Object[size];
             System.arraycopy(oldData, 0, elementData, 0, size);
         * Increases the capacity of this <tt>ArrayList</tt> instance, if
         * necessary, to ensure  that it can hold at least the number of elements
         * specified by the minimum capacity argument.
         * @param   minCapacity   the desired minimum capacity.
        public void ensureCapacity(int minCapacity) {
         modCount++;
         int oldCapacity = elementData.length;
         if (minCapacity > oldCapacity) {
             Object oldData[] = elementData;
             int newCapacity = (oldCapacity * 3)/2 + 1;
                 if (newCapacity < minCapacity)
              newCapacity = minCapacity;
             elementData = new Object[newCapacity];
             System.arraycopy(oldData, 0, elementData, 0, size);
         * Returns the number of elements in this list.
         * @return  the number of elements in this list.
        public int size() {
         return size;
         * Tests if this list has no elements.
         * @return  <tt>true</tt> if this list has no elements;
         *          <tt>false</tt> otherwise.
        public boolean isEmpty() {
         return size == 0;
         * Returns <tt>true</tt> if this list contains the specified element.
         * @param elem element whose presence in this List is to be tested.
         * @return  <code>true</code> if the specified element is present;
         *          <code>false</code> otherwise.
        public boolean contains(Object elem) {
         return indexOf(elem) >= 0;
         * Searches for the first occurence of the given argument, testing
         * for equality using the <tt>equals</tt> method.
         * @param   elem   an object.
         * @return  the index of the first occurrence of the argument in this
         *          list; returns <tt>-1</tt> if the object is not found.
         * @see     Object#equals(Object)
        public int indexOf(Object elem) {
         if (elem == null) {
             for (int i = 0; i < size; i++)
              if (elementData==null)
              return i;
         } else {
         for (int i = 0; i < size; i++)
              if (elem.equals(elementData[i]))
              return i;
         return -1;
    * Returns the index of the last occurrence of the specified object in
    * this list.
    * @param elem the desired element.
    * @return the index of the last occurrence of the specified object in
    * this list; returns -1 if the object is not found.
    public int lastIndexOf(Object elem) {
         if (elem == null) {
         for (int i = size-1; i >= 0; i--)
              if (elementData[i]==null)
              return i;
         } else {
         for (int i = size-1; i >= 0; i--)
              if (elem.equals(elementData[i]))
              return i;
         return -1;
    * Returns a shallow copy of this <tt>ArrayList</tt> instance. (The
    * elements themselves are not copied.)
    * @return a clone of this <tt>ArrayList</tt> instance.
    public Object clone() {
         try {
         ArrayList v = (ArrayList)super.clone();
         v.elementData = new Object[size];
         System.arraycopy(elementData, 0, v.elementData, 0, size);
         v.modCount = 0;
         return v;
         } catch (CloneNotSupportedException e) {
         // this shouldn't happen, since we are Cloneable
         throw new InternalError();
    * Returns an array containing all of the elements in this list
    * in the correct order.
    * @return an array containing all of the elements in this list
    *      in the correct order.
    public Object[] toArray() {
         Object[] result = new Object[size];
         System.arraycopy(elementData, 0, result, 0, size);
         return result;
    * Returns an array containing all of the elements in this list in the
    * correct order; the runtime type of the returned array is that of the
    * specified array. If the list fits in the specified array, it is
    * returned therein. Otherwise, a new array is allocated with the runtime
    * type of the specified array and the size of this list.<p>
    * If the list fits in the specified array with room to spare (i.e., the
    * array has more elements than the list), the element in the array
    * immediately following the end of the collection is set to
    * <tt>null</tt>. This is useful in determining the length of the list
    * <i>only</i> if the caller knows that the list does not contain any
    * <tt>null</tt> elements.
    * @param a the array into which the elements of the list are to
    *          be stored, if it is big enough; otherwise, a new array of the
    *           same runtime type is allocated for this purpose.
    * @return an array containing the elements of the list.
    * @throws ArrayStoreException if the runtime type of a is not a supertype
    * of the runtime type of every element in this list.
    public Object[] toArray(Object a[]) {
    if (a.length < size)
    a = (Object[])java.lang.reflect.Array.newInstance(
    a.getClass().getComponentType(), size);
         System.arraycopy(elementData, 0, a, 0, size);
    if (a.length > size)
    a[size] = null;
    return a;
    // Positional Access Operations
    * Returns the element at the specified position in this list.
    * @param index index of element to return.
    * @return the element at the specified position in this list.
    * @throws IndexOutOfBoundsException if index is out of range <tt>(index
    *           < 0 || index >= size())</tt>.
    public Object get(int index) {
         RangeCheck(index);
         return elementData[index];
    * Replaces the element at the specified position in this list with
    * the specified element.
    * @param index index of element to replace.
    * @param element element to be stored at the specified position.
    * @return the element previously at the specified position.
    * @throws IndexOutOfBoundsException if index out of range
    *          <tt>(index < 0 || index >= size())</tt>.
    public Object set(int index, Object element) {
         RangeCheck(index);
         Object oldValue = elementData[index];
         elementData[index] = element;
         return oldValue;
    * Appends the specified element to the end of this list.
    * @param o element to be appended to this list.
    * @return <tt>true</tt> (as per the general contract of Collection.add).
    public boolean add(Object o) {
         ensureCapacity(size + 1); // Increments modCount!!
         elementData[size++] = o;
         return true;
    * Inserts the specified element at the specified position in this
    * list. Shifts the element currently at that position (if any) and
    * any subsequent elements to the right (adds one to their indices).
    * @param index index at which the specified element is to be inserted.
    * @param element element to be inserted.
    * @throws IndexOutOfBoundsException if index is out of range
    *          <tt>(index < 0 || index > size())</tt>.
    public void add(int index, Object element) {
         if (index > size || index < 0)
         throw new IndexOutOfBoundsException(
              "Index: "+index+", Size: "+size);
         ensureCapacity(size+1); // Increments modCount!!
         System.arraycopy(elementData, index, elementData, index + 1,
                   size - index);
         elementData[index] = element;
         size++;
    * Removes the element at the specified position in this list.
    * Shifts any subsequent elements to the left (subtracts one from their
    * indices).
    * @param index the index of the element to removed.
    * @return the element that was removed from the list.
    * @throws IndexOutOfBoundsException if index out of range <tt>(index
    *           < 0 || index >= size())</tt>.
    public Object remove(int index) {
         RangeCheck(index);
         modCount++;
         Object oldValue = elementData[index];
         int numMoved = size - index - 1;
         if (numMoved > 0)
         System.arraycopy(elementData, index+1, elementData, index,
                   numMoved);
         elementData[--size] = null; // Let gc do its work
         return oldValue;
    * Removes all of the elements from this list. The list will
    * be empty after this call returns.
    public void clear() {
         modCount++;
         // Let gc do its work
         for (int i = 0; i < size; i++)
         elementData[i] = null;
         size = 0;
    * Appends all of the elements in the specified Collection to the end of
    * this list, in the order that they are returned by the
    * specified Collection's Iterator. The behavior of this operation is
    * undefined if the specified Collection is modified while the operation
    * is in progress. (This implies that the behavior of this call is
    * undefined if the specified Collection is this list, and this
    * list is nonempty.)
    * @param c the elements to be inserted into this list.
    * @return <tt>true</tt> if this list changed as a result of the call.
    * @throws IndexOutOfBoundsException if index out of range <tt>(index
    *          < 0 || index > size())</tt>.
    * @throws NullPointerException if the specified collection is null.
    public boolean addAll(Collection c) {
         modCount++;
         int numNew = c.size();
         ensureCapacity(size + numNew);
         Iterator e = c.iterator();
         for (int i=0; i<numNew; i++)
         elementData[size++] = e.next();
         return numNew != 0;
    * Inserts all of the elements in the specified Collection into this
    * list, starting at the specified position. Shifts the element
    * currently at that position (if any) and any subsequent elements to
    * the right (increases their indices). The new elements will appear
    * in the list in the order that they are returned by the
    * specified Collection's iterator.
    * @param index index at which to insert first element
    *          from the specified collection.
    * @param c elements to be inserted into this list.
    * @return <tt>true</tt> if this list changed as a result of the call.
    * @throws IndexOutOfBoundsException if index out of range <tt>(index
    *          < 0 || index > size())</tt>.
    * @throws NullPointerException if the specified Collection is null.
    public boolean addAll(int index, Collection c) {
         if (index > size || index < 0)
         throw new IndexOutOfBoundsException(
              "Index: "+index+", Size: "+size);
         int numNew = c.size();
         ensureCapacity(size + numNew); // Increments modCount!!
         int numMoved = size - index;
         if (numMoved > 0)
         System.arraycopy(elementData, index, elementData, index + numNew,
                   numMoved);
         Iterator e = c.iterator();
         for (int i=0; i<numNew; i++)
         elementData[index++] = e.next();
         size += numNew;
         return numNew != 0;
    * Removes from this List all of the elements whose index is between
    * fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding
    * elements to the left (reduces their index).
    * This call shortens the list by <tt>(toIndex - fromIndex)</tt> elements.
    * (If <tt>toIndex==fromIndex</tt>, this operation has no effect.)
    * @param fromIndex index of first element to be removed.
    * @param toIndex index after last element to be removed.
    protected void removeRange(int fromIndex, int toIndex) {
         modCount++;
         int numMoved = size - toIndex;
    System.arraycopy(elementData, toIndex, elementData, fromIndex,
    numMoved);
         // Let gc do its work
         int newSize = size - (toIndex-fromIndex);
         while (size != newSize)
         elementData[--size] = null;
    * Check if the given index is in range. If not, throw an appropriate
    * runtime exception.
    private void RangeCheck(int index) {
         if (index >= size || index < 0)
         throw new IndexOutOfBoundsException(
              "Index: "+index+", Size: "+size);
    * Save the state of the <tt>ArrayList</tt> instance to a stream (that
    * is, serialize it).
    * @serialData The length of the array backing the <tt>ArrayList</tt>
    * instance is emitted (int), followed by all of its elements
    * (each an <tt>Object</tt>) in the proper order.
    private synchronized void writeObject(java.io.ObjectOutputStream s)
    throws java.io.IOException{
         // Write out element count, and any hidden stuff
         s.defaultWriteObject();
    // Write out array length
    s.writeInt(elementData.length);
         // Write out all elements in the proper order.
         for (int i=0; i<size; i++)
    s.writeObject(elementData[i]);
    * Reconstitute the <tt>ArrayList</tt> instance from a stream (that is,
    * deserialize it).
    private synchronized void readObject(java.io.ObjectInputStream s)
    throws java.io.IOException, ClassNotFoundException {
         // Read in size, and any hidden stuff
         s.defaultReadObject();
    // Read in array length and allocate array
    int arrayLength = s.readInt();
    elementData = new Object[arrayLength];
         // Read in all elements in the proper order.
         for (int i=0; i<size; i++)
    elementData[i] = s.readObject();

  • [Dynamic array creation]

    Hi,
    I would like to create an array (2 dimensions) but my problem is that
    I don't know in advance the length of the first dimension of my array.
    I can't do a first pass to have the length of the array because it's too long
    so i don't know how to do!!
    Is there something to dynamically resize the array in java ? or is there an other solution?
    here is the code :
    BOList = new String[2000][4];
                   if (busComp.firstRecord()) {
                        do {
                             BOList[cpt][0] = busComp.getFieldValue("Name");
                             BOList[cpt][1] = busComp.getFieldValue("Project Name");
                             BOList[cpt][2] = busComp.getFieldValue("Comments");
                             BOList[cpt][3] = busComp.getFieldValue("Id");
                             System.out.println("BO name: " + BOList[cpt][0] + " ID:"
                                       + busComp.getFieldValue("Id"));
                             cpt++;
                        } while (busComp.nextRecord());
                   }THX

    Use an ArrayList of ArraysLists instead... but,your
    This isn't something I'd recommend. It seems you've
    got a ResultSet and you're trying to unload it to a
    2D array. What's the reason you're doing this? It
    doesn't seem like good design to me.Did you read my whole reply? I said that he probably shouldn't use 2D arrays, and that he instead should create some kind of model/bo.
    Kaj

  • How can i maintain a dynamic array

    I want to maintain an dynamic array in my code . It shoud grow accroding to no of user inputs . 1 can entre 5 numbers and other 10 , then array size should grow orderly 5 and 10 like that . Array is int array.

    Read up on the Collections API. There is a tutorial on this site. At first blush, you want a List. If it will grow and you will not be removing and inserting constantly from the 'middle' of the list of items, then ArrayList is a logical choice as your List. Otherwise, use LinkedList. But definitely bone up on the tutorial. Understanding how Collections work is fundamental to any Java programming you will do.
    - Saish

  • JSP and dynamic email from form on web page

    I fairly new to JSP, I trying to create a form the will automatically send an email once an insert button is clicked. But in the email there will be to dynamic fields, like SSN and Last Name. These would be passed in from to textboxes on the page. Here is the code I have so far. Thanks for any help
    Joaquin
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%
    // Set Session Variable To Value Of Form Element - JSPSessions_102
    session.setAttribute
    ("SSN",
    request.getParameter
    ("txtSSN"));
    // Send Email From Web Page - JSPMail_101
    Properties props = new Properties();
    props.put("smtp.sbcglobal.yahoo.com", "smtp.sbcglobal.yahoo.com");
    Session s = Session.getInstance(props,null);
    MimeMessage message = new MimeMessage(s);
    InternetAddress from = new InternetAddress("[email protected]");
    message.setFrom(from);
    InternetAddress to = new InternetAddress("[email protected]");
    message.addRecipient(Message.RecipientType.TO, to);
    message.setSubject("New Employee.");
    message.setText("This is a test ");
    Transport.send(message);
    %>
    <%@ include file="Connections/conCap2.jsp" %>
    <%
    // *** Restrict Access To Page: Grant or deny access to this page
    String MM_authorizedUsers="";
    String MM_authFailedURL="loginFailedFac.htm";
    boolean MM_grantAccess=false;
    if (session.getValue("MM_Username") != null && !session.getValue("MM_Username").equals("")) {
    if (true || (session.getValue("MM_UserAuthorization")=="") ||
    (MM_authorizedUsers.indexOf((String)session.getValue("MM_UserAuthorization")) >=0)) {
    MM_grantAccess = true;
    if (!MM_grantAccess) {
    String MM_qsChar = "?";
    if (MM_authFailedURL.indexOf("?") >= 0) MM_qsChar = "&";
    String MM_referrer = request.getRequestURI();
    if (request.getQueryString() != null) MM_referrer = MM_referrer + "?" + request.getQueryString();
    MM_authFailedURL = MM_authFailedURL + MM_qsChar + "accessdenied=" + java.net.URLEncoder.encode(MM_referrer);
    response.sendRedirect(response.encodeRedirectURL(MM_authFailedURL));
    return;
    %>
    <%
    // *** Edit Operations: declare variables
    // set the form action variable
    String MM_editAction = request.getRequestURI();
    if (request.getQueryString() != null && request.getQueryString().length() > 0) {
    MM_editAction += "?" + request.getQueryString();
    // connection information
    String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;
    // redirect information
    String MM_editRedirectUrl = null;
    // query string to execute
    StringBuffer MM_editQuery = null;
    // boolean to abort record edit
    boolean MM_abortEdit = false;
    // table information
    String MM_editTable = null, MM_editColumn = null, MM_recordId = null;
    // form field information
    String[] MM_fields = null, MM_columns = null;
    %>
    <%
    // *** Insert Record: set variables
    if (request.getParameter("MM_insert") != null && request.getParameter("MM_insert").toString().equals("FacSupPo")) {
    MM_editDriver = MM_conCap2_DRIVER;
    MM_editConnection = MM_conCap2_STRING;
    MM_editUserName = MM_conCap2_USERNAME;
    MM_editPassword = MM_conCap2_PASSWORD;
    MM_editTable = "facsupport";
    MM_editRedirectUrl = "insertOk.jsp";
    String MM_fieldsStr = "txtSSN|value|txtLstNm|value|DkCHDo|value|doCompDK|value|GenOffSupDo|value";
    String MM_columnsStr = "SSN|',none,''|LstName|',none,''|DeskChair|',none,''|CompDsk|',none,''|GenOffSup|',none,''";
    // create the MM_fields and MM_columns arrays
    java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
    MM_fields = new String[tokens.countTokens()];
    for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();
    tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
    MM_columns = new String[tokens.countTokens()];
    for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();
    // set the form values
    for (int i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = ((request.getParameter(MM_fields)!=null)?(String)request.getParameter(MM_fields[i]):"");
    // append the query string to the redirect URL
    if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
    %>
    <%
    // *** Insert Record: construct a sql insert statement and execute it
    if (request.getParameter("MM_insert") != null) {
    // create the insert sql statement
    StringBuffer MM_tableValues = new StringBuffer(), MM_dbValues = new StringBuffer();
    for (int i=0; i+1 < MM_fields.length; i+=2) {
    String formVal = MM_fields[i+1];
    String elem;
    java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
    String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
    String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
    String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
    if (formVal.length() == 0) {
    formVal = emptyVal;
    } else {
    if (altVal.length() != 0) {
    formVal = altVal;
    } else if (delim.compareTo("'") == 0) {  // escape quotes
    StringBuffer escQuotes = new StringBuffer(formVal);
    for (int j=0; j < escQuotes.length(); j++)
    if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\'');
    formVal = "'" + escQuotes + "'";
    } else {
    formVal = delim + formVal + delim;
    MM_tableValues.append((i!=0)?",":"").append(MM_columns[i]);
    MM_dbValues.append((i!=0)?",":"").append(formVal);
    MM_editQuery = new StringBuffer("insert into " + MM_editTable);
    MM_editQuery.append(" (").append(MM_tableValues.toString()).append(") values (");
    MM_editQuery.append(MM_dbValues.toString()).append(")");
    if (!MM_abortEdit) {
    // finish the sql and execute it
    Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
    Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
    PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
    MM_editStatement.executeUpdate();
    MM_connection.close();
    // redirect with URL parameters
    if (MM_editRedirectUrl.length() != 0) {
    response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
    return;
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <form action="<%=MM_editAction%>" method="POST" name="FacSupPo" id="FacSupPo">
    <table width="575" border="1">
    <tr>
    <td><div align="center">
    <h2>Facilities Support Form Submition</h2>
    <p><strong>Please Check all of the Fields</strong></p>
    </div></td>
    </tr>
    </table>
    <p>  </p>
    <p>Please Enter Employees SSN </p>
    <p>
    <input name="txtSSN" type="text" id="txtSSN" value="<%= ((request.getParameter("txtSSN")!=null)?request.getParameter("txtSSN"):"") %>"readonly="true">
    </p>
    <p>Enter Last Name</p>
    <p>
    <input name="txtLstNm" type="text" id="txtLstNm" value="<%= ((request.getParameter("txtLstNm")!=null)?request.getParameter("txtLstNm"):"") %>"readonly="true">
    </p>
    <table width="575" border="1" cellspacing="0" bordercolor="#000000">
    <!--DWLayoutTable-->
    <tr bgcolor="#FF0000">
    <td height="23" colspan="3"> </td>
    </tr>
    <tr>
    <td width="179" height="102" valign="top">
    <p>
    <input name="DkCHDo" type="text" id="DkCHDo" value="<%= ((request.getParameter("DkCHDo")!=null)?request.getParameter("DkCHDo"):"") %>"size="9" readonly="true">
    </p>
    <p>Desk & Desk Chair</p>
    </td>
    <td width="191"><p>
    <input name="doCompDK" type="text" id="doCompDK" value="<%= ((request.getParameter("doCompDK")!=null)?request.getParameter("doCompDK"):"") %>"size="9" readonly="true">
    </p>
    <p>Computer Desk</p></td>
    <td width="191"><p>
    <input name="GenOffSupDo" type="text" id="GenOffSupDo" value="<%= ((request.getParameter("GenOffSupDo")!=null)?request.getParameter("GenOffSupDo"):"") %>"size="9" readonly="true">
    </p> <p>General Office Supplies</p>
    </td>
    </tr>
    <tr>
    <td height="31" colspan="3" valign="top">
    <div align="center">
    <p>
    <input type="submit" value=" Insert " name="Submit">
    </p>
    <p>Back </p>
    </div>
    </td>
    </tr>
    </table>
    <p> </p>
    <input type="hidden" name="MM_insert" value="FacSupPo">
    </form>
    </body>
    </html>

    This how I send out e-mail(s)
    'emailBean
    import java.io.*;
    import java.net.Socket;
    import java.net.SocketException;
    public class EMailBean {
         private Socket socket;
         private OutputStreamWriter outputStreamWriter;
         private BufferedReader bufferedReader;
         public void start( String subject, String message, String from, String to ) {
              try {
                   System.out.println( "Connection to smtp.host.com..." );
                   this.socket = new Socket( "smtp.host.com", 25 );
                   this.outputStreamWriter = new OutputStreamWriter( this.socket.getOutputStream() );
                   this.bufferedReader = new BufferedReader( new InputStreamReader( this.socket.getInputStream() ) );
                   System.out.println( "Connected!" );
                   System.out.println( "From server: " + bufferedReader.readLine() );
                   send( "helo smtp.host.com" );
                   send( "MAIL FROM:<" + from + ">" );
                   send( "RCPT TO:<" + to + ">" );
                   send( "DATA" );
                   send("Subject:"+subject+"\r\n\r\n"+message + "\r\n.\r\n" );
                   this.outputStreamWriter.close();
                   this.bufferedReader.close();
                   this.socket.close();
              catch( Exception e ) {
                   System.err.println( "Error: " + e.getMessage() );
                   e.printStackTrace();
         private void send( String sendMe ) throws Exception {
              System.out.println( "To server: " + sendMe );
              this.outputStreamWriter.write( sendMe + "\r\n" );
              this.outputStreamWriter.flush();
              System.out.println( "From server: " + this.bufferedReader.readLine() );
    }And the .jsp looks like:
    <jsp:useBean id="mailBean" scope="request" class="EMailBean" />
    <%
    try {
    String date = activateBean.doQuery();
    String from = "[email protected]";
    String to = "[email protected]";
    String subject = "Myserverspy - Activation";
    String emsg = "Dear " + to + ",";
    emsg += "\nsome text here, maybe recive some variables.";
    mailBean.start(subject, emsg, from, to);
    %>
    E-mail has been sent
    <%
    catch(Exception exp){
         System.out.println("Exception: "+exp);
    %>Just insert the parameters into the emsg string.
    Andreas

  • Passing an array from Java to Pl/SQL Procdures

    I am relatively new to the Java world and I am unable to pass back an array from Java back to the calling PL/SQL procedure. I have read many of the posts that deal with this issue and in specificly have viewed Ask Tom. My main issue is trying to get the data types matched up. I am able to return varchar2, numbers, and the like, but an array of filenames is not happening. I have tried a variety of "types" but unable to accomplish the task. Please help.
    I have my Java class basically defined as:
    public static oracle.sql.ARRAY[] getCollection(String directory)
                   throws SQLException
    { // provide a directory and get a listing of files
    File path = new File( directory );
    String[] list = path.list();
    return list;
    SQL Type and PL/SQL Procedure is:
    CREATE OR REPLACE TYPE PTO_FILE IS TABLE OF VARCHAR2(100);
    create or replace function get_dir_collection( p_directory in varchar2 ) RETURN PTO_FILE
         as language java
    name 'DirCollection.getCollection( java.lang.String ) return oracle.sql.ARRAY[]';
    /

    I know that it is not an ARRAY. It is however an "array" and I am attempting to map Java's String[][ to some "object" on the oracle side.  I have looked at the link you sited and was not able to find the data mapping.  I have found that mapping data types between different "languages" is some of the most difficult aspects of working with multiple languages.
    Any suggestions? Thanks

Maybe you are looking for

  • Error: Object variable or with variable not set while accessing BPC Excel

    Hi, I am working on BPC NW 7.5. When I am trying to access BPC for Excel I am getting the below error. 'object variable or with variable not set' When I click on BPC for Excel it ask for the credentials, after entering it we encounter this error. Any

  • Function module for getting periods for date range

    Hi, Can anybody tell me the function module which will return the periods along with the year, when we give a date range. e.g 01011999 to 120112000 so it shoud return peroids between these date with year. Its possible thru programatically, but i m ch

  • Updates for software, etc.

    Is there a way that a user (me) can be automatically notified of updates? Like on a weekly basis. Or do we have to keep checking ourselves. For example, only by chance, did I notice Apple had an update for Mountain Lion 10.8.1 today. If I hadn't know

  • Large data sets and table partitioning : removing data

    Hi, I have to delete lines into a big table using partition. Someone says me it is more efficient for the performances to drop a whole partition (or subpartition if I use a composite partition) than to delete a line at the same time. He says me that

  • Guidance needed for a decision

    Hi all,. I will be extreamly thankful if you will resolve my following queries. 1)Will you please tell me what exact abap is used by SCM/CRM/SRM-Technofunctional. 2)Secondly being an ABAPer is it manageble to learn SCM/CRM/SRM functional without doma