Connection object size

Out of curiosity, how much memory would a Connection object use? I've heard that a db connection to a MS SQL Server takes 24K of RAM (If im wrong, pls correct me:). I'm wondering what object overhead (if any) is added ontop of this?
Thanks,
David

interesting ...
have you tried Runtime.totalMemory() and Runtime.freeMemory()?
I'll try and let you know.
saifuddin

Similar Messages

  • Connection object is getting closed before the stored procedure is complete

    Hi Everyone,
    I am facing an issue where by the java connection object is closed before the stored procedure it is connected to is complete.
    I am not sure if the fault is in SP or Connection pool.
    After spending some time, i could able to figure out that the procedure is taking a tad more time for processing as there are over 1000 records in the database tables it is dealing with.
    Would that be a potential cause ? or Am i required to handle it in Java only ?
    I want to know what could be possible causes for this issue ?
    Please Help.
    FYI,
    The following are the logs which says,
    XYZ (Stored Procedure) : Start Time is 1349217771302 Procedure started here
    INFO >2012-10-02 18:43:09,935 [ConnectionPool]: Closing connection: DataSource [ABC](684)
    INFO >2012-10-02 18:46:03,512 DAO[main]: XYZ : End Time is 1349217963512 Procedure ended here
    Thanks in Advance.

    Hi ,
    Thank you all for your quick response.
    Well it's my bad i dint provide you any code to look into thinking that i am dealt with a gen issue and also i am too paranoid to post any code i am dealing with in the forum (i am sorry).
    But here is some information for you,
    Database : Oracle 10g
    Java: 1.5 version
    We are using only One connection object for the entire java backend process .
    The SP is of over 1000 lines of code which for obvious reasons i can't past it here but this morning i figured out an issue in SP where by a query taking way more than usual time to execute which led to SP's poor performance and also the reason for why it is taking very long time than usual.
    This query is a simple SELECT query where it is trying fetch over 2000 records from a table of over 3 million records. The execution time is over 30-40 seconds which is the root cause of SP's poor performance.
    When i eliminated this from the logic and ran the query it could able process (inserting huge volume around 5000 records of data) in 1 second instead of 3-4 minutes earlier.
    I tried to replicate this issue (which occurred in our production server) in my local system but no luck as there was no connection issue here but only the substantial time difference.
    We are using a customized connection pool which is as follows,
    I am not sure what's going on here because it seems to be greek and latin to me.
    What we are doing in our DAO is we are using method of the below ConnectionPool.getInstance(SCHEMA) to get the connection object.
    Looking forward to seeking advice from you on how connection pool in general works.
    public class ConnectionPool extends Thread
         private static final ConnectionPool me = new ConnectionPool();
         private Hashtable dataSources = new Hashtable();
         private static final int MIN_TIMEOUT = 0;
         private long timeOut;
         private Hashtable cons = new Hashtable();
         private Hashtable active = new Hashtable();
        private boolean trace = false;
         private ConnectionPool()
              registerDataSources();
              this.timeOut = PropertyManager.getIntProperty("connectionPool.timeOut", MIN_TIMEOUT);
              setName("ConnectionPool");
              setPriority(MIN_PRIORITY);
              if (timeOut > 0)
                   start();
         private void registerDataSources()
            dataSources.clear();
              Properties props = System.getProperties();
              String app = props.getProperty("X", "Y");
              for(Enumeration e = props.keys(); e.hasMoreElements();)
                   String key = (String) e.nextElement();
                   if (key.startsWith(app + ".connectionPool.dataSources.") && key.endsWith(".selector"))
                        String ds = key.substring((app + ".connectionPool.dataSources.").length(), key.length() - ".selector".length());
                        LogManager.logStatus("Registering [" + ds + "] (selector) " +
                                  props.getProperty(app + ".connectionPool.dataSources." + ds + ".selector"));
                        dataSources.put(ds,
                             new GenDataSource(
                                  ds,
                                  props.getProperty(app + ".connectionPool.dataSources." + ds + ".selector")));
                        continue;                    
                   if (!key.startsWith(app + ".connectionPool.dataSources.") || !key.endsWith(".server"))
                        continue;
                   String ds = key.substring((app + ".connectionPool.dataSources.").length(), key.length() - ".server".length());
                   try
                        LogManager.logStatus("Registering [" + ds + "] " +
                                  props.getProperty(app + ".connectionPool.dataSources." + ds + ".url"));
                        loadDriver(props.getProperty(app + ".connectionPool.dataSources." + ds + ".driver"));
                   catch (Exception se)
                        LogManager.logException(se);
                   GenDataSource genDataSource = new GenDataSource(
                             ds,
                             props.getProperty(app + ".connectionPool.dataSources." + ds + ".useMatrix", "false").equals("true"),
                             props.getProperty(app + ".connectionPool.dataSources." + ds + ".server"),
                             props.getProperty(app + ".connectionPool.dataSources." + ds + ".url"),
                             props.getProperty(app + ".connectionPool.dataSources." + ds + ".user"),
                             props.getProperty(app + ".connectionPool.dataSources." + ds + ".password"));
                   // Set the schema if schema is defined in settings.xml file
                   if (genDataSource != null && props.getProperty(app + ".connectionPool.dataSources." + ds + ".schema") != null ) {
                        genDataSource.setSchema(props.getProperty(app + ".connectionPool.dataSources." + ds + ".schema"));
                   dataSources.put(ds, genDataSource);
         public static Connection getConnection(String dataSource) throws SQLException
              GenDataSource ds = (GenDataSource) me.dataSources.get(dataSource);
              if (me.timeOut <= 0)
                   if (ds.getSchema() != null )
                        return updateSchema ( ds);
                   else
                        return DriverManager.getConnection(ds.url(), ds.user(), ds.password());
              String key = dataSource;
              Stack free;
              GenPooledConnection pc = null;
              synchronized (me)
                   if ((free = (Stack) me.cons.get(key)) == null)
                        free = new Stack();
                        me.cons.put(key, free);
                   if (!free.empty())
                        pc = (GenPooledConnection) free.pop();
                   if (pc == null)
                        if (ds.getSchema() != null )
                             pc = new GenPooledConnection("DataSource [" + key + "]",
                                                 updateSchema ( ds), free, me.active, me.timeOut, me.trace);
                        else
                             pc = new GenPooledConnection("DataSource [" + key + "]",
                                       DriverManager.getConnection(ds.url(), ds.user(), ds.password()), free, me.active, me.timeOut, me.trace);
                   else
                        pc.touch();
              LogManager.logStatus("Using " + pc);
              me.active.put(pc.id(), pc);
              return pc;
         public void run()
              for(;;)
                   try
                        sleep(60 * 1000);
                        synchronized (me) {
                             for(Enumeration e = cons.elements(); e.hasMoreElements();)
                                  Stack stack = (Stack) e.nextElement();
                                  for (int i = stack.size()-1; i >= 0; i--)
                                       GenPooledConnection pc = (GenPooledConnection) stack.elementAt(i);
                                       if (pc.isExpired())
                                            stack.removeElementAt(i);
                   catch (Exception e)
                        GenUtil.reportException(e);
         private static Connection updateSchema ( GenDataSource ds) throws SQLException {
              Connection con = DriverManager.getConnection(ds.url(), ds.user(), ds.password());
              if (ds.getSchema() != null ) {
                   String sql = "SET SCHEMA  " + ds.getSchema()+ ";";
                   LogManager.logDebugMessage("updating the Schema with sql statement " + sql);
                   PreparedStatement ps = con.prepareStatement(sql);
                   ps.execute();
                   ps.close();
              return con;
    }Thanks.
    Edited by: EJP on 5/10/2012 14:09: added {noformat}{noformat} tags. Please use them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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

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

  • An error occured while opening the connection: Object reference not set to

    After I uninstalled Oracle Developer Tools for Visual Studio .NET 10.1.0.4 and installed Oracle Developer Tools for Visual Studio .NET with Oracle10g Release 2 ODAC 10.2.0.2.21 I got the error message below when I want to connect to my 10g database using Oracle Explorer.
    Error:
    An error occured while opening the connection: Object reference not set to an instance of an object
    I use OracleConnection to open also cannot be done. But I use Oracle SQL Developer I can connect to orcl that I cannot connect using ODAC 10.2.0.2.21 in my laptop.
    Please help me.
    Ming Man

    Sorry my mistake, I double checked, the one I uninstalled is ODAC 10.2.0.2.20 and not ODAC 10.1.0.4.
    But I have that error.
    Ming Man

  • Connection string size limits

    Hi,
    old client has size limit on connection string size?
    if i create a tnsnames with 3 vip old client generate an error.
    Is there any workaround?

    842366 wrote:
    Hi,
    old client has size limit on connection string size?
    if i create a tnsnames with 3 vip old client generate an error.
    Is there any workaround?upgrade client
    use EZCONNECT; which does not require any tnsnames.ora
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Having the connection object for the specific schema

    hi
    My application interacting with the database of having many no of schema's. I need to create a connection object which is pointing to the specific schema in my database. This is help me to avoid writing schema name in the query every time.
    Thanks
    Siva

    How to specify the schema name in properties file?
    Say for example, i created properties file like that,
    Properties props = new Properties();
    props.setProperty("user", "username");
    props.setProperty("password", "password');
    In which property i can set for schema?

  • Link from IS-U connection object to email from marketing campain

    Hi all,
    I've a problem with emails from marketing campains in WebUI.
    If you send an email from such a campain, it is linked at the contact historie of the receiving BP.
    But we need an additional link from the IS-U connection objects of this BP to this email.
    I implemented the badi CRM_MKT_MODIFY_ORDER to add the link in the docflow segment.
    but now there a two mistakes. from the contact history of the BP the link still starts BT126H_MAIL, but only the part "references" is filled with BP, contact, res.employee and header data of the marketing campain. The email block is empty although the mail was sent correctly. Why am I losing the reference to the the email/smartform?
    the second mistake is even more curious to me. in the contact history of the connection object is a link to the email created. But the link leads to component BT126H_APPT although its category is email.
    Any idea, what's my mistake?
    regards
    Martin
    Edited by: Martin Knittel on Aug 3, 2009 5:11 PM:
    I solved problem no 1. Forgot a partner dataset in the badi.
    But need still your help with problem no 2. Why is there a link to BT126H_APPT instead of BT126H_MAIL?

    Was a mistake in standard coding. Solved by sap note

Maybe you are looking for