Java Connection in LKM

Hi all,
I am trying to add a command at LKM ,so that it establish a connection to the source database and retrieve values from a table.
i have added this at Command on Source
<@
import java.sql.*;
import java.lang.*;
Connection myCon = odiRef.getJDBCConnection("SRC");
Statement myStmt = myCon.createStatement();
ResultSet myRs = myStmt.executeQuery("select count(*) FROM SAMPLE");
myRs.next();
String myString = myRs.getString(1);
System.out.println(myString);
@>
Now the SRC is GLOBAl context.while executing i want to it to be dynamic based on current running physical data server
when i execute the interface it gives me the following error.
java.lang.Exception: The application script threw an exception: java.lang.NullPointerException: Null Pointer in Method Invocation BSF info: HCL at line: 0 column: columnNo
     at com.sunopsis.dwg.codeinterpretor.a.a(a.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.codeInterpretation(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execIntegratedFunction(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
     at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
     at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
     at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
     at com.sunopsis.dwg.cmd.e.i(e.java)
     at com.sunopsis.dwg.cmd.g.y(g.java)
     at com.sunopsis.dwg.cmd.e.run(e.java)
     at java.lang.Thread.run(Unknown Source)
Pls tell me where i am going wrong?

SaraHrry wrote:
Is it a best practice to open a connection to database in a Constructor in Java ???No. A constructor should simply put a newly created object into a valid usable state. Unless that class' responsibility is simply to be some sort of proxy for a connection, or perhaps a connection pool, establishing the connection would not be part of that initial state, and maybe not even in those cases.

Similar Messages

  • SAP Java Connectivity Builder -NoClassDefFoundError com.sap.aii...Reference

    Hi there,
    I'm trying to generate Java Proxies for SAPJCO using the SAP Java Connectivity Builder (JCB). I got it from the NetWeaver 6.20 Release. The tool installs and runs properly but after putting in the connection properties and klicking "next", the application hangs. When activating System output, I get the error shown below.
    I already tried to put all jar files contained in the C:\JBuilder5\lib\ext directiry into the classpath (but none of them contains the class mentioned).
    Which is the right (standalone) tool for generating Java Proxies for a standalone Java application?
    If it is JCB, is there a bug on the version I use (NetWeaver Release 6.20)?
    Any help would be apreciated.
    C:\JBuilder5>java -Dlog.handler.FileLog=FileHandler,log.txt -Dlog.logger.com=ALL,FileLog -cp lib/ext/aii_basis.jar;lib/e
    xt/aii_ifr_core.jar;lib/ext/aii_ifr_jbtool.jar;lib/ext/aii_lcraccess.jar;lib/ext/aii_msg_runtime.jar;lib/ext/aii_proxy_g
    en.jar;lib/ext/aii_proxy_rt.jar;lib/ext/aii_util.jar;lib/ext/aii_util_log.jar;lib/ext/lcrclient.jar;lib/ext/logging.jar;
    lib/ext/SapIdeHelp.jar;lib/ext/SapIdeJBUtil.jar;lib/ext/SapIdeJspInsight.jar;lib/ext/SapIdeTaglibReflection11.jar;lib/ex
    t/SapIdeTracing.jar;lib/ext/SapIdeUtil.jar;lib/ext/SAPJ2EEEngineJBuilderPlugin.jar;lib/ext/sapjco.jar;lib/ext/SAPmdi.jar
    ;lib/ext/servlet.jar;lib/ext/tc_sec_core.jar com.sap.aii.ifr.tool.jbuilder.JBuilderTool
    #0 12:35:37 [main] DEBUG com.sap.aii.util.misc.api.AIIProperties: Initial AIIProperties
            com.sap.aii.client = true
    #1 12:35:37 [main] FINE com.sap.aii.util.misc.api.AIIProperties: changed Property "com.sap.aii.standalone" from "null" t
    o "true"
    #2 12:35:37 [main] FINE com.sap.aii.util.misc.api.AIIProperties: changed Property "com.sap.aii.xml.parserFactory" from "
    null" to "com.inqmy.lib.jaxp.SAXParserFactoryImpl"
    #3 12:35:37 [main] FINE com.sap.aii.util.misc.api.AIIProperties: changed Property "com.sap.aii.xml.transformerFactory" f
    rom "null" to "com.inqmy.lib.jaxp.TransformerFactoryImpl"
    #4 12:35:46 [AWT-EventQueue-0] DEBUG com.sap.aii.ifr.upload.client.SAPNavigationPane: New file is C:\Documents and Setti
    ngs\kalkoo1\Desktop\t.jar
    #5 12:36:08 [AWT-EventQueue-0] FINER com.sap.aii.ifr.upload.client.R3LogonScreen: setting for Client : 010
    #6 12:36:08 [AWT-EventQueue-0] FINER com.sap.aii.ifr.upload.client.R3LogonScreen: setting for Logon Name : kalkoo1
    #7 12:36:08 [AWT-EventQueue-0] FINER com.sap.aii.ifr.upload.client.R3LogonScreen: setting for Password : #########
    #8 12:36:08 [AWT-EventQueue-0] FINER com.sap.aii.ifr.upload.client.R3LogonScreen: setting for Language : EN
    #9 12:36:08 [AWT-EventQueue-0] FINER com.sap.aii.ifr.upload.client.R3LogonScreen: setting for Host name: bgstsapedai01.s
    t.behr.de
    #10 12:36:08 [AWT-EventQueue-0] FINER com.sap.aii.ifr.upload.client.R3LogonScreen: setting for System number : 20
    #11 12:36:08 [AWT-EventQueue-0] INFO com.sap.aii.ifr.upload.client.R3LogonScreen: trying to establish connection
    #12 12:36:08 [AWT-EventQueue-0] FINEST com.sap.aii.ifr.util.IdentityCheck: Looking up identity
    #13 12:36:08 [AWT-EventQueue-0] DEBUG com.sap.aii.ifr.util.IdentityCheck: Results of identity check: isIFRServer: false;
    isIFRRMIClient: false; isStandaloneIFR: true
    #14 12:36:08 [AWT-EventQueue-0] FINEST com.sap.aii.ifr.util.IdentityCheck: Checking IdentityCheck.isIFRServer. Result: f
    alse
    #15 12:36:08 [AWT-EventQueue-0] INFO com.sap.aii.ifr.upload.sap.SAPConnection: connecting to system 20 on bgstsapedai01.
    st.behr.de via JCo
    #16 12:36:09 [AWT-EventQueue-0] DEBUG com.sap.aii.ifr.upload.sap.SAPUploadSource: init MDI to System bgstsapedai01.st.be
    hr.de (system=20, client=010) (BasisRelease: 620)
    #17 12:36:09 [AWT-EventQueue-0] DEBUG com.sap.aii.ifr.upload.UploadBuffer: new UploadBuffer
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/sap/aii/ifr/client/editor/Reference
            at java.lang.Class.getDeclaredMethods0(Native Method)
            at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
            at java.lang.Class.getDeclaredMethod(Unknown Source)
            at java.awt.Component.isCoalesceEventsOverriden(Unknown Source)
            at java.awt.Component.access$100(Unknown Source)
            at java.awt.Component$2.run(Unknown Source)
            at java.awt.Component$2.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.awt.Component.checkCoalescing(Unknown Source)
            at java.awt.Component.<init>(Unknown Source)
            at java.awt.Container.<init>(Unknown Source)
            at javax.swing.JComponent.<init>(Unknown Source)
            at javax.swing.JTree.<init>(Unknown Source)
            at javax.swing.JTree.<init>(Unknown Source)
            at com.sap.aii.ifr.navigation.IFRJTree.<init>(IFRJTree.java:84)
            at com.sap.aii.ifr.navigation.IFRTreePane.buildPane(IFRTreePane.java:123)
            at com.sap.aii.ifr.navigation.IFRTreePane.<init>(IFRTreePane.java:33)
            at com.sap.aii.ifr.upload.client.SAPNavigationPane.<init>(SAPNavigationPane.java:43)
            at com.sap.aii.ifr.upload.client.SAPBrowser.setIsConnected(SAPBrowser.java:252)
            at com.sap.aii.ifr.upload.client.SAPBrowser$ConnectAction.actionPerformed(SAPBrowser.java:594)
            at com.sap.aii.ifr.upload.client.SAPBrowser$NextAction.actionPerformed(SAPBrowser.java:536)
            at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
            at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
            at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
            at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
            at java.awt.Component.processMouseEvent(Unknown Source)
            at javax.swing.JComponent.processMouseEvent(Unknown Source)
            at java.awt.Component.processEvent(Unknown Source)
            at java.awt.Container.processEvent(Unknown Source)
            at java.awt.Component.dispatchEventImpl(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Window.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.EventQueue.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.run(Unknown Source)

    Hi,
    >> Error :- java.lang.NoClassDefFoundError: com/sap/aii/security/proxy/KeystoreHelp
    1) Can you check the class path  you have mentioned  is correctly
    2) Setting of the Java in your system ( Desk top /Lap top ) check the Proxy settings
    3) Re start the J2EE engine in the server
    Regards
    Agasthuri Doss

  • Crystal XI R2, Salesforce 3.0, Windows 7 64-bit, Java connection error

    All,
    I've got the same problem as this thread -- Re: CR XI R2: Salesforce 3.0 driver on Windows 7 64-bit?
    Crystal XI R2, Salesforce 3.0 downloaded from the Crystal page.  Using Windows 7 64-bit.  Have applied SP 5 per another thread.
    Continue to get JAVA error.  Java being used is 1.4 as installed by Crystal in the Crystal program directory.
    thanks, jhb

    Don,
    Still no go.  I get the same error.
    I uninstalled SP6, SP5, Salesforce Connector, and Crystal XI R2 SP2 and then re-installed everything.
    1) Crystal XI R2 SP2
    2) Salesforce connector 3.0
    3) SP5
    4) SP6
    Still get the same Java Connection error.  I've also disabled Windows Firewall.  I'm not behind a proxy.  I've tried with and without the security token.
    thanks, jhb

  • ABAP Java connectivity

    Hi ABAPers,
    I want to have a sample program for SAP Java connectivity. I know SAP has a JCo but how to go about it. We have another system which needs to communicate with SAP 4.6C. Also, I would like to know whether while reading tables from other system, can this program update our tables.
    Thanking you.

    Hi,
    To use JCo, download it (including the Javadocs) from http://service.sap.com/connectors. The zip file contains a comprehensive tutorial to program using JCo. You can also take a look at the FAQ on JCo at http://www.sapgenie.com/faq/jco.htm for more information.
    If you just want to take a look at the sample code, you can download the tutorial from http://zerone.samcheok.ac.kr/Asp_pr/Language/.%5Cuploadfile%5CJCo%20Tutorial-1.pdf
    You can definitely use JCo to update tables in SAP. You will either have to call an existing BAPI, or an RFC FM to do so.
    Hope this helps. Let us know if you need further assistance.
    Regards
    Message was edited by: Shehryar Khan
    Message was edited by: Shehryar Khan

  • Java connection exception

    I am trying to connect to an external server from a proxy , but I get a java.connection exception : remote host did not respond within the time
    out period ..
    how do i solve this issue ? can i explicitly set an increased time out on the connection ?

    I am trying to use sockets to address the issue of time outs..the code i have is as follows..i am trying to post an xml file , i dont seem to be getting a response nor am i erroring out ?
    String host = "http://mysite.activation.com";
    Socket sckt = new Socket(host,80);
         sckt.setSoTimeout(10000);
         String method = "POST";
    String messageString = "<?xml version='1.0' encoding='UTF-8' ?>" +
         "<Test.Users>" +
         "<User userID='"+test+"' />"+
         "</Test.Users>" ;
         OutputStream out = sckt.getOutputStream();
         out.write(method.getBytes());
         out.write(messageString.getBytes());
         out.flush();
         out.close();

  • Java connection - no application name in sp_iqshowpsexe

    We have Java connection to IQ 15.4.
    sp_iqshowpsexe 13386, under application column, it has
    HOST=appdb1p.nam.nsroot.net
    Is there a proper way put logic to Java Code, so we can identify the Java application name?
    For example, with Windows dbisql; it is reported back.
    HOST=VDI;EXE=C:\sybase\iq154\...\dbisql.exe;

    You can use the APPLICATIONNAME property on the JDBC connection URL to set the value.  This property is documented at:
    SyBooks Online
    For example:  jdbc:sybase:Tds:myhostname:portnum/mydb?APPLICATIONNAME=OurJavaAppName
    Regards,
    Ken

  • Java connect to oracle

    I have 2 database server to store data and 2 backup database server to backup data. I want to use java connect to 2 database server (or more) When 2 database server die, Java will automacally connect to 2 backup database server. How can I do ?

    Oracle has features for standby databases; their configuration has nothing to do with Java, it all happens within Oracle software...
    There are books about this, such as "Oracle Database 10g High Availability with RAC, Flashback, and Data Guard"...

  • How Java connect to LDAP?

    Hi guys
    Does anybody know how Java connect to LDAP server. Thanks in advance.
    Regards,
    Mark.

    http://www.java-pro.com/code/2000/JP0012.zip is the source code for the December 2000 issue of Java Pro magazine, which had an article about this. Inside you will find JP0012JB.zip which is the source code for working with LDAP. You don't get a copy of the articles in this zip file, only the code.

  • Java connect to SAP R/3

    I would seek for opinion on the problem that we're currently encountered related to java We are developing an intranet system using Java and Borland Enterprise Server as an application/web server and also connecting to SAP R/3 database to get certain informations. The problem is that the connection to the database is not disconnect eventhough users already logout from the system. I can check the connection via the SAP (transaction SM04) and the connection are still established.
    According to the Java developers they already put in the disconnect statement in the java program.
    Pls help.

    Try and adhere to this pattern :
    Datasource datasource = //Go configure your own datasource if you need to
    Connection con = null ;
    PreparedStatement pstat = null;
    ResultSet rset = null; 
    try {
       con = datasource.getConnection() ;
       pstat = con.prepareStatement(SQLSTRING) ;
       rset = pstat.executeQuery() ;
       if(rset.next()) {
               //blah blah
    } catch (SQLException e) {
      e.printStackTrace() ;
    } finally {
       try {
          rset.close() ;
          pstat.close() ;
          con .close() ;
        }catch (SQLException e) {
           e.printStackTrace() ;

  • Nakisa OrgChart STVN 21 JAVA Connectivity issue with ECC 6.0 Ehp4

    Dear Nakisa,
    We have deployed Nakisa component with following steps:
    1. Java component OrgChart21 TalentOrgChart21_16.sca on SAP Netweaver CE 7.1 Ehp1.
    2. applied Nakisa "STVN21_Addon_NW701.SAR" and "STVN21TP_OCOMECC60_1_1.zip" on SAP ERP 6.0 Ehp4.
    3. Created SSO connectivity between NWCE and ERP 6.0 Ehp4.
    5. Applied Nakisa License on portal using following URL:
    http://coe-lba-asd1.group.coe:57000/OrgChart/manager.jsp
    6. We have provided security settings entries without role mapping and getting following issues while accessing Nakisa user portal:
      404   Not Found
      SAP NetWeaver Application Server 7.11 / AS Java 7.11 
      Error: The requested resource /default.jsp is not available
      Troubleshooting Guide https://sdn.sap.com/irj/sdn/wiki?path=/display/jsts/home
    Details: File [default.jsp] not found in application root of alias [/] of Java EE application [sap.com/com.sap.engine.docs.examples].
    Now we would require implement connectivity between Nakisa JAVA component and ERP 6.0 Ehp4. Please help us with its procedure.
    Regards,
    Raj

    Hello,
    The connectivity if I understand you correctly is based on the Connection String.
    Please refer to the page 33 "Setting the Authentication Source" on the Administrator Guide for STVN2.1.
    An example of connection string would be:
    ASHOST=SAPTWO SYSNR=02 USER=gsmith PASSWD=PWD1234 CLIENT=800
    Cheers,
    Bentow.

  • ABAP to JAVA connectivity

    Hi Experts,
    I want to call JAVA program in ABAP, how I can achive this.
    -Rajneesh Gupta

    Hi Rajneesh,
    You can use the the class CL_GUI_FRONTEND_SERVICES. In this you can use the EXECUTE method .
    Before this you need to create a connection in SM59 where you need to define the path of the Java batch file.
    You can also use the FM 'SXPG_COMMAND_EXECUTE'. Where you can define the path of the Java batch file kept on the application server.You can create external OS command using SM69 and then call that external OS command using the above FM.
    Thanks & Regards,
    Anuj

  • Oracle Java connectivity

    Hi,
    I have installed Oracle 10g on Fedora Core 6. I've been trying to connect to the database via java using jdk1.5(using both drivers, classes12.jar and ojdbc14.jar). But its giving an error Network Adapter Failed. Can any one shed some light on this. Individually both are working fine, oracle 10g and jdk1.5
    Thanks in advance
    Shanky

    Yeah....i was tryin to connect from the same system. And also i have checked the version of java to be jdk1.6. Are there any new drivers from oracle side for jdk1.6?
    Also which oracle driver should be used for jdk1.5?
    And btw....what is tnsping?
    I am able to connect to Oracle using SQL*Plus normally. What is meant by name resolution?
    Thanks in advance for your patience
    Regards
    Shanky

  • Oracle java connection

    Hi,
    I've a problem in the connection between a
    Oracle DBMS 7.3.3 to a java application. The
    Oracle DBMS is working on AX 4.3 (Unix) machines and my java 1.1 application in working on a linux machines. I look for a jdbc driver for oracle 7.3.3 but I find only one for oracle 7.3.4 for solaris system. It is useful?
    Ciao
    Michele
    null

    Make sure the class12.zip file is there in the classpath (Assuming you are using JDK 1.2.X)..
    And try the conection as
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // Connect to the database
    // You must put a database name after the @ sign in the connection URL.
    // You can use either the fully specified SQL*net syntax or a short cut
    // syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
    Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@dlsun511:1721:dbms733",
    "scott", "tiger");
    For the Personal Oracle and JDBC connection you need to start the listener.ora and try connecting. or
    you can use the connect string as
    Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@",
    "scott", "tiger");
    Regards
    Ravi

  • Java Connection Pooling issue with Oracle 10g Express Edition

    Hello
    I have a Java based web application that uses the Oracle 10g Express Edition database. I am using a connection pool to get connections to the database.
    I use the NetBeans IDE and run my web application on the bundled Tomcat server(5.5.7) that comes with the IDE. Though when I initially run the application from the IDE, the connection pool is set up fine, when I recompile my java code and try to run the application again, I get the following error each time:
    Listener refused the connection with the following error:
    ORA-12516, TNS:listener could not find available handler with the
    matching protocol stack.
    The logs before the error shows up, indicate that the connection pool object is fine and gives me the number of available connections and the number of active connections and so on, which I have printed from the constructor of the Connection Pool class:
    For e.g.:
    Cache size = 17
    Available Connections = 17
    Cache Limit = 1000
    Active size = 0
    However, if I kill my Tomcat server process and run the application again, it works fine with no error.
    I looked around for possible causes and solutions and all I could find
    was increasing the processes parameter value in the init.ora file. I have increased the parameter value to from 100 to 20000 now, in increments of 500/1000 each time but it hasnt worked so far.
    Someone else suggested that I increase the size of my connection pool; I initially had it set to a minimum limit of 5, an initial limit of 10 and a maximum limit of 1000. However if I set the Initial Limit to anything above 17 connections, I see the following log on the Bundled Tomcat log and my application doesn't run at all:
    Log: Loading JDBC Driver : class=oracle.jdbc.driver.OracleDriver ...
    Log: Loaded JDBC Driver
    Log: Connection with URL=jdbc:oracle:thin:@localhost:1521:xe as username/password
    Error code not handled : 0
    Exception Message :java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12519, TNS: no appropriate service handler found
    The Connection descriptor used by the client was:
    localhost:1521:xe
    // End of log
    And the Bundled Tomcat server automatically shuts down.
    Again the System.out statements from the Connection Pool class constructor show that the cache has been initialized and that currently there are free connections available in the pool.
    E.g.
    Cache size = 18
    Available Connections = 18
    Cache Limit = 1000
    Active size = 0
    Has anyone faced anything similar? Could someone please suggest what I'm doing wrong here and what I should do to set right this problem?
    Swetha

    hello, please pardon me, my english is basic. i do of my best. i had the same problem until reading the pdf documentation 2 days for java devvelloper.it is simple, follow this way.
    try {OracleDataSource ds;
         Connection conn;
      ds = new OracleDataSource();
      ds.setURL("jdbc:oracle:thin:@localhost");
      conn = ds.getConnection("userid","password");
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    don't forget to Dowload the user client of oracle Express Edition. do the rest of your program and it will work. take a look to the documentation pdf for java develloper. all it is explained.  good look                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java connectivity with db2 in linux

    hi all,
    i wish to know how to connect java with db2 in linux.actually which is the string that is to be included in the following:
    class.forName("//which is the string that is to be included here");
    Connection con("jdbc:????");

    hi all,
    i wish to know how to connect java with db2same as every other database and OS. JDBC is the way.
    in linux.actually which is the string that is to be
    included in the following:
    lass.forName("//which is the string that is to be
    included here");full name of the DB2 JDBD driver class.
    Connection con("jdbc:????");look at the docs for your JDBC driver to figure out what the URL needs to be.
    %

Maybe you are looking for