Connection/Connection Pooling - Best Practices

Hi everyone,
I'm doing my first JDBC application, and I have some questions about the right way to do things. We've got a series of business objects with lots of database abstraction and everything, and the situation comes up where we're making a lot of calls to the database to populate our objects. The high number of calls occur because of the level of abstraction we need, so when we get a Person object, we don't do a join on the address table and the phone table, but instead make seperate calls to those tables. Aside from the fact that this may not be the best way to do things, what is the best way to manage the connections? It's pretty costly time-wise to create a bunch of new connections, so I was just using one connection and passing it through our database call objects, so I'd created a connection to the DB, get my Person information, pass that connection on to read from the Address table, then again to Phone table. I know this can't be good, but it's a lot faster than creating a new connection every time. Also, I don't know how reusing the connection for different things is screwing up the cursor, or causing the application to hang until the connection is free again.
I've read some stuff about connection pooling with JDBC 2.0, but the need for the JINI calls is confusing to me.
Can someone take a few minutes to describe the right way to get this to work with Java? I'm using the MSSQL JDBC driver availiable on Microsoft's site, but I didn't notice which version of JDBC it supports. It's Type 4 driver, but I don't know what that means either.
Thanks in advance,
Jim

They're not JINI calls, they're JNDI calls - Java Naming and Directory Interface. They're just doing a lookup to get the data source from the connection pool.
When you see it done that way, it's usually a container like Tomcat or WebLogic that's handling the connection pool for you. Are you using either of those, or were you going to try to write your own pooling mechanism?
Type 4 driver means it's 100% pure Java, no native code. You can read all the different types at:
http://java.sun.com/products/jdbc/driverdesc.html
There's another driver at SourceForge jTDS for M$ SQL Server that's pretty good. I've used it with some success, switching away from the M$ implementation:
http://jtds.sourceforge.net/
Good luck. - MOD

Similar Messages

  • Handling of connection closures, best practice

    Hello,
    I have the following situation (within some old code):
    Quite a lot of different values are stores in a ldap server and are fetched often from a long-running program. There are many child-contexts from the initialcontext. The two possiblities I see are:
    a) have one connection which handles all. Problem: When the connection is closed (by a ldap server restart or whatever) i have to reinitialise the initialcontext and all child contexts.
    b) i use connection pooling and use a new(pooled) connection for each query.
    Are the above assumtions correct? What would be the best practice to do this? Can Connection Request Controls help me with this?
    I'm quite new to the advanced things of JNDI and thank you in advance for your answers.
    cheers,
    Michael

    Yes, java.sql.SQLException is designed for that. It has two methods, getSQLState and getErrorCode, that will help you get the state of the RDBMS if something goes wrong. - MOD

  • Error while Connecting report Best Practices v1.31 with SAP

    Hello experts,
    I'm facing an issue while trying to connect some of my reports from Best Practices for BI with SAP.
    It only happens when it's about info sets, the other ones that are with SAP tables go smoothly without a problem.
    The most interesting is I have already one of the reports connected to SAP info sets.
    I have already verified the document of steps of creation of additional database that comes with BP pack. They seem ok.
    Here goes what Crystal Reports throws to me after changing the data source to SAP:
    For report "GL Statement" one of the Financial Analysis one which uses InfoSet: /KYK/IS_FIGL_I3:
    - Failed to retrieve data from the database; - click ok then...
    - Database connector error: It wasn't indicated any variant for exercise (something like this after translating) - click ok then
    - Database connector error: RFC_INVALID_HANDLE
    For report "Cost Analysis: Planned vs. Actual Order Costs" one of the Financial Analysis one which uses InfoSet: ZBPBI131_INFO_ODVR and ZBPBI131_INFO_COAS; and also the Query CO_OM_OP_20_Q1:
    - Failed to retrieve data from the database; - click ok then...
    - Database connector error: check class for selections raised errors - click ok then
    - Database connector error: RFC_INVALID_HANDLE
    Obs.: Those "Z" infosets are already created in SAP environment.
    The one that works fine is one of the Purchasing Analysis reports:
    - Purchasing Group Analysis -> InfoSet: /KYK/IS_MCE1
    I'm kind of lost to solve this, because I'm not sure if it can be in the SAP JCO or some parameter that was done wrongly in SAP and I have already check possible solutions for both.
    Thanks in advance,
    Carlos Henrique Matos da Silva - SAP BusinessObjects BI - Brazil.

    I re-checked step 3.2.3 - Uploading Crystal User Roles (transaction PFCG) - of the manual where it talks about CRYSTAL_ENTITLEMENT and CRYSTAL_DESIGNER roles, I noticed in the Authorizations tab that the status was saying it hadn't been generated and I had a yellow sign, so then that was what I did (I generated) as it says in the manual.
    Both statuses are now saying "Authorization profile is generated" and the sign is now green on the tab.
    I had another issue in the User tab (it was yellow as Authorizations one before generating)....all I needed to do to change to green was comparing user (User Comparison button).
    After all that, I tried once more to refresh the Crystal report and I still have the error messages being thrown.
    There's one more issue in one of the tabs of PFCG transaction, it is on the Menu one where it is with a red sign, but there's nothing talking about it in the manual. I just have a folder called "Role menu" without anything in it.
    Can it be the reason why I'm facing errors when connecting the report to SAP infoSets? (remember one of my reports which is connected to an infoSet works good)
    Thanks in advance,
    Carlos Henrique Matos da Silva - SAP BusinessObjects BI - Brazil.

  • BI7.0 Connectivity -SAP Best Practice

    Hello,
    I need SAP Best Practices documentation on  how to connect(RFC)  ECC 6.0 and BI 7.0 blog or whitepaper.
    I have old version BW 3.5 and R/3 document RFC connect.
    Thanks

    Hi,
    Check these.
    Connection between Source Systems and BW
    http://help.sap.com/saphelp_nw70/helpdata/en/00/dc54384ac9a81be10000009b38f8cf/frameset.htm
    Creating SAP Source Systems
    http://help.sap.com/saphelp_nw70/helpdata/en/ac/4a4e38493e4774e10000009b38f889/frameset.htm
    BW connectivity(.doc)
    http://help.sap.com/bp_biv335/BI_EN/BBLibrary/documentation/B84_BB_ConfigGuide_EN_DE.doc
    Regards.

  • Pool : best practice ODI : PLSQL or Interface object ?

    Hello,
    My ODI consultant has developped an interface to load a flat file into Hyperion Planning :
    * first step : load flat file into staging : done with "Interface" object
    * second step : transform staging table (1,2,3 ==> JAN, FEB, MAR // transform "-" into ND_Customer ... very easy transformation !) : done trough a PLSQL Procedure. Result is load into FACT_TABLE
    * third step : load FACT_TABLE into ESSBASE : done with "interface" object
    During design, we didn't discuss the technology, but after the build, I'm very suprised by the second step. There is no justification to do it with PLSQL. My consultant explains me : "I'd rather to use PLSQL". But from my point of view, ODI best practice is to use "Interface" (more flexible, you can change the topology without impact in interface etc ...)
    What is your point of view? Should I raise an issue and expect from my consultant a rewriting with "interface" object?
    Rgds

    Thx SH, the complexity (use of two intermediate tables : STAGING and FACT) is due to our requirment to archive the original data during one year (in STAGING) and to give an audit trail from Essbase to original data (before transformation). From Essbase we could go back to FACT Table (same member name) then goes back to STAGING by using and unique ID that produces a link between tables.
    From my point of view ODI Interface is the simplier way to maintain the "mapping", instead of PLSQL, but I would have more feedbacks from other developper to be sure of my feeling (I've done only 2 Hyperion Planning + ODI Project before the current one).
    The complexity of interface are low or medium : simple filter on one or two dimensions / DECODE mapping on Month / group by on similar records / for few interfaces, more complexe rules with IF statement.
    Thx in adavance

  • How to connect AS400 (best practice)

    Hi folks,
    I'm trying to connect to an AS400 server and need expert advise to do so.
    I'm planning to use a JDBC driver to connect to the DB2400 database (for write/read into specific tables).
    What is the best way to reset AS400 user/password ? Use JDBC connectio and write into correct table or use Windows programs as RMTCMD to connect to AS400 and then launch AS400 command line ?
    Does any of you have try these kind of solution ?
    Thanks for your help,
    Ben

    Ben,
    That's an interesting question.  I think there are a couple of approaches to this:
    1. Check with SAP to see if they have an "official" connector.  I know there was a slide deck out there a couple of years ago with some "approved" connectors.  There might be one there.  Slim chance, but why re-invent the wheel?
    2. More likely you'll need to create your own.  You're on the right path with the JDBC connector, but I'm not sure if you'll be able to set passwords.  It'll depend on the system and level of access you have.  You should also look to see if there's an LDAP interface to the system.  Might not be helpful for database applications, but would be good for general system (OS) access.
    Good luck!
    Matt

  • Best practice for RAC connections

    Got a question of what people consider best practice for setting up high-availability connection pools to a RAC cluster. Now that you can specify the fail-over logic right in the thin connection string it seems like there are three options.
    A) Use OCI connections and allow the fail-over logic to be maintained in the TNSNAMES.ORA file.
    B) Use simple thin connections with multi-pools and let WebLogic maintain the fail-over logic.
    C) Use simple thin connections with fail-over logic in the connection string.
    Thanks,
    Rodger...

    If you need XA, then follow the WebLogic documentation. If not, then
    you have much more freedom. The thin driver can be configured to
    use the tnsnames.ora file if that helps you. WebLogic much prefers the
    thin driver to the OCI-based one, which can kill a JVM with OCI bugs.
    If you do driver-level failover, each failed connection will cost a test
    and replace. If you use multipools, WLS can be configured to flush a
    whole pool when it finds a connection bad, and also make the failover
    at the pool level, right then, so application delay is minimized.
    Joe

  • What is the best Practice JCO Connection Settings for DC  Project

    When multiple users are using the system data is missing from Web Dynpro Screens.  This seems to be due to running out of connections to pull data.
    I have a WebDynpro Project based on component development using DC's.  I have one main DC which uses other DC's as Lookup Windows.  All DC's have their Own Apps.  Also inside the main DC screen, the data is populated from multiple function modules.
    There are about 7 lookup DC Apps accessed by the user
    I have created JCO destinations with following settigns
    Max Pool Size 20
    Max Number of Connections 200
    Before I moved to DC project it was regular Web Dynpro Project with one Application and all lookup windows were inside the same Project.  I never had the issue with the same settings.
    Now may be becuase of DC usage and increase in applications I am running out of connections.
    Has any one faced the problem.  Can anyone suggest the best practice of how to size JCO connections.
    It does not make any sense that just with 15-20 concurrent users I am seeing this issue.
    All lookup components are destroyed after its use and is created manually as needed.  What else can I do to manage connections
    Any advise is greatly appreciated.
    Thanks

    Hi Ravi,
    Try to go through this Blog its very helpful.
    [Web Dynpro Best Practices: How to Configure the JCo Destination Settings|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417600)ID2054522350DB01207252403570931395End?blog=/pub/wlg/1216]
    Hope It will help.
    Regards
    Jeetendra

  • BEST PRACTICES FOR CREATING DISCOVERER DATABASE CONNECTION -PUBLIC VS. PRIV

    I have enabled SSO for Discoverer. So when you browse to http://host:port/discoverer/viewer you get prompted for your SSO
    username/password. I have enabled users to create their own private
    connections. I log in as portal and created a private connection. I then from
    Oracle Portal create a portlet and add a discoverer worksheet using the private
    connection that I created as the portal user. This works fine...users access
    the portal they can see the worksheet. When they click the analyze link, the
    users are prompted to enter a password for the private connection. The
    following message is displayed:
    The item you are requesting requires you to enter a password. This could occur because this is a private connection or
    because the public connection password was invalid. Please enter the correct
    password now to continue.
    I originally created a public connection...and then follow the same steps from Oracle portal to create the portlet and display the
    worksheet. Worksheet is displayed properly from Portal, when users click the
    analyze link they are taken to Discoverer Viewer without having to enter a
    password. The problem with this is that when a user browses to
    http://host:port/discoverer/viewer they enter their SSO information and then
    any user with an SSO account can see the public connection...very insecure!
    When private connections are used, no connection information is displayed to
    SSO users when logging into Discoverer Viewer.
    For the very first step, when editing the Worksheet portlet from Portal, I enter the following for Database
    Connections:
    Publisher: I choose either the private or public connection that I created
    Users Logged In: Display same data to all users using connection (Publisher's Connection)
    Users Not Logged In: Do no display data
    My question is what are the best practices for creating Discoverer Database
    Connections.
    Is there a way to create a public connection, but not display it in at http://host:port/discoverer/viewer?
    Can I restrict access to http://host:port/discoverer/viewer to specific SSO users?
    So overall, I want roughly 40 users to have access to my Portal Page Group. I then want to
    display portlets with Discoverer worksheets. Certain worksheets I want to have
    the ability to display the analyze link. When the SSO user clicks on this they
    will be taken to Discoverer Viewer and prompted for no logon information. All
    SSO users will see the same data...there is no need to restrict access based on
    SSO username...1 database user will be set up in either the public or private
    connection.

    You can make it happen by creating a private connection for 40 users by capi script and when creating portlet select 2nd option in Users Logged in section. In this the portlet uses there own private connection every time user logs in.
    So that it won't ask for password.
    Another thing is there is an option of entering password or not in ASC in discoverer section, if your version 10.1.2.2. Let me know if you need more information
    thnaks
    kiran

  • What are the best practices to connect 30-40 iPads to Wi-Fi in a single room?

    What are the best practices to connect 30-40 iPads to Wi-Fi in a single room?

    I don't use it but it does say this in the help section...

  • [XI 3.1] BEST PRACTICE method of Oracle connection for RPTs on Linux

    Business Objects XI (3.1) - SP3.
    Running on Red Hat Enterprise Linux OS.
    7,000+ Crystal Reports 2008 *.rpt objects ONLY (No Universe / No WebI).
    All reports connecting to Oracle 10g databases.
    ==================
    In the past, all of this infrastructure was running on Windows Server OS and providing the database access via a Named ODBC connection (eg. "APP_DATA".)
    This made it easy to manage as all the Report Developers had a standard System DSN called "APP_DATA" which was the same as the System DSN name on all of our DEV, TEST/UAT, and PROD servers for Business Objects.
    When we wanted to move/promote a *.rpt file from DEV to PROD we did not have to change any "Database Connection" info as it was all taken care of by pointing the System DSN called "APP_DATA" a a different physical Oracle server at the ODBC level.
    Now, that hardware is moving from Windows OS to Red Hat Linux and we are trying to determine the Best Practices (and Pros/Cons) of using one of the three methods below to access the Oracle database for our *.rpts....
    1.) Oracle Native connection
    2.) ODBC connection
    3.) JDBC connection
    Here's what we have determined so far -
    1a.) Oracle Native connection should be the most efficient method of passing SQL-query to the DB with the fewest issues and best speed [PRO]
    1b.) Oracle Native connection may not be supported on Linux - http://www.forumtopics.com/busobj/viewtopic.php?t=118770&view=previous&sid=9cca754b468fc67888ab2553c0fbe448 [CON]
    1c.) Using Oracle Native would require special-handling on the *.rpts at either the source-file or the CMC level to change them from DEV -> TEST -> PROD connection. This would result in a lot more Developer / Admin overhead than they are currently used to. [CON]
    2a.) A 3rd-Party Linux ODBC option may be available from EasySoft - http://www.easysoft.com/products/data_access/odbc_oracle_driver/index.html - which would allow us to use a similar Developer / Admin overhead to what we are used to. [PRO]
    2b.) Adding a 3rd-Party Vendor into the mix may lead to support issues is we have problems with results or speeds of our queries. [CON]
    3a.) JDBC appears to be the "defacto standard" when running Oracle SQL queries from Linux. [PRO]
    3b.) There may be issues with results or speeds of our queries when using JDBC. [CON]
    3c.) Using JDBC requires the explicit-IP of the Oracle server to be defined for each connection. This would require special-handling on the *.rpts at either the source-file (and NOT the CMC level) to change them from DEV -> TEST -> PROD connection. This would result in a lot more Developer / Admin overhead than they are currently used to. [CON]
    ==================
    We would appreciate some advice from anyone who has been down this road before.
    What were your Best Practices?
    What can you add to the Pros and Cons listed above?
    How do we find the "sweet spot" between quality/performance/speed of reports and easy-overhead for the Admins and Developers?
    As always, thanks in advance for your comments.

    Hi,
    I just saw this article and I would like to add some infos.
    First you can quite easely reproduce the same way of working with the odbc entries by playing with the oracle name resolution on the server. By changing some files (sqlnet, tnsnames.ora,..) you can define a different oracle server for a specific name that will be the same accross all environments.
    Database name will be resolved differently regarding to the environment and therefore will access a different database.
    Second option is the possibility to change the connection in .rpt files by an automated way like the schedule manager. This tool is a additional web application to deploy that can change the connection settings of rpt reports on thousands of reports in a few clicks. you can find it here :
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80af7965-8bdf-2b10-fa94-bb21833f3db8
    The last option is to do it with a small sdk script, for this purpose, a few lines of codes can change all the reports in a row.
    After some implementations on linux to oracle database I would prefer also the native connection. ODBC and JDBC are deprecated ways to connect to database. You can use DATADIRECT connectors that are quite good but for volumes you will see the difference.

  • External connectivity best practice

    Hi,
    I would like to know what are the best practices to have external users using Excel to connect to SSAS cube. I understand the general concept that a cube user must be in a domain AD andthat same user is a member of a SSAS cube.
    How can I ensure the excel connection is secure and each external user is only able to view their own data? I know the workbook can be password protected but can the connection be also password protected ?
    BTW, I am not sure if this is the right forum for this question
    Regards

    Most modern external drives will typically go into a standby mode shortly after they're unmounted or disconnected which will spin down the drive. They'll still use some power, but your drive won't be doing anything so you don't need to worry about wearing it out. I'm a bit anal about stuff. I usually go so far as to unplug my external drives when I'm not using them as the power supply still consumes some juice... but, in your case, as it seems like you probably go back and forth quite a bit... just powering it down would be the best thing. It really doesn't take any extra effort when connecting your MacBook Pro to just switch it back on again.

  • Best Practice - WAP connecting switchport configuration.

    Is there a best practice for deploying the WAP's in a WAP/WLC infrastructure?  Should the connecting switchport be an Access port or a Trunk port?  I've seen this implemented in both fashions and wasn't sure if one was a better choice than the order.  What is the difference?
    My other question is regarding applying additional switchport configurations.  Is there anything wrong with applying either spanning-tree portfast, spanning-tree bpdguard, or switchport port-security. 

    Hi Ken,
    Access port all the time, everywhere, UNLESS the AP is configured for HREAP/FLEX then trunk. Or if you deploy a AP in monitor mode then TRUNK.
    QOS -- if its access port trust dscp. If you truck trust cos.
    No you are fine. Portfast is highly recommended.
    "Satisfaction does not come from knowing the solution, it comes from knowing why." - Rosalind Franklin
    ‎"I'm in a serious relationship with my Wi-Fi. You could say we have a connection."

  • Best Practices for Connecting to WebHelp via an application?

    Greetings,
    My first post on these forums, so I appologize if this has already been covered (I've done some limited searching w/o success).  I'm developing a .Net application which is accessing my orginazation's RoboHelp-generated webhelp.  My organization's RoboHelp documentation team is still new with the software and so it's been up to me to chart the course for establishing the workflow for connecting to the help from the application.  I've read up on Peter Grange's 'calling webhelp' section off his blog, but I'm still a bit unclear about what might be the best practices approach for connecting to webhelp.
    To date, my org. has been delayed in letting me know their TopicIDs or MapIDs for their various documented topics.  However, I have been able to acquire the relative paths to those topics (I achieved this by manually browsing their online help and extracting out the paths).  And I've been able to use the strategy of creating the link via constructing a URL (following the strategy of using the following syntax: "<root URL>?#<relative URI path>" alternating with "<root URL>??#<relative URI path>").  It strikes me, however, that this approach is somewhat of a hack - since RoboHelp provides other approaches to linking to their documentation via TopicID and MapID.
    What is the recommended/best-practices approach here?  Are they all equally valid or are there pitfalls I'm missing.  I'm inclined to use the URI methodology that I've established above since it works for my needs so far, but I'm worried that I'm not seeing the forest for the trees...
    Regards,
    Brett
    contractor to the USGS
    Lakewood, CO
    PS: we're using RoboHelp 9.0

    I've been giving this some thought over the weekend and this is the best answer I've come up with from a developer's perspective:
    (1) Connecting via URL is convenient if (#1) you have an established naming convention that works for everyone (as Peter mentioned in his reply above)
    (2) Connecting via URL has the disadvantage that changes to the file names and/or folder structure by the author will break connectivity
    (3) Connecting via TopicID/MapID has the advantage that if there is no naming convention or if it's fluid or under construction, the author can maintain that ID after making changes to his/her file or folder structure and still maintain the application connectivity.  Another approach to solving this problem if you're working with URLs would be to set up a web service that would match file addresses to some identifier utilized by the developer (basically a TopicID/MapID coming from the other direction).
    (4) Connecting via TopicID has an aesthetic appeal in the code since it's easy to provide a more english-readable identifier.  As a .Net developer, I find it easy and convenient to construct an enum that matches my TopicIDs and to utilize that enum to construct my identifier when it comes time to make the documentation call.
    (5) Connecting via URL is more convenient for the author, since he/she doesn't have to worry about maintaining IDs
    (6) Connecting via TopicIDs/MapIDs forces the author to maintain those IDs and allows the documentation to be more easily used into the future by other applications worked by developers who might have their own preference in one direction or another as to how they make their connection.
    Hope that helps for posterity.  I'd be interested if anyone else had thoughts to add.
    -Brett

  • Best use of connection pool

    hi all,
    i have some confusion if someone have good suggetions for me.
    i make an connection pool class, and in that package and subpackages i have different class files which do interact with DB thus in whole class files i want to use that same connection pool.
    would any one tell me which will be best method to do it.
    or i have to pass the connection pool to every class object.
    Thanks

    InitialContext initialContext = new InitialContext();
    DataSource dataSource = (DataSource)initialContext.lookup("connPool");
    Connection connection = dataSource.getConnection();You need to do a JNDI lookup for the DataSource and getConnection() from that.
    ***Annie***

Maybe you are looking for

  • Is there a way to use Internal Mac Speakers with something stuck in the headphone jack?

    A while ago, I broke a pair of headphones in the jack of my Macbook Pro. This means I can't use the external speakers either, and it's very annoying. It's now been a year, and I have been getting by with a combination of using Wifi2Hifi, a USB audio

  • HP LaserJet Pro 200 M251n Color Printer driver for Window NT

    Hi All,  Good day. I'm here to seek for help.  Currently i bought a HP LaserJet Pro 200 M251n Color Printer, but i want it to use at Window NT.  I need driver to run this printer at Window NT. Anyone can help and advice me? Thanks. 

  • How do I change the width for masthead/footer?

    Here's my URL: http://lave0134.site44.com/dsn1568/Portfolio%20Website/index.html I want the masthead & footer to be full width of my website page.

  • Servlet with a database QueryString

    Does anybody knows howto make a servlet that can connect to database and return the PDF to the browser ? I have some session variables that has to be part of the querystring and be hidden ! Thanks anyone !

  • Captivate 7 close button

    Can someone talk me through how i can create a close button within Captivate 7 that works? The built in Exit call functions correctly when i preview within Captivate but not when i publish. Many thanks.