How to store Connection object and call it from other programs.

Hi,
I am trying to connect to the database, store the connection object and use this connection object from other standalone java programs.
Can any one tell me how to do this? I've tried in the following way:
In the following program I am connecting to the database and saving the connection object in a variable.
public class GetKT2Connection {
   public static void main(String[] args) {
      String url = "jdbc:odbc:SQLDsn;
      String dbUser = "sa";
      String dbPwd = "sa";
      Connection kt2conn = Connection connection = java.sql.DriverManager.getConnection(url, dbUser, dbPwd);
      if(kt2conn == null) {
         System.out.println("Database Connection Failure!");
      else {
         System.out.println("Connected to Database...");
     GetKTConnectionObj.storeKT2ConnectionObj(kt2conn);
} Here is the program to save connection object in a variable.
public class GetKTConnectionObj {
   static Connection kt2Connection = null;
   public static void storeKT2ConnectionObj(Connection conn) {
   kt2Connection = conn;
   public static Connection getKT2ConnectionObj() {
   try {
      return kt2Connection;
   catch(Exception e){
      System.out.println(e);
  return null;
}Now from the following code I am trying to get the connection object that is stored. But this is throwing NullPointerException.
public class Metrics_Migration {
  public static void main(String args[]) {
     try {
    java.sql.Connection connection_1 =   GetKTConnectionObj.getKT6ConnectionObj();
     catch(Exception e){
}

kt2Connection is null. You need to store it first, to make it not null. Otherwise it will stay null forever. And why on earth are you trying to do this THIS way?
If you are running the two applications separately, it wont work either.

Similar Messages

  • Hi. how to create Subroutine Pool and call it from sapscript

    HI,
    Can anyone tell is there any standard subroutine pool available which could fetch the customer number. 
    how to create an subroutine pool and call it from the sapscript..
    please help me
    Advance Thanks..
    Guhapriyan.

    Hi Guhapriyan,
    1. Create a FORM in your program.
    2. call it from sapscript using
    /:   PERFORM GET_COMPANY_INFO IN PROGRAM YHRR_OFFER_CONTRACT_FORM      
    /:   USING &P0001-BUKRS&                                               
    /:   CHANGING &COMP_NAME&                                              
    /:   ENDPERFORM                                                        
    3. The form in your program should be of the following  parameters only.
    form GET_COMPANY_INFO tables IN_PAR  structure ITCSY
                            OUT_PAR structure ITCSY.
    (important is IN_PAR, OUT_PAR -
    where in your read the values passed,
    and pass back the values
    thru internal table using varname, varvalue)
    regards,
    amit m.

  • How to store a file and refer it from another file using the Binary cache?

    Hello,
    I think it's a long shot but I thought I will give it a try.
    I am creating an excel file from an xml String using the Web Dynpro Binary cache.
    The problem is that when columns with numbers are involved an extra #agg column is being added by the excel "flattener" which is in charge of rendering the excel file from the xml String.
    The only way to override this excel feature is to supply your own XSLT and reference it from the XML. Now, since I am not using an actual filesystem but the Web Dynpro Binary cache, is it possible to use this cache in order to store there the xslt and refer it later from an XML?
    Roy

    Hi,
    Just found out this.. See if you can make use of it..
    getPublicCachedWebResource(byte[] webResource, WDWebResourceType resourceType, WDScopeType scopeType, WDDeployableObjectPart deployableObjectpart, String key)
    <i>          returns a IWDCachedWebResource, <b>which is saved directly to the WDDeployableObject directory.</b></i>
    you can make WDDeployableObject as your component and point the reference to the component folder.. Since you are specifying a scope type.. it shoukd be deleted after the scope defined...
    Lemme know if this works..:)

  • Create DLL from labview and calling it from other application

    I have an application built using Labview. I wanted to create DLL out of it. The application has
    two String inputs start and stop buttons and two status indicators.
    1. How to itegrate start and stop buttons from function prototype?
    2. Does Labview created DLLs requires labview runtime engine when it is to be called from other application?
    Can some one help on this.
    Solved!
    Go to Solution.

    Hi Yuvish,
    1) They should be boolean inputs to your VI. But does it makes sense to provide a stop button input at the start of your VI? (THINK DATAFLOW!)
    2) Yes, the LV-RTE is needed...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Netscape.cfg error on startup and no linking from other programs...

    When I start up Firefox 4.0.1, it gives an error message regarding a netscape.cfg file. If I happened to use a link embedded in an email to open Firefox, it does not appropriately link -- instead it still goes to my homepage. If Firefox is already open, it will link from another program.
    I am not the only person having this problem.

    Menchar,
    Where did you get this application, and has it ever worked before? What version of Measurement Studio, Visual Studio, and NI-Daq was it built on ? If it has worked before, what changed, and is it possible to strip down any parts, so you can test the pieces individually rather than the program as a whole? Also are you getting NTDLL errors while doing anything else on this computer? It may be a corrupt NTDLL.dll file http://www.downloadatoz.com/howto/How-to-resolve-ntdll-dll-error.html.
    You can view the OCX file path if you  go to Project » Add to Project » Components and Controls and select a specific CW control under the Registered ActiveX Controls. I have attached a screenshot showing an OCX file pat.
    Richard S -- National Instruments --Applications Engineer -- Data Acquisition with TestStand
    Attachments:
    2009-05-05_165739.png ‏23 KB

  • How can I transfer text and call history from an iPhone 5 to an iPhone 6 Plus?

    I just received the iPhone 6 Plus today.  In moving information to it from my iPhone 5, I discovered that my text history, call history, and voicemail history haven't been transferred.  I had synced the iPhone 5 to iTunes and then synced the iPhone 6 Plus to iTunes.  But, since the operating system on the 6 Plus was newer than the 5, iTunes made me treat the 6 Plus as a new phone instead of just backing up the old phone.  How can I transfer the call, text, and voicemail history?

    Make a backup of the old device and restore the new device to that backup. You will get an exact duplicate of the old phone.

  • How to find the value of a variable in other program

    How to find the value of a variable in other program say I am in a FM and this FM is being called in from other program and I want to know some of the variable details of the program from the FM itself. Imagine if this is a txn. and I need to know the details from some of the programs while executing the same transaction
    Regards
    Vin

    Hi Vinayak,
         you will be having your first program values in internal table or some variables,
        when you are calling the second program you wii use like this,
        SUBMIT <Second Program Name> USING SELECTION-SCREEN '1000'
                           WITH s_emp(second program select-options)   IN t_emp(first program variables)
                           WITH p_chk   EQ t_chk
                           WITH p_r1    EQ t_r1
                           WITH p_month EQ t_month
                           WITH s_cust1 IN t_cust1
                           WITH p_r2    EQ t_r2
                           WITH s_cust2 IN t_cust2
                           WITH s_week  IN t_week
                           AND RETURN.
    you have pas like this to get your first program details.

  • Error in creating Connection Object and Device Location

    Hi ,
    When i am creating Connection Object and Device Location , system is giving dump . all other object are working fine.
    the error is gievn below :
    Error in reading table TE130.
    i checked this the table , its have no entries ( mainly field ISTYP is blank ) and this is the cause of problem .
    Could you please tell me that how to fill this table before creating Connection object and device location. i think some configuration should be needed for this but i dont know how .
    thanks and regards
    Deepak.

    Hi Deepak,
    You can check standard configuration in client 000.
    Meanwhile you can use this settings:
    ISTYP TPLKZ FLTYP NUMKI NUMKE
    C     AO_GP     A     01     OC
    D     AO_GP     G     02     OC
    This is where you define structure indicator for isu technical location category.
    ISTYP correspond to the type of technical location in ISU, C for connection object and D for device location
    The content of TPLKZ is defined in the following menu in SPRO.
    Plant Maintenance and Customer Service
    Master Data in Plant Maintenance and Customer Service
    Technical Objects
    Functional Locations
    Create Structure Indicator for Reference Locations/Functional Locations
    Hope it helps,
    Regards,
    Daniel Valenzuela
    Edited by: Daniel Valenzuela on Feb 4, 2008 3:22 PM

  • How to make own editor and call it?

    could you please tell me how to make own editor and call it on a clicking of a push button corresponding to an test Item

    In the Object Navigator... just click on the 'Editor' Node and press the '+' (Create) button....
    Set then any properties as you like....
    So simple...
    Greetings,
    Sim

  • How to store java object in oracle

    Hi all,
    is it possible to store jva object in oracle.
    I have defined myClass. It have only data fields ( no methods).
    I make myClass myObject = new myClass();
    How can I store this object in oracle DB.
    Many thanks in advance.

    1.Convert this object into stream of Bytes.
    2.create a new InputStream from these Byte array.
    2.Use the setBinaryStream to set the values inside the table's column.
    3.Store this object as a Blob in the table (column type must be Blob).
    Hope this helps.
    Sudha
    PS:- Somebody explained in this forum how to convert an Object into Byte array .

  • How to store photo images and thumbimpressions in oracle 10g database

    Hi all
    I have an web application running in Oracle 10g rel 1 database server in RHEL3. It has application server with forms and j2ee component as middle tier. I need to store centrally photo images and thumb impressions and use it in our application without any overhead on retrieval and performance of web application. what will be optimized method of storage of photo and thumb impressions. Awaiting your valuable suggestions.
    Regards
    Vijay Kumar

    Hi Vijay,
    How to store photo images and thumbimpressions in oracle 10g database I have working code here for storing photos in Oracle tables that you may find useful:
    http://www.dba-oracle.com/t_storing_insert_photo_pictures_tables.htm
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • CONNECTION OBJECT AND POD

    hi experts,
    can any one of you explain what is connection object and point of delivery with any example.

    Hello
    Connection object is the place where the Utility service is provided. It can be a building, or a transformation center in the street or a fountain. It is just where you provide the service.
    PoD is an object for the de regulated market. It is a universal coordinate on where the service is provided. Imagine you switch  from UItility company A to company B. When both companies exchange your data, the only data that both companies know for sure is your PoD.
    PoD number is created via an algorithm which is unique for your whole country.
    Hope it helps
    Joaquin

  • Connection Object and Street name

    Hi,
    Could anybody please specify the table name in which we can find the Connection object and Street name?
    Thanks and Regards

    Table EHAUISU you will have the connection object number.
    Then go to ILOA table give the connection object number in Functional loc. and execute it.
    You will get the address number. Then go to ADRC table to know the street name.
    You will not find the data in a single table.
    If you want to find then go to views
    V_EHAU_ADDRNR : IS-U Connection Object: Optimized Access for Address Number  "you will find address number for connection object.
    V_EHAUADR  :  You will get street name for connection object.
    Please let me know if you want any more details. if have any issues with answer then let me know the exact question for the same.
    Thank You.
    Regards,
    Siva

  • How to create a java application & call it from a PDA via TELNET

    Dear All,
    My objective is to create a java application that's hosted on a server and called remotely from a PDA using TELNET.
    I've created a java application using Eclipse & the jCurses library. Unfortunately, the jCurses API events and listener aren't enough and i wasn't able to achieve my target application functionality.
    Can anyone advise a library other than jCurses that can help create a java application that can be called from a PDA via TELNET?
    Is AWT an option ?
    Thanks in advance for your support,
    Best regards,
    Lana

    user10827661 wrote:
    My objective is to create a java application that's hosted on a server and called remotely from a PDA using TELNET.
    I've created a java application using Eclipse & the jCurses library. Unfortunately, the jCurses API events and listener aren't enough and i wasn't able to achieve my target application functionality.
    Can anyone advise a library other than jCurses that can help create a java application that can be called from a PDA via TELNET?
    Is AWT an option ?Your server side Java application can use a Java library that
    creates a java.net.ServerSocket to listen for TCP connections from TELNET clients.
    You do not need any graphics (jCurses or AWT) on the server side, telnet is a simple ascii protocol.

  • How can I connect to a windows server from a mac book pro

    How can I connect to a windows server from a mac book pre?

    I have a Dell Power Edge T110 ii in the office that has files and software I need to access when away from the office, when I am on the road I use a mac book pro and an iPad.
    I am sorry if I am being a bit vague but this is all new to me, I have tried 3 IT guys but they can not find a way.
    Any help is greatly appeciated.

Maybe you are looking for

  • Acrobat 9.0 Runtime Error Vista SBS 2003 Folder Redirection Issue

    I just got off of a two hour phone call with Adobe. They are unable to resolve my issue. After installing Acrobat 9.0, we receive the following error: "Microsoft Visual C++ Debug Library Runtime Error! Program: C:\Program Files\Adobe\Acrobat 9.0\Acro

  • Preview shows some text incorrectly in pdfs

    I have recently had problems viewing pdfs in Preview. This applies to new pdfs that I have downloaded as well as old ones that were already on my computer. I am a graduate student in biology, so I download and read many scientific articles as pdfs on

  • Pre Data Transfer Assistent Crashes

    I guess I'd describe the situation for mac users with Pre's as dire at this point. I have a mobile me account and it's not supported (I guess missing sync will handle that). Right now, I can't even get my numbers over with the data transfer assistant

  • Fresh install of iPhoto 11 won't open - say's it needs update.

    Hi, I need some help here. I just re-installed my MBP (mid 2010) with OSX Lion, got all updates. After that i installed my iLife 2011 software bundel, and got every update downloaded and installed. Rebootet and then tried to start iPhoto (for the fir

  • How do you close apps running in the background in iOS 7?

    Do you know how to close apps in iOS 7?  In iOS 6 you held your finger on them and when the minus sign came up you closed them that way.  This saved the battery.  Now there is no way to close the apps once you close them and it runs the battery down