Connection Object as a parameter !

I have got a jdbc connection object. Is it a good practice to send the connection object as parameter to a method??

yes..really it is good practice to send as parameter...i too use this way

Similar Messages

  • Passing connection object as EJB parameter

    I am working on a legacy website which uses stateless session EJB's and runs on
    WebLogic 6.1 using JDK 1.3 and Oracle 8.1.6, I am working on upgrading this
    application to WebLogic 9.2, JDK 1.5 and Oracle 10.2.
    I configured a datasource in WebLogic using the Oracle thin XA driver.
    When attempting to run the application I got an error message stating that an
    object which is not serializable is being passed as an EJB parameter. I found that
    several EJB methods are passing open database connections as parameters so to fix this
    issue we should change the code. However, I am reluctant to change the code since I
    believe that the reason for passing the connection objects is that the developers
    wished to preserve transactions and so any changes might result in many issues in
    the application. I have the following questions:
    - The code is doing something which is not allowed. So why was this okay in WebLogic
    6.1 using the older Oracle oci driver?
    - One way to get around this would be to convert the EJB's to POJOS. There are no
    container based properties and the only EJB's are stateless session EJB's. The
    high water mark for concurrant usage is 40. There is only a single server (no clustering)
    What kind of issues would such a
    conversion bring?
    - Would it be better to convert the EJB's to local interfaces? What kind of issues would
    this bring?
    Any other suggestions would be very much appreciated.

    Salma Saad wrote:
    Thanks Joe,
    Converting to POPJOS from EJB or to local EJB's is changing the code but it limits changes to the logic of the application which could result in unforseen issues.
    There is only 1 server and 1 jvm but I get a not serlializable exception which I did not get when running this code on WebLogic 6.2 or 8.1 using Oracle 8.1.6 and 9i .I am getting it now that I am using WL 9.2 and Oracle 10.2.
    I looked through all the parameters and everything is a string except for Connection which does not implement serializable. There is a Vector but all the contained objects are strings. Let me know if you have any ideas what I can do to get rid of this, and also why is it happenning in the newer version of WL when it didn't happen before?
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****
         at weblogic.rmi.internal.CBVWrapper.copy(CBVWrapper.java:57)
         at com.isr.applications.isrinteractive.ejb.sessionbean.user.UserBean_x07h56_EOImpl_CBV.validateLogin(Unknown Source)
         at jsp_servlet._admin.__validatelogin._jspService(__validatelogin.java:187)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)Hi. I looked at the code throwing this exception, and
    it's in a whole 'nother area of the server, nothing to
    do with JDBC or EJBs as such. It's odd too, because it
    seems to have already verified that whatever object
    it's dealing with is a serializable object...
    I recommend you're opening an official support case
    about this exception, and maybe they'll want help
    reproducing it...
    Joe
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:391)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:309)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.isr.applications.isrinteractive.servlets.reports.SessionFilter.doFilter(Unknown Source)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3212)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Caused by: java.io.NotSerializableException: java.lang.Object
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
         at weblogic.rmi.extensions.server.CBVOutputStream.writeObject(CBVOutputStream.java:84)
         at weblogic.rmi.internal.CBVWrapper.copy(CBVWrapper.java:49)
         ... 20 more

  • Connection Object from devices FM

    hi all,
    Is there any function Module that can be used to retrieve the connection object for a device.
    regds,
    stock

    Hi stock,
          Use ITOB_FUNCLOC_READ_SINGLE by inputing device in I_FUNC_LOCATION field. The resulting connection object will be in the export parameter E_OBJECT_REC. ie E_OBJECT_REC-TPLMA will be your connection object.
    Please reward points if useful.
    Regards,
    Harikrishna.

  • 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.

  • Error in creating connection object

    Dear Experts
    When I am creating connection object using ES55 , I get Stop message saying : " Alternate ID not supported" and when i see Help it indicates : An alternative indicator is active in Customizing of the functional location. This functionality is not supported for connection objects and device locations
    what could be going wrong
    Plesae suggest me the solution
    Thanking you in advance
    warm regards
    narasimha

    Hi,
    Please check the following settings in SPRO:
    Plant Maintenance & Customer Service - -Master Data in Plant Maintenance & Customer Service --Technical Objects --Functional Locations --Alternate Labeling of Functional Locations - - Activate Alternative Labeling --
    In this setting pls inactive the setting for Alt.Label.Then go to ES55 and try.It will work.
    Thanks,
    Banasri Mitra

  • Passing object as a parameter to a method while dragging it to UI

    Hi
    I am using webservice datacontrol to invoke "Secured webservice". Dragged a method from datacontrol and dropped it into UI, it passes a object(i.e., SOAHeader object) as input parameter and returns "String" as a output. So, here I have created a java class and passing it as an object to the method. When i deployed the app into Android emulator, while clicking that method as a button, its throwing me an error message *"HTTPStatusCode 500: Server encountered an unexpected condition which prevented it from fulfilling the request"*. I tried to configure debugger to get log for remote deployment, after that the application itself not opening in emulator. Then how can i find the exact reason for this error message?
    Here I got few doubts,
    1) Is this the correct way of passing the object as a method input parameter?
    2) How can i invoke secured web service through "Webservice datacontrol" in ADF Mobile. I searched in google and got a link by andrejus "http://andrejusb.blogspot.be/2012/11/adf-mobile-secured-web-service-access.html", but not understanding about "*adfCredentialStoreKey*", what is it? and how can i use it?. I set the security policies as mentioned, is it enough to invoke the secured webservices without giving username/password?. Bit confused, can anyone please tell me more about accessing secured webservices from webservice datacontrol.
    3) I tried to configure debug option(as mentioned in developer's guide) to get log of remote deployment. I changed *"java.debug.enabled=true"* in cvm.properties. After that configuration, unable to open that mobile app through emulator. What could be the reason?
    Regards
    Raj

    Thank you Shay.. you have posted new demo's regarding this for people like us(Newbies in ADF), awesome :) Please keep continuing.. This demo & Andrejus sample helps me a lot to do sample authentication using "**Remote login server**".
    Small doubt, Is it possible to inject user credentials with webservice request without creating *"regular" web ADF application, securing it, and deploying it on a server* . I read it in mobile document that,
    For secured web services, the user credentials are dynamically injected using ADF Mobile uses Oracle Web Services Manager (OWSM) Lite Mobile ADF Application Agent to create and configure proxies, as well as to request services through the proxies. The user credentials are injected into the OWSM enforcement context when proxies are configured.
    I am new with this OWSM, can you please give me some hints like how to proceed further for implementing authentication using OWSM lite mobile ADF Application Agent.
    Thanks in advance

  • Duplicate check for Connection Objects in CRM

    Hi,
    I want to implement a duplicate check for connection objects in CRM. The duplicate check shall use the address of the connection object and perhaps additonal attributes. I have found a duplicate check for business partners using the basis address service and TREX as index pool. However, I couldn't find a similar functionality for connection objects. Does somebody know:
    1) How to implement a duplicate check for connection objects which is based on the address of the connection object?
    2) Is there a way to use the TREX-based duplicate check which is integrated into the basis address service for connection objects?
    Thanks in advance!
    Best regards,
    Frank

    I also have a requirement to check for duplicate address at connection object level and we are using SAP data servies to validate the address. Can anyone share their experience.

  • Creating logical/virtual connection object  from physical connection

    Can anybody help me what is creating logical/virtual connection object and how to create it from physical connection in java ??
    Thanks in advance...

    WHile you are waiting for an answer, you might want to review the related Oracle documentation:
    For 10g, all docco is at http://www.oracle.com/pls/db102/portal.portal_db?selected=3 and docco I suspect will help you is "Java Developer's Guide" and "JDBC Developer's Guide and Reference"

  • Statements in Connection Object

    Hi All,
    I am using Oracle 8i as my database and JDBC 2.0 for connecting my Java program to Oracle.
    I know that from single connection object I can create multiple statements and execute them. But can any one say me what is the maximum no. of statements which can be created from a single connection object? Or is there no limit on that?
    ..Raj

    Only limited by your memory, no theoritical limit

  • Connection Object filed in O/P file

    Dear Experts,
    As per my requirement, i need to get the connection objects fields in output Excel file, but right now, through el06 they are generating mass data, but in that output file one filed is not coming, but it was maintained in connection object .
    now i want to get that filed ( filed name "other city" ) in my excel sheet also.
    can any body have clue , how to get that filed in my output file also.
    cheers..

    Hi Avinash,
    Thanks for reply, my req is, i have to give the data to meter readers, to which location they have to go , for collecting the MR readings, in that list i need all the fields which i maintained in CO. i guess they didn't maintained one filed earlier, now i want to have one filed in o/p excel sheet.
    hope i made clear.
    Cheers.

  • Threaded Queries from Single static Connection object - Good approach?

    Hi,
    I need to generate a report where I need to query count(1) from over one hundred tables from oracle 10g database. I am not updating or deleting any record.
    My approach is to use a single static connection object and create one thread for each table and capture the result back into a static hashtable.
    But still, I am not getting any substantial performance improvement. Earlier, my report took 40 minutes, when it was non-threaded and now it takes 30 minutes.
    Is there anything more I can do to make my report get the counts faster? Will a connection pool help?

    Tolls wrote:
    jschell wrote:
    I was told by the DBA that count(1) works faster than count(*)....that's why....Unlikely. Certainly not true in current versions of Oracle if that is the source.Not unlikely, actually not true. Beneath the hood Oracle turns a count(1) into a count(*) in order to deal with this. Why? Because count(1) is turned into count(*) in order to avoid it being slower (Oracle 7 was the last time count(1) was different). And the reason generally given is because so many people were mistakenly using count(1) thinking it performed better that they decided to put in the "conversion" to fix the silly queries.
    I think this it the [Ask Tom|http://asktom.oracle.com/pls/asktom/f?p=100:11:109792721681931::::P11_QUESTION_ID:1156159920245] link I used last time this came up here.
    I knew all that, but I missed that the OP had specified the database vendor and version.

  • Passivation of Connection Object in Stateful Session Bean

    Hi all,
    I am developing a Stateful session bean that has a Connection object as its instance variable. And this bean starts transaction that spans across multiple method calls and finally either commit or rollback.
    BeanClass
    UserTransaction utx;
    Connection conn;
    ejbCreate()
    allocateconnection();
    ejbRemove()
    closeconnection();
    ejbActivate()
    allocateconnection();
    ejbpassivate()
    closeconnection();
    StartTransaction()
    utx = getusertransaction();
    utx.begin();
    Method1()
    do something with database
    Method2()
    do something with database
    CommitTransaction()
    utx.commit();
    For example, the typical usage of this bean would be:
    bean.StartTransaction();
    bean.Method1();
    bean.Method2();
    bean.CommitTransaction();
    Here are my two questions:
    1. General Question: In order for a Connection object to join a Transaction, Do I have to create the connection after the transaction has started?
    2. If the answer to the above question is yes, then: I understand that when this bean get passivated, the UserTransaction instance object would be passivated. And since the connection object can't not be passivated, I have to recreate the connection object in ejbactivate() method, would newly created connection participate in the same Transaction that was being passivated and now activated?

    >
    Hi all,
    I am developing a Stateful session bean that has a
    Connection object as its instance variable. And this
    bean starts transaction that spans across multiple
    method calls and finally either commit or rollback.
    BeanClass
    UserTransaction utx;
    Connection conn;
    ejbCreate()
    allocateconnection();
    ejbRemove()
    closeconnection();
    ejbActivate()
    allocateconnection();
    ejbpassivate()
    closeconnection();
    StartTransaction()
    utx = getusertransaction();
    utx.begin();
    Method1()
    do something with database
    Method2()
    do something with database
    CommitTransaction()
    utx.commit();
    For example, the typical usage of this bean would be:
    bean.StartTransaction();
    bean.Method1();
    bean.Method2();
    bean.CommitTransaction();
    Here are my two questions:
    1. General Question: In order for a Connection object
    to join a Transaction, Do I have to create the
    connection after the transaction has started?Strictly NO. In fact, the connection is obtained first and then can a transaction begin.
    2. If the answer to the above question is yes, then: I
    understand that when this bean get passivated, the
    UserTransaction instance object would be passivated.
    And since the connection object can't not be
    passivated, I have to recreate the connection object
    in ejbactivate() method, would newly created
    connection participate in the same Transaction that
    was being passivated and now activated?
    The answer to first question being NO, your argument for question 2 does not hold true. According to the EJB specification, a stateful session bean can only be passivated between the transaction and not within a transaction. Your implementation for the stateful EJB is good to work.

  • How many Connections objects????

    Hi
    I am creating a GUI application which contains several GUI classes(e.g. frames and dialog boxes) which are instantiated depending on the choice of the user. I also have a Database class which contains the code which enables the connection to the database. The code creating the connection is within the constructor,therefore creating a connection whever I create an instance of the database class.
    Most of the GUI classes need to obtain or update information held in a database.
    Currently I create an instance of the Database class in every GUI class which needs to access the database. Obviously however every time a new database object is created, a new connection is also created.
    I am worried about all these database objects all containing their own connections.
    Should I have just one connection object in existence at any one time?
    If so,can I declare the Connection variable in the Database class as static?
    Any help/comments would be gratefully received.
    LGS

    From what I know, there should be no problem with maintaining multiple connections to the database. This is a property of the database itself, most allow about 256 connections. The only problem you face is a lost transaction. As long as you keep the queries serialized, you shouldn't encounter any problems.
    If you did want to only have one connection open... why not have another class for that (DBConn) and not instantiate a new connection in the constructor of your Database class. This way, each Database object can use the one connection by all referencing the DBConn object.
    Just a thought...

  • Passing a Vector object as a parameter to a method

    Hi,
    How can I pass a Vector object as a parameter to a method?
      void buttonAdd_actionPerformed(ActionEvent e) {
        Vector studentHobbies = new Vector();
          String[] items = listHobbies.getSelectedItems();
          for (int i=0; i<items.length; i++) {
            studentHobbies.addElement(items);
    newStudent = new Student(Name,StudentNumber,studentHobbies);
    studentenlist.addTo(newStudent);
    So I want to pass the Vector object 'studentHobbies'  to a method.
    Would I do something like this :import java.util.Vector;
    public Student(String Name, int StudentenNumber, Vector studentHobbies){
    this.Name = Name;
    this.StudentNumber = StudentNumber;
    this.studentHobbies = StudentenHobbies;

    yes, thats how you do it.
    maybe you should first try your idea and then ask people questions?
    also, use ArrayList instead of Vector, its better - google as to why if you care.

  • Hoe to pass object as a parameter thru webSerive

    I need to pass Object as a parameter to web service:
    example:
    public calss returnCodes{
    int ret_code;
    String ret_string;
    public retrunCodes(int ret_code, String ret_string){
    this.ret_code = ret_code;
    this.ret_string = ret_string;
    public int getret_code()
    return this.ret_code;
    public String getret_string {
    return this,ret_string
    and other repc holder class to hold returnCodes
    public class retrunCodesHolder implents javax.xml.rpc.Holder
    returnCode value;
    pubic returnCodesHolder(){
    public returnCodesHolder(returnCodes value) {
    this.value = value;
    In Webservice I use returnCodesHolder as parameter.
    WebService getReturnCodesWs I have
    returnCodes retCodes = new returnCodes(04,"Good return code)
    returnCodesHolder retholder = new returnCodesHolder(retCodes)
    return myString;
    When I am calling above webService in servlet I have code:
    org.test.mytest.returnCodesHolder retHolder = new org.test.mytest.returnCodesHolder();
    String result = port.getReturnCodesWs(retHolder);
    How to I access /get values of returnCodes class in my calling servlet?
    I am using Tomcat v 6.0

    I believe (although have never used, so if I'm wrong,
    correct me please!) you can do it with implicit
    dynamic cursors, such as:
    For rec in 'select col1, col2 from table 1 '||lstr
    loop
    Not really:
    michaels>  declare
       lstr   varchar2 (30) := ' where empno = 7788';
    begin
       for rec in 'select * from emp e ' || lstr
       loop
          null;
       end loop;
    end;
    Error at line 1
    ORA-06550: line 5, column 4:
    PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
       . ( * @ % & - + / at mod remainder rem .. <an exponent (**)>
       ||

Maybe you are looking for

  • Just upgraded to 5 from 3 - what happened to the page select icon? Can't find it in customize toolbars.

    Used to be you could select which page you wished to go back or forward to from the arrow icons on the navigation toolbar. The history menu item only shows 10 sites without having to open history for today. What happened? Is there another icon or a n

  • BIt locker script

    Can someone tell me if a script can be created in powershell to be able to unlock a certain drive with bitlocker?  We are manually doing it now.

  • Installation of Oracle 11g on Windows 8

    I am trying to install Oracle 11g Database in my windows 8 system. Whenever i click on the setup.exe the installer window pops up and nothing happens. I am running it as an administrator. I need some help on this. I have tried to run in compatibility

  • Report from CRT?

    Dear All, It's very urgent!!   My Client is asking flexible reports like Yearly, Quarterly, Monthly, Unlimited from CRT Tables by adding additional fields like Year, Cumulative Type, Specifice Period (If it is Quarterly in cumulative type field, then

  • Third party IM Client until Android client is released

    Hello all. I was wondering if anyone has successfully gotten a third party xmpp client to work on an android device and connect it to the Cisco Jabber service. I see there is an option in the admin console to allow third-party clients but have been u