Accessing  table type from JAVA

Hi Experts,
We are making a custom copy of the std FM COM_BPUS_ORG_CONTPERS_REGISTER .
It is observed that Tables are obsolete and we should not use them in custom function modules.
I can pass a table type in import parameter and export parameter.
Can we access a table type from java layer.
Also, note that this STANDARD function module has parameter IT_BUSINESSPARTNERROLE_ORG which has table type BU_ROLE_T.
Is it possible to access this?
Note:- This Function module is not getting called in standard web shops.
Please let me now how i can access this table type for hava while calling FM so as to input or retrieve valus from it.
Regards
Antony

The issue with you is more than accessing a table type.
You said:
This Function module is not getting called in standard web shops.
For function modules that are not called as a part of the standard flow, you have to develop your own simple BOM, BO, BEI, BE classes and methods to call the custom RFC - the whole nine yards. See the extension guide and see the Extension Demos 2 and 3 for reference.
See the sample JCO calls from Java to understand how to access the table types.

Similar Messages

  • Referencing package table type from Java

    Hi,
    In my package spec, I have a table type defined. I just want to refer this from Java program in order to pass ARRAY object to a procedure inside the package. But I keep getting an errory saying "Invalid name pattern".
    But If I declare the type outside of the package, it works fine. Can anyone help me on this?
    Regards,
    Poornachandran R

    Hi,
    create or replace package msproot.spear$util as
    -- UUID table type
    type varchar32_t is table of varchar2(32) index by binary_integer;
    * Function name: getUUID
    * Desc: Retreive a unique id.
    * IN: maxNumOfUUID - integer, the quentity of UUID to generate, optional default 1.
    * OUT: UUID - an array of 32 characters string of UUID
    function getUUID(maxNumOfUUID number :=1 ) return varchar32_t;
    end spear$util;
    create or replace package body msproot.spear$util as
    -- get uuid - retun more the one UUID
    function getUUID(maxNumOfUUID number) return varchar32_t is
    uuidArr varchar32_t;
    begin
    -- generate the array of uuid up to maxNumOfUUID
    for i in 1..maxNumOfUUID loop
    select sys_guid into uuidArr(i) from dual;
    end loop;
    return (uuidArr);
    end getUUID;
    end spear$util;
    private String[] retrieveUuid(int maxNumOfUUID) throws Exception
    String[] arr = null;
    try {
    // generate a free spear ids array from the database
    // Use a PL/SQL block to open the stored procedure
    OracleCallableStatement ocstmt =
    (OracleCallableStatement) conn
    .prepareCall("begin ? := spear$util.getUUID(?); end;");
    // index-by table element type
    int elemSqlType = OracleTypes.CHAR;
    // index-by table element length in case the element type
    // is CHAR, VARCHAR or RAW. This value is ignored for other
    // types
    int elemMaxLen = 32;
    // register the return parameter
    ocstmt.registerIndexTableOutParameter(1, maxNumOfUUID, elemSqlType,
    elemMaxLen);
    // register the number of UUIDes to generate
    ocstmt.setInt(2, maxNumOfUUID);
    // run the stored procedure
    ocstmt.execute();
    // access the value using JDBC default mapping
    arr = (String[]) ocstmt.getPlsqlIndexTable(1);
    // close the cursor
    ocstmt.close();
    } catch (SQLException x) {
    System.out.println(errorMessage + x.toString());
    throw new Exception(errorMessage + x.getMessage());
    return arr;
    Best,
    EA

  • How to call nested table type from Java

    I needed a 2 dimensional array and asked the questuion here.
    [Original thread| http://forums.oracle.com/forums/message.jspa?messageID=3419944#3419944]
    I have my program working correctly in pl/sql.
    The java guys are building this array and passing it in to me, but they don't know how.
    A small example of this would be appreciated.
    Heres an example of the procedure prototype and the type definitions in use
    create or replace
    type csn_array_obj
    as object
    (csn varchar2(20 char),
    box_id varchar2(10)
    create or replace
    type csn_array_type is table of csn_array_obj;
    procedure populate_stock(
    p_csn_array in csn_array_type
    added in example of object and type definition.

    There's an orl Oramag article by Tom Kyte rounding up [some Java tips|http://asktom.oracle.com/tkyte/omag/00-nov/o60tom.html] which includes an example of how to do this. You'll need to replace Tom's SIMPLARRAY with your own type.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Alter table type from COLUMN to ROW

    TABLE type can be changed from ROW to COLUMN (and vice versa) using the ALTER TABLE command .
    Lars Breddemann  wrote
    when considering which data store to choose (which, by the way, can be changed later on as well), you have to take into account:
    * will you usually need the complete row (all columns)? If so, row store may be more efficient, as reconstructing the complete row is one of the most expensive column store operations.
    * will you need to join the row-store table to a column store table? If so, you should avoid using a different storage type, since using both storage engines in a statement leads to intermediate result set materialization which is another name for bad performance.
    * do you want to fill the table with huge amounts of data, that should be aggregated and analysed? If this is the case, the column store is the better option.
    As a rule of thumb you may just start with column-store tables and change them to row-store tables when you encounter performance issues.
    In general most developers cannot anticipate all important use cases for the tables they design.
    This is especially true for living and growing systems.
    So, more important than choosing the 'right' storage in the beginning is to monitor the performance and to benchmark the differences when changing the storage engine.
    So suppose we have a COLUMN table , but would be requiring to get data from many columns (so would be a very expensive column operation) , would it be advisable to change the table type FROM COLUMN to ROW on the fly . would this be a resource intensive operation if the table has a lot of data ?
    Lets suppose , if the above can be done , but there exists a interdependency for the column table (say from another simultaneous operation) , and thus should remain as COLUMN table as such . so what would be the better option in this case .
    Creating views is not an option as it seems from the SQL guide , that there was not an option to create a ROW view from a COLUMN table. ?
    Edited by: Rajarshi Muhuri on Nov 27, 2011 3:25 AM

    Dear Rajashri,
    1. you cann't alter table from column to row using alter command.
    but you can achieve this through Stored procedure, just Little bit HSQL coding.
    I hope upcoming versions SAP Gives like following SQL statements  ( following statemnt not works in HANA works in oralce )
       create row table "EFASHION_TUTORIAL"."AAA" as
    select
    "ARTICLE_COLOR_LOOKUP_ID",
    "ARTICLE_ID",
    "COLOR_CODE",
    "ARTICLE_LABEL",
    "COLOR_LABEL",
    "CATEGORY",
    "SALE_PRICE",
    "FAMILY_NAME",
    "FAMILY_CODE"
    from "EFASHION_TUTORIAL"."ARTICLE_COLOR_LOOKUP";
    2. Row & column table two different purpose like OLTP & OLAP.
         when you think about OLAP means modeling use Column.
          when you think about OLTP means real time operations then use Row
    Column table is high compress ( 5 - 20X),  i don't think you want get any performance issue when read information from column table. that is actual Core engine reading parller process. ( that is Heart of HANA).
    Column table purpose quite different like calculations, grouping.. most of DW environment Queires.
    Row table is currently system tables in feature row tables as OLTP, it's less compress mode compress to column store.
    so finally you write small program convert column to row and row to column
    thanks
    Rao

  • Passing Tables back from Java Stored Procedures

    Thomas Kyte has written (in reference to
    trying to pass an array back from a stored
    function call):
    You can do one of two things (and both require the use of
    objects). You cannot use PLSQL table types as JDBC cannot bind to
    this type -- we must use OBJECT Types.
    [snip]
    Another way is to use a result set and "select * from
    plsql_function". It could look like this:
    ops$tkyte@8i> create or replace type myTableType as table of
    varchar2 (64);
    2 /
    Type created.
    ops$tkyte@8i>
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 function demo_proc2( p_rows_to_make_up in number )
    3 return myTableType
    4 as
    5 l_data myTableType := myTableType();
    6 begin
    7 for i in 1 .. p_rows_to_make_up
    8 loop
    9 l_data.extend;
    10 l_data(i) := 'Made up row ' | | i;
    11 end loop;
    12 return l_data;
    13 end;
    14 /
    Function created.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( demo_proc2(5) as mytableType )
    3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    Made up row 4 [Image]
    Made up row 5
    So, your JDBC program would just run the query to get the data.
    If the function "demo_proc2" cannot be called from SQL for
    whatever reason (eg: it calls an impure function in another piece
    of code or it itself tries to modify the database via an insert
    or whatever), you'll just make a package like:
    ops$tkyte@8i> create or replace package my_pkg
    2 as
    3
    4 procedure Make_up_the_data( p_rows_to_make_up in
    number ); 5 function Get_The_Data return myTableType;
    6 end;
    7 /
    Package created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace package body my_pkg
    2 as
    3
    4 g_data myTableType;
    5
    6 procedure Make_up_the_data( p_rows_to_make_up in number )
    7 as
    8 begin
    9 g_data := myTableType();
    10 for i in 1 .. p_rows_to_make_up
    11 loop
    12 g_data.extend;
    13 g_data(i) := 'Made up row ' | | i;
    14 end loop;
    15 end;
    16
    17
    18 function get_the_data return myTableType
    19 is
    20 begin
    21 return g_data;
    22 end;
    23
    24 end;
    25 /
    Package body created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( my_pkg.get_the_data as mytableType
    ) 3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    And you'll call the procedure followed by a query to get the
    data...
    I have tried this, and it works perfectly.
    My question, is what does the wrapper look
    like if the stored function is written
    in java instead of PL/SQL? My experiments
    with putting the function in java have been
    dismal failures. (I supposed I should also
    ask how the java stored procedure might
    look also, as I suppose that could be where
    I have been having a problem)
    null

    Thanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
    We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
    What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
    Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
    SELECT java_stored_proc(pl/sql_stored_proc(col_id))
    FROM table_of_5000_rows;
    Sorry for the lengthy post.

  • XMLAnalysis Error while trying to execute a MDX query on MS SSAS - Accessing the cube from Java through Olap4j driver

     Am trying to access MS SSAS data cube from Java through olap4j driver(through msmdpump.dll). I am able to connect , but when I try to execute a query, i am getting the below error: Please help
    me out . (I tested the http://XXXX/OLAP/msmdpump.dll in MS Excel , and it is working fine)
    org.olap4j.OlapException: XMLA provider gave exception: <soap:Fault xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <faultcode>
    XMLAnalysisError.0xc10a0004
    </faultcode>
    <faultstring>
    The CRASHDWHSRG cube either does not exist or has not been processed.
    </faultstring>
    <detail>
    <Error Description="The CRASHDWHSRG cube either does not exist or has not been processed." ErrorCode="3238658052" HelpFile="" Source="Microsoft SQL Server 2012 Analysis Services">
    </Error>
    </detail>
    </soap:Fault>

    See my other answer where you asked this same question on another thread
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/22dfc400-668d-4bd4-b76d-7c6b9ddda47a/msmdpumpdll-not-getting-registered?forum=sqlanalysisservices
    http://darren.gosbell.com - please mark correct answers

  • "access denied" error from Java Web Start

    I can successfully download the jar file, but always have error message "access denied" when the java application tries to open a local file in C:\temp\poc1.xml.
    I can successfully execute the java application from DOS,but failed when using Java Web Start. The error message is as follows:
    Java Web Start Console, started Wed Nov 28 16:30:31 PST 2001Java 2 Runtime Environment: Version
    1.3.1 by Sun Microsystems Inc.java.security.AccessControlException: access denied
    (java.io.FilePermission C:\temp\poc1.xml read)     at
    org.apache.xerces.framework.XMLParser.parse(Unknown Source)     at
    org.apache.xerces.framework.XMLParser.parse(Unknown Source)     at
    com.hotlocker.client.HLSessionParser.parse(Unknown Source)     at
    com.hotlocker.client.UploadDownloadClient.uploadFiles(Unknown Source)     at
    com.hotlocker.client.UploadDownload.main(Unknown Source)     at
    java.lang.reflect.Method.invoke(Native Method)     at
    com.sun.javaws.Launcher.executeApplication(Unknown Source)     at
    com.sun.javaws.Launcher.executeMainClass(Unknown Source)     at
    com.sun.javaws.Launcher.continueLaunch(Unknown Source)     at
    com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)     at
    com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)     at
    com.sun.javaws.Launcher.run(Unknown Source)     at java.lang.Thread.run(Unknown Source)

    Hi,
    you can't get a file like in a "normal" app
    because a JWS-app runs in the restricted
    sandbox environment by default.
    So you either sign your app with a digital certificate
    or you use a special FileOpenService (JNLP-API).
    You could also put the file into the app-jar and
    load it by a classloader.
    Regards,
    Mathias

  • Accessing DLL files from Java

    I have a problem with Java, and the problem is that I'm trying to call a DLL file declared by C++ only but without a support for Java programs, is what I'm aiming for going to be available by using the rundll32.exe file.
    Note: I'm trying to use the (skydll.dll) file for controling skystar2 DVB card.
    Message was edited by:
    JZoro

    You cannot directly call a DLL from Java unless the DLL exposes entry points that are compatible with the JNI calling conventions.
    For example a Java class calling a native function like below:
    class Arguments
       private native void setArgs (String[] javaArgs);
       public static void main (String args[])
          Arguments A = new Arguments();
          newArgs[] = A.setArgs(args);
       static
          System.loadLibrary("MyArgs");
    }Needs a DLL entry point with the following signature:
    JNIEXPORT void JNICALL
    Java_Arguments_setArgs (JNIEnv *jenv, jobject job, jobjectArray oarr) {Notice that the first parameter of the method is of type JNIEnv and the second can be either a reference to a class or Java object instance.
    Jacques Gonzalez
    J4SOFT

  • Accessing Table Type

    Hi All,
        In the code below WFAT_EMP_INT_EMPWA is a table type.
    For the function module 'WFA_EMP_DATA_GET' ,  ET_EMP_WORKAREA is an export parameter of type WFAT_EMP_INT_EMPWA
    For the function module 'WFA_EMP_DATA_MODIFY' , IT_EMP_WORKAREA is an import parameter of the same type.
    I need to get  the parameter from one function module and pass it to the next function module.
    Do i need to create a work area for the table type or can we simply define the table type and just pass it to the next FM as shown below.
    DATA: ITAB_WRKAREA TYPE WFAT_EMP_INT_EMPWA.
    DATA: itab_bapiret TYPE BAPIRET2_T,
          wa_bapiret TYPE LINE OF BAPIRET2_T.
    DATA: itab_bapiret1 TYPE BAPIRET2_T,
           wa_bapiret1 TYPE LINE OF BAPIRET2_T.
    FORM GET_WRKAREA_CODE.
      CALL FUNCTION 'WFA_EMP_DATA_GET'
        EXPORTING
          IV_EMP_BPID       = W_BUPNR
          IV_ORG_OBJID      = W_ORGEH
          IV_EFFECTIVE_WEEK = SY-DATUM
          IV_TEMPORARY      = GC_SPACE
        IMPORTING
          ET_EMP_WORKAREA   = ITAB_WRKAREA
          ET_RETURN         = itab_bapiret.
      LOOP AT itab_bapiret
      INTO wa_bapiret.
      WRITE :/ wa_bapiret-MESSAGE.
      ENDLOOP.
    ENDFORM.                    "get_wrkarea
    FORM TRANSFER_WRKAREA.
      CALL FUNCTION 'WFA_EMP_DATA_MODIFY'
        EXPORTING
          IV_EMP_BPID            = W_BUPNR
          IV_ORG_OBJID           = W_ORGEH
          IV_EFFECTIVE_WEEK      = SY-DATUM
          IS_EMP_INTERFACE_ADMIN = WA_WFAS_EMP_INT_ADMIN
         IT_EMP_WORKAREA        = ITAB_WRKAREA
        IMPORTING
          ET_RETURN              = itab_bapiret1.
          LOOP AT itab_bapiret1
          INTO wa_bapiret1.
          WRITE :/ wa_bapiret1-MESSAGE.
          ENDLOOP.
    ENDFORM.                    "transfer_wrkarea
    In the above context does ITAB_WRKAREA(table type) will have only one record.
    What is the difference between these 2 statements
    DATA:  x type TT.   " TT refers to table type
    DATA: x type ST.    "ST refers to structure type
    I am getting confused with the table types and structures . Table type refers to a line type which inturn refers to a structure? Can some one explain this.
    Thanks in Advance

    *-- Table type is a table.. when you refere to a table type u need not use again standard table of , or occurs 0 addition the follwoing statmenet will declare x as a internal table with out header line.
    DATA: x type TT. " TT refers to table type
    *-- Structure is a flat structure and x is a work area not internal table.
    DATA: x type ST. "ST refers to structure type
    if you have to create x as intenaal table using strrucre ST then
    data : x type standard table of ST..
    Thanks
    Mahesh

  • ADF mobile: access app preferences from java

    Hi,
    Jdev 11.1.2.3.0 + mobile extension.
    Where I can find example code or documentation to access preferences (configured in adfmf-application.xml) from java code?
    regards
    Peter

    Thanks!
    It's following part of the document:
    "At the Java layer, an EL value expression is resolved using the following
    approach:
    String val =
    AdfmfJavaUtilities.evaluateELExpression("#{preferenceScope.feature.f0.vendor}")
    regards
    Peter

  • How to access physical files from java platform

    Hello All,
    We have one JDE Word Writer program, which export the order master data in the DB2/400 Physical files.
    We want to access this data from our java program (reside on windows platform). I am wondering how we can do that. I got one hint that can be accessed by ODBC connection. But I am unable to get the correct ODBC driver. I am looking for correct driver to access the data.
    If some one has done this already, please help me. Or suggest me any alternate way.
    Dinesh

    Can use File class to write code to examine and manipulate file.
    Tutorial: http://java.sun.com/docs/books/tutorial/essential/io/file.html

  • How to access system calls from java program?

    i am having a doubt regarding accessing system calls from a Java program like accessing unix system calls from a c program.

    Runtime.getRuntime().exec("line command here");
    example:
    Runtime.getRuntime().exec("ls -la");

  • UnsatisfiedLinkError - Trying to access a DLL from Java

    I am trying to use the Java Native Interface (JNI) to run some C++ code from Java. I tried a simple test program to teach myself that, and it worked perfectly. However, now that I'm tackling a bigger project (A data acquisition program), I get an UnsatisfiedLinkError in the line that calls the function from the DLL.
    Here is the stacktrace: Exception in thread "AWT-EventQueue-0" java.lang.Error: java.lang.reflect.Invoca
    tionTargetException
            at org.jdesktop.application.ApplicationAction.actionFailed(ApplicationAc
    tion.java:859)
            at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(App
    licationAction.java:665)
            at org.jdesktop.application.ApplicationAction.actionPerformed(Applicatio
    nAction.java:698)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
    95)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6263)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
            at java.awt.Component.processEvent(Component.java:6028)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
            at java.awt.Container.dispatchEventImpl(Container.java:2085)
            at java.awt.Window.dispatchEventImpl(Window.java:2475)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
    ad.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
    java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(App
    licationAction.java:662)
            ... 26 more
    Caused by: java.lang.UnsatisfiedLinkError: fileiotest.dllinterface.startget()V
            at fileiotest.dllinterface.startget(Native Method)
            at fileiotest.dllinterface.start_daq(dllinterface.java:26)
            at fileiotest.FileIOTestView.startrun(FileIOTestView.java:680)
            ... 31 moreI have made sure that the DLL is in the classpath, using both the -classpath tag and by setting the PATH variable. Is something wrong with my DLL itself, perhaps?

    Yes, I have.
    I didn't include the code yet because I thought if someone had similar trouble, there might be something obvious I am overlooking and they wouldn't even need to see the code. I can provide it, however.
    This is the C++ DLL
    // consoledaq.cpp : Defines the entry point for the console application.
    #include <windows.h>                    /* Compiler's include files's */
    #include <string.h>                  
    #include <stdio.h>
    #include "cbw.h"
    #include "stdafx.h"
    #include "dllinterface.h"
    #include "jni.h" //can copy or give full path
    #include <math.h>
    BOOL APIENTRY DllMain( HANDLE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
        return TRUE;
    #define BOARD_NUM      0                /* Number of A/D board as defined with InstaCal */
    #define BUF_SIZE       10048            /* Size of buffer */
    #define NUM_SECS       10                /* Number of secs to collect data */
    #define ADRANGE        BIP5VOLTS        /* A/D voltage range */
    #define TIMER_NUM      1                /* Windows timer used by this program */
    static HGLOBAL  MemHandle32;       
    /* Variables for AinScan */
    static unsigned short *ADValues;    /* Win32 pointer to A/D buffer */
    static HGLOBAL   ADMemHandle;
    static short     ADCurStatus;       /* Current status for D/A scan */
    static long      ADCurCount;        /* Current count for A/D scan  */
    static long      ADCurIndex;        /* Current index for A/D scan  */
    int              ADOptions;
    long       Count, Rate;
    float      Voltage, Voltage2;
    unsigned short CurValue, CurValue2;
    JNIEXPORT void JNICALL
    Java_daq_startget(JNIEnv *env, jobject obj)
         cbErrHandling (PRINTALL, STOPALL);  /* Set library's error handling */
         ADCurStatus = RUNNING;
         ADCurIndex = 0l;
         ADCurCount = 0l;
         /* Allocate A/D Windows buffer */
         ADMemHandle = cbWinBufAlloc ((long)BUF_SIZE);
         /* Allocate a local WIN32 buffer to hold A/D Data */
         MemHandle32 = GlobalAlloc(GMEM_FIXED | GMEM_DDESHARE, BUF_SIZE *sizeof(short));
         /* Get a 32-bit pointer to the A/D WIN32 buffer */
         ADValues = (unsigned short *)GlobalLock(MemHandle32);
         /* Start up background A/D scan */
         Count = BUF_SIZE;
         Rate = BUF_SIZE / (NUM_SECS * 2);
         ADOptions = BACKGROUND | CONTINUOUS;
         cbAInScan (BOARD_NUM, 0, 1, Count, &Rate, ADRANGE, ADMemHandle, ADOptions);
    JNIEXPORT void JNICALL
    Java_daq_stopget(JNIEnv *env, jobject obj)
         cbStopBackground(BOARD_NUM, AIFUNCTION);  /* Stop A/D subsystem background scan */
         if (ADMemHandle)                 
              cbWinBufFree (ADMemHandle);   /* Free allocated memory */
         if (MemHandle32)
              GlobalFree (MemHandle32);
    JNIEXPORT jfloatArray JNICALL
    Java_daq_getpoint(JNIEnv *env, jobject obj)
         jfloatArray theArray;
         if (ADCurIndex >= 0)
              /* Copy Data from memory to 32 bit memory buffer */
              cbWinBufToArray(ADMemHandle, &ADValues[ADCurIndex], ADCurIndex ,2);
              CurValue = ADValues[ADCurIndex];
              CurValue2 = ADValues[(ADCurIndex + 1)];
         else
              CurValue = 0;
              CurValue2 = 0;
         jfloat tmp[2];
         theArray =  env->NewFloatArray(2);
         cbToEngUnits(BOARD_NUM,ADRANGE,CurValue,&Voltage);                      
         cbToEngUnits(BOARD_NUM,ADRANGE,CurValue2,&Voltage2);
         tmp[0] = Voltage;
         tmp[1] = Voltage2;
         env->SetFloatArrayRegion(theArray, 0, 2, tmp);
         return theArray;
    }And this is the Java class:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package fileiotest;
    * @author Owner
    public class dllinterface {
        public native void startget();
        public native float[] getpoint();
        public native void stopget();
        static {
         System.loadLibrary("daqdll");//This is firstJNI.DLL
         /*if generated by borland
         System.loadLibrary("firstjni");//This is firstjni.dll
        public static void start_daq()
            dllinterface DI=new dllinterface();
            DI.startget();
        public static void stop_daq()
            dllinterface DI=new dllinterface();
            DI.stopget();
        public static float[] get_data_point()
          dllinterface DI=new dllinterface();
          float newtempfloat[];
          newtempfloat = DI.getpoint();
          return newtempfloat;
    }

  • MS Access Date problem (from Java program)

    I have written an app. in Java that reads & writes data from a MS Access database.
    I am trying to write an insert class which will add a row of data to one of my database tables - which contains Date fields.
    My problem is that I can update the text fields, but not Date fields - every time I try my program throws an exception:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    My simplified code reads as:
    try {
    Statement insertStatement = databaseConnection.createStatement();
    String query = "INSERT INTO myTable(jobId, employeeId, date) VALUES('11', '1', " + "'13/11/2006'" + ");";
    insertStatement.execute(query);
    } //close, etc. etc.
    If I remove the date info from the query, the program executes successfully. I appreciate my problem might be related to the formatting of the date in Access, and if not a 'proper' Java question I give my apologies.
    I have attempted several formats of the date with no success or variation in the exception.
    I am, however, completely stuck and would appreciate any and all help given.
    Regards and thanks
    David

    I have amended my code to use a preparedStatement, but on execution I have the same problem.
    My code is as follows:
    PreparedStatement pstmt = null;
    try {
    String query = "INSERT INTO myTable (jobId, employeeId, date) VALUES(?, ?, ?);";
    pstmt = databaseConnection.prepareStatement(query);
    pstmt.setString(1, "11");
    pstmt.setString(2, "1");
    java.sql.Date sqlDate = getCurrentJavaSqlDate();
    pstmt.setDate(3, sqlDate);
    // execute query, and return number of rows created
    int rowCount = pstmt.executeUpdate();
    System.out.println("rowCount=" + rowCount);
    pstmt.close();
    catch, etc. etc.
    Any ideas or help most welcome
    Regards
    David

  • Best approach to append multiple Access tables together using java?

    Hello,
    I've been given the task of retrieving data from a collection of Access files and storing them in a MySQL database. The program I wrote works fine, but the problem is that the data is broken up by months and not years. I need access to a years worth of data for my calculations to be accurate.
    Therefore, I need to merge all the tables from different databases(files) for one year(12 tables).
    All the tables are identical, just different values for different days.
    I know how to manually append one table to another in MS Access, but that is too time consuming.
    I was thinking of querying all the data of each month and merging all the result sets into one collection to be later inserted into a new MySQL table.
    Any insight of how to do this efficiently would be greatly appreciated.

    maccartee wrote:
    I wrote a java class that will cycle through each Access file, executing a query to select all the rows in the table I need and insert them into a text file. The problem is that the sql query I use works in mysql but not access:
    SELECT * into OUTFILE 'C:\\TableDump.txt' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' FROM 8227;
    You can't write such a thing in Access.
    I get the following when I run it:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Query input must contain at least one table or query.
    I think Access is telling you the right answer: it won't accept that statement.
    8227 is the name of table I want.You named your table '8227'? Oh, my.
    I'm not too familiar with Access, but I thought I could run valid SQL queries?You're not too familiar with SQL. This is only valid in MySQL.
    Why insist on doing this in Java? There's a better way to do this. Save all the Access files as .csv output and import those into MySQL. Java's not the way to go here.
    %

Maybe you are looking for