Access ABAP Table using Java (NWDS/JCO)

All,
I am trying to setup a jco connection from java program through NWDS to ECC abap table.
However I am getting the following error in NWDS:
Exception in thread "main" java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc [C:\Program Files\Java\jdk1.6.0_45\bin\sapjcorfc.dll: Access is denied]. java.library.path [C:\Program Files\Java\jdk1.6.0_45\bin;.]
and a parity error on my system:
"Parity blocked an attempt by javaw.exe to run sapjcorfc.dll because the file is not approved.  If you require access to this file, please contact your system administrator.  Scroll down for diagnostic data."
Here is the Java code...per the SAP website:
package com.sap.pi.updateAbapSxmbAdminParams;
import com.sap.mw.jco.*;
public class ReadPiAbapTables {
  private static JCO.Client theConnection;
  private static IRepository theRepository;
  public static void main(String[] args) {
   createConnection();
   retrieveRepository(); 
   try {
    JCO.Function function = getFunction("RFC_READ_TABLE");
    JCO.ParameterList listParams = function.getImportParameterList();
    listParams.setValue("BSAUTHORS", "QUERY_TABLE");
    theConnection.execute(function);
    JCO.Table tableList = function.getTableParameterList().getTable("SXMSCONFVLV");
    if (tableList.getNumRows() > 0) {
     do {
      for (JCO.FieldIterator fI = tableList.fields();
      fI.hasMoreElements();)
       JCO.Field tabField = fI.nextField();
       System.out.println(tabField.getName()
         + ":t" +
         tabField.getString());
      System.out.println("n");
     while (tableList.nextRow() == true);
   catch (Exception ex) {
    ex.printStackTrace();
  private static void createConnection() {
   try {
    theConnection = JCO.createClient("aaa", "aaa", "aaa", "aa", "aa", "aa");
    theConnection.connect();
   catch (Exception ex) {
    System.out.println("Failed to connect to SAP system");
  private static void retrieveRepository() {
   try {
    theRepository = new JCO.Repository("saprep", theConnection);
   catch (Exception ex)
    System.out.println("failed to retrieve repository");
  public static JCO.Function getFunction(String name) {
   try {
    return theRepository.getFunctionTemplate(name.toUpperCase()).getFunction();
   catch (Exception ex) {
    ex.printStackTrace();
   return null;

Hi Vicky,
You need authorization to the S_TABU_DIS object, talk with the ABAP basis team about this to find the more restrictive role.
It's not a good idea to use the RFC_READ_TABLE, for the wide permissions needed. You could think to develop a Z RFC for this.  You can check pros/cons in this document: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a83ec690-0201-0010-14ac-bd1d75e24a7d?overridelayout=t…
Regards.

Similar Messages

  • Access ABAP tables using NWDS Java Code

    All,
    I am planning to write a program to autmatically update is_url entries in sxmb_admin using a Java program.
    Is there a way we can access the ABAP tables using standalone Java Code? would it something like dblookup that we use in the mappings?
    Your Thoughts....
    Thanks.

    Hi Vicky - Interesting..Seems like you are trying to automate every single thing
    However you can make use of Jco to connect to ABAP tables..
    Check the below thread..
    Help on accessing tables of SAP from the Java Application
    I assume the table name is "SXMSCONFVLV" which you might have to update but not sure..

  • Access ABAP table in Webdynpro Java application

    Hi All
    Is it possible to access ABAP table in Webdynpro Java application
    Please provide your input
    Thanks
    Karthi D.

    Hi you will connect to the remote SAP system, the
    backend, using an Adaptive RFC MOdel. To access database tables, you can make use of existing functions in terms of RFC function modules. For each function module you need, the system generates a corresponding Java proxy class. All the generated proxy classes and interface are bundled together in the RFC model and treated as part
    of your Web Dynpro project
    In WebDynpro java you RFC by using Model :
    Adaptive RFC Model
    1. automatically adapts to changes in function module signature
    2 provides support for data types and extensibility
    3.support for different structure definitions in different backend
    systems (release dependent structures, custom adaptation)
    Basic principles and guidelines
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/11c3b051-0401-0010-fe9a-9eabd9c216de
    See this blog
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/wdjava/faq%2b-%2bmodels%2b-%2badaptive%2brfc
    http://help.sap.com/saphelp_nw04s/helpdata/en/6a/11f1f29526944e8580c5e59333d96d/frameset.htm
    Thanks,
    Tulasi

  • Problem in accessing mseg table using MSEG~M Index.

    Hi Experts,
    I am facing problem in accessing mseg table using MSEG~M Index. I used same sequence of fields and i tried with mandt field also. but it is not taking the Index and it is going for TImeout ABAP dump.
    This are my codes used in different ways
    1.  SELECT  mjahr
             bwart
             matnr
             lifnr
             dmbtr
             kostl
             aufnr
             bukrs
             FROM mseg CLIENT SPECIFIED INTO TABLE t_mseg2
                      WHERE mandt EQ sy-mandt      AND
                            matnr NE SPACE         AND
                            werks EQ p_werks       AND
                            lgort NE '0000'        AND
                            bwart IN (122,201,262) AND
                            sobkz NE '0'
                            %_HINTS ORACLE 'INDEX("MSEG" "MSEG~M")'.
    2.   SELECT  mjahr
             bwart
             matnr
             lifnr
             dmbtr
             kostl
             aufnr
             bukrs
             FROM mseg  INTO TABLE t_mseg2
                      WHERE matnr NE SPACE         AND
                            werks EQ p_werks       AND
                            lgort NE '0000'        AND
                            bwart IN (122,201,262) AND
                            sobkz NE '0'
                            %_HINTS ORACLE 'INDEX("MSEG" "MSEG~M")'.
    3.   SELECT  mjahr
             bwart
             matnr
             lifnr
             dmbtr
             kostl
             aufnr
             bukrs
             FROM mseg INTO TABLE t_mseg2
                      WHERE matnr NE SPACE         AND
                            werks EQ p_werks       AND
                            lgort NE '0000'        AND
                            bwart IN (122,201,262) AND
                            sobkz NE '0'.                   
    The above all code is not at all taking the index in Quality server .but in Development it is taking .In Quality server it is reading all datas without using the index and going Timeout ABAP dmup
    Please, Suggest me some solutions.
    Thanks in Advance.
    Regards,
    Nandha

    Hi,
    Without NE also not working out. i am facing same problem still.
    SELECT  bwart
             matnr
             lifnr
             dmbtr
             kostl
             aufnr
             FROM mseg CLIENT SPECIFIED INTO TABLE t_mseg
                      WHERE mandt EQ sy-mandt      AND
                            werks EQ p_werks       AND
                            bwart IN (122,201,262) AND
                            mjahr EQ p_year        AND
                            bukrs EQ p_cc
                            %_HINTS ORACLE 'INDEX("MSEG" "MSEG~M")'.
    Please,check and help me out from this issue.
    Regards,
    Nandha

  • 1)unexpected Exception:page fault accessing tag table 2)java.rmi.MarshalException:Unexpected Exception page fault accessing page table

    i am trying to call WCF service by using Jsr 172 method
    but i got the two error
    1)unexpected Exceptionage fault accessing tag table
    2)java.rmi.MarshalException:Unexpected Exception page fault accessing page table
    does anybody knows about how to solve this error.
    Plz help me
    thanks in advance!!!!!!!!!!!
      My Code is:-----
    package com.rim.sample.webservicedemo;
    import java.rmi.RemoteException;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.container.MainScreen;
    public class webservice extends UiApplication
        public webservice()
            pushScreen(new myscreen());
        public static void main(String[] args)
            webservice t=new webservice();
            t.enterEventDispatcher();
    final class myscreen extends MainScreen implements FieldChangeListener
        //taking this program from :-http://blog.bayestech.com/?p=78
         public myscreen()
             setTitle("HI");
             ButtonField g=new ButtonField("OK",ButtonField.CONSUME_CLICK);
             g.setChangeListener(this);
             add(g);
        public void fieldChanged(Field field, int context)
            try
                testServiceCall();
            catch (RemoteException e)
                Dialog.alert(e.getMessage());
                Dialog.alert(e.toString());
         public void testServiceCall() throws RemoteException
                TestService_Stub service = new TestService_Stub();
                //String  message = service.helloWorld();
               // Dialog.alert(message);
              // String  message2=service.echoName("ankush,nilesh,chetan,ravi");
                //Dialog.alert(message+"  second message  "+message2);
                // Object addition_output=service.addition(7,2);
                 //Dialog.alert("your addition is" +  String.valueOf(addition_output));
                 String  login_message = service.logOn_method("abcdefg","aaaaa");
                 Dialog.alert("login successfully");
                 Dialog.alert(login_message);
    //////////////TestService_Stub class file///////////////////////
    package com.rim.sample.webservicedemo;
    import java.rmi.RemoteException;
    import javax.xml.rpc.JAXRPCException;
    import javax.xml.namespace.QName;
    import javax.microedition.xml.rpc.Operation;
    import javax.microedition.xml.rpc.Type;
    import javax.microedition.xml.rpc.ComplexType;
    import javax.microedition.xml.rpc.Element;
    import net.rim.device.api.ui.component.Dialog;
    public class TestService_Stub implements TestService,javax.xml.rpc.Stub
        ///calling web services by using jsr-172 method
        //website link :- http://blog.bayestech.com/?p=78
        private String[] _propertyNames;
        private Object[] _propertyValues;
      //  private Object[] _propertyValues1;
        public TestService_Stub()
            _propertyNames = new String[] { ENDPOINT_ADDRESS_PROPERTY };
           // _propertyValues = new Object[] { "http://test.bayestech.com/Services/TestService.asmx" };
          // _propertyValues = new Object[] { "http://soft21/testWCF/Service.svc" };
            _propertyValues = new Object[] { "< url name >" };
     protected void _prepOperation(Operation op)
            for (int i = 0; i < _propertyNames.length; ++i)
                op.setProperty(_propertyNames[i], _propertyValues[i].toString());
     public String logOn_method(String usr_name,String password_name ) throws java.rmi.RemoteException
          Object inputObject[] = new Object[]
                  usr_name,
                  password_name
          Operation op = Operation.newInstance( _qname_operation_logOn, _type_logOn, _type_logOnResponse );
          _prepOperation( op );
          op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "<soap action name >" );
          Object resultObj;
          try
              resultObj = op.invoke( inputObject );
              Dialog.alert((String)resultObj);
          catch( JAXRPCException e )
              Throwable cause = e.getLinkedCause();
              if( cause instanceof java.rmi.RemoteException )
                  throw (java.rmi.RemoteException) cause;
              Dialog.alert(e.getMessage());
              throw e;
          return (String )((Object[])resultObj)[0];
     protected static final QName _qname_operation_logOn = new QName( "<soap action name>", "logOn" );
        protected static final QName _qname_logOnResponse = new QName( "<soap action name>", "logOnResponse" );
        protected static final QName _qname_logOn = new QName( "<soap action name>", "logOn" );
        protected static final Element _type_logOn;
        protected static final Element _type_logOnResponse;
        static
     _type_logOn = new Element( _qname_logOn, _complexType( new Element[] {
                 new Element( new QName( "<soap action name>", "usr_name" ), Type.STRING, 0, 1, false ),
                 new Element( new QName( "<soap action name>", "password_name" ), Type.STRING, 0, 1, false )}), 1, 1, false );
            _type_logOnResponse = new Element( _qname_logOnResponse, _complexType( new Element[] {
                  new Element( new QName( "<soap action name>", "logResult" ), Type.INT, 0, 1, false )}), 1, 1, false );
        private static ComplexType _complexType( Element[] elements )
            ComplexType result = new ComplexType();
            result.elements = elements;
            return result;
        public void _setProperty(String name, Object value) {
            // TODO Auto-generated method stub
        public Object _getProperty(String name) {
            // TODO Auto-generated method stub
            return null;
        public String echoName(String name) throws RemoteException {
            // TODO Auto-generated method stub
            return null;
        public String helloWorld() throws RemoteException {
            // TODO Auto-generated method stub
            return null;
    i am trying to call WCF service by using Jsr 172 method
    but i got the two error
    1)unexpected Exceptionage fault accessing tag table
    2)java.rmi.MarshalException:Unexpected Exception page fault accessing page table
    does anybody knows about how to solve this error.
    Plz help me
    thanks in advance!!!!!!!!!!!
      My Code is:-----
    package com.rim.sample.webservicedemo;
    import java.rmi.RemoteException;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.container.MainScreen;
    public class webservice extends UiApplication
        public webservice()
            pushScreen(new myscreen());
        public static void main(String[] args)
            webservice t=new webservice();
            t.enterEventDispatcher();
    final class myscreen extends MainScreen implements FieldChangeListener
        //taking this program from :-http://blog.bayestech.com/?p=78
         public myscreen()
             setTitle("HI");
             ButtonField g=new ButtonField("OK",ButtonField.CONSUME_CLICK);
             g.setChangeListener(this);
             add(g);
        public void fieldChanged(Field field, int context)
            try
                testServiceCall();
            catch (RemoteException e)
                Dialog.alert(e.getMessage());
                Dialog.alert(e.toString());
         public void testServiceCall() throws RemoteException
                TestService_Stub service = new TestService_Stub();
                //String  message = service.helloWorld();
               // Dialog.alert(message);
              // String  message2=service.echoName("ankush,nilesh,chetan,ravi");
                //Dialog.alert(message+"  second message  "+message2);
                // Object addition_output=service.addition(7,2);
                 //Dialog.alert("your addition is" +  String.valueOf(addition_output));
                 String  login_message = service.logOn_method("abcdefg","aaaaa");
                 Dialog.alert("login successfully");
                 Dialog.alert(login_message);
    //////////////TestService_Stub class file///////////////////////
    package com.rim.sample.webservicedemo;
    import java.rmi.RemoteException;
    import javax.xml.rpc.JAXRPCException;
    import javax.xml.namespace.QName;
    import javax.microedition.xml.rpc.Operation;
    import javax.microedition.xml.rpc.Type;
    import javax.microedition.xml.rpc.ComplexType;
    import javax.microedition.xml.rpc.Element;
    import net.rim.device.api.ui.component.Dialog;
    public class TestService_Stub implements TestService,javax.xml.rpc.Stub
        ///calling web services by using jsr-172 method
        //website link :- http://blog.bayestech.com/?p=78
        private String[] _propertyNames;
        private Object[] _propertyValues;
      //  private Object[] _propertyValues1;
        public TestService_Stub()
            _propertyNames = new String[] { ENDPOINT_ADDRESS_PROPERTY };
           // _propertyValues = new Object[] { "http://test.bayestech.com/Services/TestService.asmx" };
          // _propertyValues = new Object[] { "http://soft21/testWCF/Service.svc" };
            _propertyValues = new Object[] { "< url name >" };
     protected void _prepOperation(Operation op)
            for (int i = 0; i < _propertyNames.length; ++i)
                op.setProperty(_propertyNames[i], _propertyValues[i].toString());
     public String logOn_method(String usr_name,String password_name ) throws java.rmi.RemoteException
          Object inputObject[] = new Object[]
                  usr_name,
                  password_name
          Operation op = Operation.newInstance( _qname_operation_logOn, _type_logOn, _type_logOnResponse );
          _prepOperation( op );
          op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "<soap action name >" );
          Object resultObj;
          try
              resultObj = op.invoke( inputObject );
              Dialog.alert((String)resultObj);
          catch( JAXRPCException e )
              Throwable cause = e.getLinkedCause();
              if( cause instanceof java.rmi.RemoteException )
                  throw (java.rmi.RemoteException) cause;
              Dialog.alert(e.getMessage());
              throw e;
          return (String )((Object[])resultObj)[0];
     protected static final QName _qname_operation_logOn = new QName( "<soap action name>", "logOn" );
        protected static final QName _qname_logOnResponse = new QName( "<soap action name>", "logOnResponse" );
        protected static final QName _qname_logOn = new QName( "<soap action name>", "logOn" );
        protected static final Element _type_logOn;
        protected static final Element _type_logOnResponse;
        static
     _type_logOn = new Element( _qname_logOn, _complexType( new Element[] {
                 new Element( new QName( "<soap action name>", "usr_name" ), Type.STRING, 0, 1, false ),
                 new Element( new QName( "<soap action name>", "password_name" ), Type.STRING, 0, 1, false )}), 1, 1, false );
            _type_logOnResponse = new Element( _qname_logOnResponse, _complexType( new Element[] {
                  new Element( new QName( "<soap action name>", "logResult" ), Type.INT, 0, 1, false )}), 1, 1, false );
        private static ComplexType _complexType( Element[] elements )
            ComplexType result = new ComplexType();
            result.elements = elements;
            return result;
        public void _setProperty(String name, Object value) {
            // TODO Auto-generated method stub
        public Object _getProperty(String name) {
            // TODO Auto-generated method stub
            return null;
        public String echoName(String name) throws RemoteException {
            // TODO Auto-generated method stub
            return null;
        public String helloWorld() throws RemoteException {
            // TODO Auto-generated method stub
            return null;

    Vishnu,
    I'm working on Ludwig's testcase.
    Ludwig's testcase is based on read-only View Objects.
    Is it also the case in your application ?
    I was unable to reproduce with VOs based on EOs.
    With read-only VOs, you can avoid the ArrayIndexOutOfBoundsException by setting the "Key Attribute" property for the PK of the Master VO.
    See the ADF Developer's Guide, topic "7.9.3 What You May Need to Know About Enabling View Object Key Management for Read-Only View Objects"
    URL: http://download-uk.oracle.com/docs/html/B25947_01/bcvoeo009.htm#BABJEEFA
    Regards,
    Didier.

  • Need help with ABAP coding using java

    Dear experts,
    I have used ABAP to code many reports/function modules.However as i know java quite well,i want to achieve the same using java.I have utilized JCO to retrieve information from RFC in this mission.
    However i realized that i had to code all things using ABAP and use java only as interface to connect to
    SAP fetch that module and display information on console.It was not that fun.
    I want that i should not Login to SAP but work only using java.
    I heard SAP Netweaver is a good choice.But i dont know much about it.Will i be able to develop reports only by java and how ?
    Plz suggest.

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

  • Iterate through all the records in a table using Java API

    Hi All,
    What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
    Thanks!
    Kenny

    Hi Kenny,
    You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
    Please look at the following code:
    Search search = new Search(<code name of your table>);
    ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
    rsd.AddField<code name of a field>);
    rsd.AddField(<code name of a field>);
    String sortField = <code name of your sort field>;
    boolean sortAscending = true;
    int page = 0; //page number
    A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
    for (int i = 0; i < rs.GetRecordCount(); i++)
        Value fieldValue = rs.GetValueAt(i, <code name of a field>);
    Hope this helps,
    Nir
    PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward.

  • How to access sharepoint logs using Java?

    Is there a way to access Sharepoint logs using Java from a remote machine? 
    Any help / pointers would be appreciated. Thanks.

    Hello,
    I am not aware about any client modal class for log but if you create your own service and host in SP server then you can call this web service in JAVA. (i am not sure whether JAVA supports .NET web service or not).
    You can refer this for web service:
    http://www.arboundy.com/2010/12/centalised-view-of-sharepoint-uls-log-files/
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to access Websphere variables using java

    Hi
    I want to access Websphere variables using java.
    Any help is appreciated!!
    Thanks
    P

    WebSphere Application Server has a bunch environmental variables such as log locations. These are held at the "server", "node", and "cell" level.
    To access them, you have to get the right context. Something like this, I believe...
    InitialContext initialContext = new InitialContext();
    initialContext.lookup("foo:bar/baz/blah"); //correct context hereGo to the IBM website for WAS and do a search on namespace bindings. That should give you some more information.
    Good luck.

  • Writing a java program to access SAP tables using SAP JCO

    Hi all,
           I have a requirement where I need to access the VBAK table and get some values out of it based on a query on some of it fields. I would like to know how this can be done via a Java program by utilising the SAP JCo library. Has anyone done this before? A sample program would be very helpful.
    Thanks in advance!

    Hi SAM,
    Welcome to SDN!!!!!!
    Chk this help doc.
    http://help.sap.com/saphelp_nw04/helpdata/en/35/42e13d82fcfb34e10000000a114084/frameset.htm
    Also chk these thread.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/8798be90-0201-0010-d093-85f728778d37
    Re: How to access SAP database tables with Java (Jco)
    Regards.
    Maha

  • Accessing BAPI's using JAVA with out using webdynpro URGENT

    hi Experts,
    What is the procedure for calling RFC/BAPI's using JAVA with out using the webdynpro. Please let me know what are the possibilities with step by step implementation.
    Regards
    Vijay

    Hi Boris Rubarth,
    Thaks for relavant information.
    I have kind of the requirement. The clinet is asking for connecting the SAP RFC using java application. The build Jar or .war or .Ear for which are going to develop should be compatible for running on any of the Applications server like they have Tom cat, weblogic, websphere server.
    so the .jar for or .ear file which we are going to develop should be able to run accessing the RFC/ BAPIs from any of these servers other than SAP WAS that is what their target.
    Please give me your suggestion, which is better approach. currently their SAP system is 4.6c . So presently it is not possible the webservice approach. But they have plans to go for upgrade to ECC6.0
    In that case only JCO option is possible. If use this option . Is it possible to access application which is deployed irrespective of the WAS by doing the required configuration.
    Basically i am aware of the ABAP webservice work bech steps and also the JAVA coding also.
    Please suggest me what is the better way to achieve this.
    Regards

  • Accessing an Table in Java

    Hi,
    I'm getting an error
    "java.sql.SQLException: Invalid name pattern: SCOTT.Point"
    when I try to access the values of an table with user defined types in a Java stored procedure with getArray().
    Here's a more detailed description:
    I have defined two "SQL types of language java".
    The definition in SQL is:
    TYPE Point AS OBJECT EXTERNAL NAME
    objects.Point' LANGUAGE JAVA USING SQLDATA (
    x FLOAT EXTERNAL NAME 'x',
    y FLOAT EXTERNAL NAME 'y',
    z FLOAT EXTERNAL NAME 'z');
    TYPE Triangle AS OBJECT EXTERNAL NAME
    'objects.Triangle' LANGUAGE JAVA USING SQLDATA (
    A POINT EXTERNAL NAME 'a',
    B POINT EXTERNAL NAME 'b',
    C POINT EXTERNAL NAME 'c');
    The equivalent java class for Point and Triangle can be found at the end of the posting.
    After that I wanted to add a static java function to another class TEST. This function should have an array of triangles as input and should be able to access all the triangles.
    Therefor I defined a SQL type for a table of triangles
    TYPE mylist AS TABLE OF Triangle;
    and a SQL type with the static function that corresponds to the java class TEST:
    TYPE test AS OBJECT EXTERNAL NAME
    'objects.Test' LANGUAGE JAVA USING SQLDATA (
    STATIC FUNCTION testfunction(tri mylist) RETURN NUMBER
    EXTERNAL NAME 'testfunction(oracle.sql.ARRAY) return int');
    Now the most important - and probably wrong - code:
    In the equivalent java class TEST I tried to access the array/table with the following function:
    public static int testfunction(oracle.sql.ARRAY trilist) throws SQLException
    int n = trilist.length(); // this works !!!!
    ARRAY obs = trilist.getArray(); // this doesn't work !!!
    Object[] obs = (Object[]) trilist.getArray(); // this doesn't work either
    return n;
    When I try to use this function in SQLplus, I get this error: "java.sql.SQLException: Invalid name pattern: SCOTT.Point" although I imported the java classes objects.Point and objects.Triangle.
    It looks like that there is no problem with the class Triangle, but only with the class Point?!
    I really tried a lot and search a lot in forums. But there are hardly any postings to this "server-side" problem, especially with tables of user-defined types. Most of the questions concern accessing data from client-side e.g. create a connection in the java programm and so on...
    I would be very thankful to a small example how to be able to access the values of the triangle table or to get a good advice how to solve my problem.
    Thanks to you all!
    Java classes Point and Triangle:
    package objects;
    import java.sql.*;
    public class Point implements java.sql.SQLData {
    public double x;
    public double y;
    public double z;
    public void readSQL(SQLInput in, String type) throws SQLException {
    x = in.readDouble();
    y = in.readDouble();
    z = in.readDouble();
    public void writeSQL(SQLOutput out) throws SQLException {
    out.writeDouble(x);
    out.writeDouble(y);
    out.writeDouble(z);
    public String getSQLTypeName() throws SQLException {
    return "SCOTT.Point";
    public Point(){ }
    public Point(double x, double y, double z){
    this.x = x;
    this.y = y;
    this.z = z;
    package objects;
    import java.sql.*;
    import objects.*;
    public class Triangle implements java.sql.SQLData {
    public Point a;
    public Point b;
    public Point c;
    public Vector normal;
    public void readSQL(SQLInput in, String type) throws SQLException {
    a = (Point) in.readObject();
    b = (Point) in.readObject();
    c = (Point) in.readObject();
    public void writeSQL(SQLOutput out) throws SQLException {
    out.writeObject(a);
    out.writeObject(b);
    out.writeObject(c);
    public String getSQLTypeName() throws SQLException {
    return "SCOTT.Triangle";
    public Triangle(){ }
    public Triangle(Point a, Point b, PointD c, Vector normal)
    this.a = a;
    this.b = b;
    this.c = c;
    this.normal = normal;
    }

    Hi Avi,
    first of all many thanks to you!
    Why did I start this thread here? Well, first of all, the problem described in this second posting is a little bit different, at least its context. So I chose another "subforum" than in the first posting. Additionally, as you see, there are different readers in the forums. I'm not sure whether I would have got this hint in Database/JVM, too.
    But now to the main subject:
    Your idea helped me indeed a little bit. I changed "SCOTT.Point" to "SCOTT.POINT" and "SCOTT.Triangle" to "SCOTT.TRIANGLE". Your proposition "SCOTT"."Point" didn't work since Ihave to return one single string.
    The error montioned above in my first posting disappeared now, but I get the next error: java.lang.ClassCastException.
    I tried all possible kinds of type cast:
    public static int testfunction(oracle.sql.ARRAY trilist) throws SQLException
    int n = trilist.length(); // this works !!!!
    ARRAY obs = (ARRAY) trilist.getArray(); // this doesn't work !!!
    Object[] obs = (Object[]) trilist.getArray(); // this doesn't work either
    Triangle[] obs = (Triangle[]) trilist.getArray(); // this doesn't work either
    return n;
    Using "java.sql.Array" as input type and the method "java.sql.Array.getArray" leads to the same problems.
    In many books expressions like in the code above are used for given resultSets. There, it works! :-(
    Any ideas what could still be wrong?

  • Creating XML from Relational Tables using java

    I would like to create an XML document by querying relational tables in java
    try {
            connection = getConnection();
            final String qryStr = "select XMLElement( foo, 'bar' ) from dual";
            final OracleXMLQuery qry = new OracleXMLQuery(connection, qryStr);
            final String xmlString = qry.getXMLString();
    I would expect this to give the following result that I get from running the statement in SQL Developer
    select XMLElement( foo, 'bar' ) from dual
    <FOO>bar</FOO>
    Instead I get
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XML tag name.</ERROR>
    Is this the correct way to go about this?

    Is this the correct way to go about this?
    Not really.
    OracleXMLQuery class is the Java-side implementation of DBMS_XMLQUERY APIs.
    It's mostly designed to generate a canonical XML document out of a SQL query.
    Assuming a query like "SELECT col1, col2 FROM my_table", the resulting XML should appear like this :
    <ROWSET>
      <ROW>
        <COL1>123</COL1>
        <COL2>ABC</COL2>
      </ROW>
      <ROW>
        <COL1>456</COL1>
        <COL2>XYZ</COL2>
      </ROW>
    </ROWSET>
    So in your test, since the resulting column is not aliased (XMLElement), you're actually trying to generate something like this :
    <ROWSET>
      <ROW>
        <XMLELEMENT(FOO,'BAR')>
          <FOO>bar</FOO>
        </XMLELEMENT(FOO,'BAR')>
      </ROW>
    <ROWSET>
    which of course is invalid, hence the error message.
    If you want to generate only <FOO>bar</FOO> as output, just use a regular PreparedStatement with your query and access the document in the ResultSet with the proper getter.

  • How to access NTFS entries using Java

    I want to access and read the attributes of a file stored in the Master File Table of NTFS.
    How should I do it using Java. Is using native code and using JNI the only way or is there a package in Java that supports this?
    Thanks

    WebSphere Application Server has a bunch environmental variables such as log locations. These are held at the "server", "node", and "cell" level.
    To access them, you have to get the right context. Something like this, I believe...
    InitialContext initialContext = new InitialContext();
    initialContext.lookup("foo:bar/baz/blah"); //correct context hereGo to the IBM website for WAS and do a search on namespace bindings. That should give you some more information.
    Good luck.

  • Access mirror site using java, download files and other information?

    Hi, I have 2 nodes/servers on the system both running webservers and having the same interface, but at a time user will access one node at a time from their browser, but this interface will be able to allow the user to get information from the both the nodes. the information that the user can get is DB stored as well as files on the disk of either node.
    i can manage the DB, cuz there is nothing to it, but how do I get files from the other node?
    currently any files/web documents are all stored in a application directory of the web root and protected by htaccess i believe, so when a user logs on to node one he can access all plain text/binary files along with web content since the web server authorizes the user to access anything in that dir. but at the same time from the same session I want to be able to access files in a mirror site using the same username and password and not having him to enter it again. the username/pass combo is replicated on both the servers, it this possible?
    currently i use the http password protection provided by apache to access one node, but can i use the same session on another machine with the same credentials?
    If this is not possible how can i do this programatically using java? can i do can "ls" on the directory i want on another server and display the list to the user and then when he clicks on that file name i fetch it from the backup/mirror server and have him save it using http or ftp?
    It would be great if we can get a solution to this.
    Thank you very much in advance.
    Ankur

    If you install the web server on different machines, It is possible to share the informations between them.

Maybe you are looking for