How to make common database connection using bean, etc.

anyone know how to make a coomon database connection because on my web pages each of them need to connect on the database for their specific objectives... please help
regards
blingbling
Edited by: BlingBling15 on Oct 22, 2007 1:16 PM

Making a 'common' connection and passing it around is a bad idea. And making a new connection on every page, as you seem to have already guessed, also involves an overhead that you can do without.
Like drvijayj2k2 has mentioned, you should use connection pooling.
Take a look at the Apache Commons DBCP [1] and it's examples [2].
[1] http://commons.apache.org/dbcp/
[2] http://wiki.apache.org/jakarta-commons/DBCP
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
----------------------------------------------------------------

Similar Messages

  • How to make new database connection using Oracle BI Interactive Dashboards

    Hi,
    I install Oracle BI Intelligence on my system.
    I am using Oracle BI Interactive Dashboard. Here we have default database connection.
    but now i want to use it for my own database. Can any body give me guideline how to
    make a new data base connection using this s/w or how to connect to my database so
    that i can make my own reports.
    I am using
    http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/saw/saw.html
    this link.
    i make odbc connection which is fine.
    but
    Restoring the Business Intelligence Presentation Catalog and Updating Metadata
    The third point blow above heading is not clear.
    Thanks

    Umesh - in order to build Answers and Dashboard content you must first setup a Physical model, then a Business model, followed by a Presentation Catalog/Subject Area.
    All these tasks are carried out using the Repository Administration Utility.
    1) Import your physical tables using OCI/ODBC into the physical layer.
    2) Build your model
    3) Deploy
    Then you're ready to start building answers/dashboards.
    Good Luck.

  • How many number of database connections used in a transaction

    Hi All,
    We are using weblogic 8.1 with Oracle 9i both running on windows 2000. We are trying to estimate the potential resource usage in the system we are building. As part of this activity we want to find out how the database connections are used for entity beans -
    If a session bean calls more than one entity beans
    (each method in the entity bean doing one update) does weblogic use the same database connection for all the entity beans or does it use seperate connections ? Is such behaviour documented somewhere ?
    Here the assumption is all the entity beans are linked to the same datasource.
    If the (default) behaviour is to use seperate connections is there a way to make it use one connection across multiple entity beans.
    Thanks
    Kingshuk

    Hi Bodapati,
    Sorry for the delay in replying to this.
    There is optimization, which will use the XA
    connections from the pool. Can you tell me what your
    observations are? I may be able to see if we can tune it.From our tests the XA driver too appear to make use of one connection only for the life of the transaction. There is a good document here explaining how it is ensured that only one connection is used - http://e-docs.bea.com/wls/docs81/oracle/trxjdbcx.html#1083132
    Quoting from the above URL :
    When a thread attempts to use a connection, the XA jDriver calls xa_open (and xa_start) to create the connection and associate it with the thread. After the database connection is created, the connection remains associated with the thread; the driver does not call xa_close. When the thread subsequently needs a database connection, it uses the same database connection associated with it, even though it appears to get and return a connection from the JDBC connection pool
    I am not sure why you say the connections will be
    blocked. One connection will be blocked only if you are > using non-XA driver to setup the pool, until the
    transaction commits. For XA there is no need to reserve
    the same connection for the transaction.Probably my understanding on this is incorrect and I need to read up. I was under the impression that - once a transaction begins, each connection used within that transaction, is enlisted as a part of that transaction and can not be used by in another transaction until the transaction commits or rollsback.
    Thanks
    Kingshuk

  • Database connection using beans

    Hi, I'm very new to JSP. I'm trying to write an application which has a Login page which the user uses to login to a Oracle database (with their own User ID and password). Once the user has successfully logged in I would like to use the same connection to all the other pages the user is traversing until the user logs out. I have come to know that this is possible using beans in JSP or using the connection pool, but I'm not 100% sure how. Can someone please provide me some sample code of the Login page, the beans and a third page which uses the connection. I really appreciate your time and efforts. Thanks a lot in advance for all your efforts and support.
    Cheers
    Balaji

    What you have to learn is how to use session variables after you have successfully logged in your pages. What the next succeeding pages will do is to check if this session variable is not null or valid and then proceed with the display of the pages or redirect it to the login page otherwise. You can implement this sesion variable as a bean to store all the details for a particular user.
    Typically you will use
    Object o = session.getAttribute("yourSessionVariable");
    if (o ==null)
    // go to login page OR
    // create a session variable
    // like session.setAttribute("yourSessionVariable", new Object());
    }else
    //proceed with the display
    Here, o is your bean.
    Hope this helps

  • Jsp and database connection using bean

    * I want create a bean to handle database connectivity.The
              <jsp:usebean> tag uses
              no argument constructor ..so I cannot pass the userid and password to
              the constructor.
              So how can I create a database connection when the user_id and password
              will be a part of parameter ?
              * Now I'm opening database connection in the jsp scriplets. Everytime I
              refresh the
              jsp page a new connection is created ? Is it not going to choke the
              database ? I cannot use connection pool because every user logs in with
              different userid.
              Thanks
              

    You can pass your arguments in this way:
              <jsp:usebean id="myBean" scope="page"/>
              <jsp:setProperty name="myBean" property="userId", value=<%= user_id%>/>
              <jsp:setProperty name="myBean" property="password", value=<%=
              user_password%>/>
              of course, in your bean class, you should create two setter methods,
              setUserId and setPassword.
              Hopefully, this will help you.
              sonia WEN
              Chiranjib Misra wrote:
              > * I want create a bean to handle database connectivity.The
              > <jsp:usebean> tag uses
              > no argument constructor ..so I cannot pass the userid and password to
              > the constructor.
              > So how can I create a database connection when the user_id and password
              > will be a part of parameter ?
              >
              > * Now I'm opening database connection in the jsp scriplets. Everytime I
              > refresh the
              > jsp page a new connection is created ? Is it not going to choke the
              > database ? I cannot use connection pool because every user logs in with
              > different userid.
              >
              > Thanks
              

  • How to create a database connection using Jdeveloper 10g

    when i try to create a database connection,its asking for connection name.is that connection name is user-defined or predefined name??In the next step its asking for username and password.where do i get that username and password.if anyone know this please explain me in detail coz this is for the first time am using JDeveloper.
    Thanks in advance.

    Hi user583040,
    May be you could have a look on this: http://my.opera.com/Tiftif/blog/faq-jdeveloper-english §5.2. If you have suggestions to improve this document, i will greatly appreciate to add them to it.
    Regards,
    Tif

  • How to disconnect the database connection using crystal report

    Post Author: cp_pramodu
    CA Forum: Crystal Reports
    Hi All,
    We have developed an application using .Net and Crystal Reports 10 for generating Adhoc reports from Business system (db sybase 12). We are using the below mentioned script for opening rpt files.
    Try
           ReportDocument1.Load(sReportName)
           For Each table In ReportDocument1.Database.Tables
                  ' Get the TableLogOnInfo object.
                  logonInfo = table.LogOnInfo
                  ' Set the server or ODBC data source name, database name,
                  ' user ID, and password.
                  logonInfo.ConnectionInfo.ServerName = sReportServerName
                  logonInfo.ConnectionInfo.DatabaseName = DBName
                  logonInfo.ConnectionInfo.UserID = UserName
                  logonInfo.ConnectionInfo.Password = Password
                  ' Apply the connection information to the table.
                 table.ApplyLogOnInfo(logonInfo)
    Next
    'Me.Cursor = Cursors.WaitCursor
    Me.CrystalReportViewer1.ReportSource = ReportDocument1
    'Me.Cursor = Cursors.Default
    Catch ex As Exception
    'Response.Write(ex.Message)
    Finally
    Me.Cursor = Cursors.Default
    'ReportDocument1.Close()
    'ReportDocument1.Dispose()
    End Try
    Each time user opens the report a new connection is established to the database, can we disconnect the connection established from crystal reports, while closing crystal report. At the same time i want to setup an Idle time for these connections. In database level, i will not be able to set idle time in database level, as it affect our electronic channels.
    Waiting for a reply.
    Thanks & Regards,
    Pramodu. C. P

    Hi,
    If you are reworking the application can you not build in the functionality to re-establish a connection if there is a failure? That is, a submission from the application server to the database server detects a failure, etc. and then re-establishes the connection. If you need a more frequent check than during a user-initiated roundtrip, you may be best served by using the "dummy query" technique on some time interval.
    From my understanding using HA Event Notification would require a RAC database (plus a multi-threaded application and services correctly configured on the RAC-side).
    In the documentation I see this:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci09adv.htm#sthref1495
    "Applications must connect to a RAC instance to enable HA event notification."
    In any case, this has the potential to be a bit complicated...
    Regards,
    Mark

  • How to check the database connection using OCI

    I am working on enhhancement of very old application developed using C and OCI. It has a background process which acts as a middleware for interaction of any other front end process with oracle database. Any processes, which needs to interact with database sends a request to background peocess and then it will execute a call to execute the stored procedures for performing requested operation (like select, update, insert) on table and will send the result back to respective process. So this process has to be always running in background and connected to branch database.
    If branch database gets restarted or connection gets dropped due to some ad-hoc problem then the background process also has to be restarted manually. Because this process establishes the connection to branch database only once on start up and it does not have the intelligence to reconnect automatically in such scenario.
    I am looking forward to build the intelligence in this process to automatically reconnect if connection with branch database is lost. But I am not familer with OCI, and I am not sure if there is any OCI call which can determine if my earlier connection is still available. Can any one please tell me if there is any other way to check the connection other than the execution of dummy query, then check if it gets executed properly and then do the actual query.
    Thanks in advance,
    Deeapk

    Hi,
    If you are reworking the application can you not build in the functionality to re-establish a connection if there is a failure? That is, a submission from the application server to the database server detects a failure, etc. and then re-establishes the connection. If you need a more frequent check than during a user-initiated roundtrip, you may be best served by using the "dummy query" technique on some time interval.
    From my understanding using HA Event Notification would require a RAC database (plus a multi-threaded application and services correctly configured on the RAC-side).
    In the documentation I see this:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci09adv.htm#sthref1495
    "Applications must connect to a RAC instance to enable HA event notification."
    In any case, this has the potential to be a bit complicated...
    Regards,
    Mark

  • How to create database connection using DB2Driver in JDeveloper 10.1.2.1.0?

    I am trying to create a JDeveloper/Data Connection using com.oracle.ias.jdbc.db2.DB2Driver. The driver is registered from a User Libraries: DataDirect JDBC. I have the following class path for the library:
    E:\DataDirect\3.4\lib\YMdb2.jar;E:\DataDirect\3.4\lib\YMbase.jar;E:\DataDirect\3.4\lib\YMutil.jar
    I have no trouble configuring the connection but when I test it and I got ‘No suitable driver Vendor code 0’. What’s wrong? I have successfully created several database connections using Oracle thin driver. This is first time I am using a third party driver. Has any one successfully create a database connection using the com.oracle.ias.jdbc.db2.DB2Driver?

    Hi
    Since the error points to the unavailability of the driver class,can you double check your library claspath entries again.
    I just tried a DB2 connection using the following properties and the connection went through fine:
    Driver class name: com.oracle.ias.jdbc.db2.DB2Driver
    URL: jdbc:merant:db2://<host_name>:50000;DatabaseName=SAMPLE
    Thanks
    Prasanth

  • Help: How to make JDeveloper to connect to Oracle repository through CMAN?

    Hi folks,
    I have a very dummy problem.
    I have JDeveloper on Linux.
    I have on Oracle SCM Repository in a database, which is across WAN.
    The database is accessible through connection manager.
    BUT HOW DO I EXPLAIN TO JDEVELOPER , that there is a Connection Manager. It only allows me to enter host:port:sid. It doesn't allow me to enter custom JDBC URL.
    This is really missing functionality...
    Please help me,
    Regards,
    Mihail Daskalov

    The support for Oracle SCM in JDeveloper can only connect via thin JDBC. This always requires a host, port and SID. The limitation is due to underlying limitations in the libraries we use to connect to Oracle SCM.
    Is your database connection using OCI? We have an existing enhancement request for OCI support (2700757), but let me know if it's another connection type, and I'll add that to the ER.
    Thanks,
    Brian
    JDev Team

  • How to make SAP B1 connection with Windows Sharepoint Service 3.0

    how to make SAP B1 connection with Windows Sharepoint Service 3.0 through asp.net web part code.. I get the security error when i run that web part......
    public bool ConnectToCompany()
                oCompany = new SAPbobsCOM.Company();
                oCompany.Server = "192.168.1.58";
                oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;
                oCompany.CompanyDB = "SBODemoUS";
                oCompany.DbUserName = "sa";
                oCompany.DbPassword = "abc";
                //oCompany.UseTrusted = true;
                oCompany.UserName = "manager";
                oCompany.Password = "manager";
                oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English;
                oCompany.LicenseServer = "192.168.1.58:30000";
                int i = oCompany.Connect();
                if (i != 0)
                    return false;
                return true;
    protected override void RenderContents(HtmlTextWriter writer)
                if (conn.ConnectToCompany() == true)
                    writer.Write("Hello" + this.Context.User.Identity.Name);
    Edited by: bikalg on Nov 28, 2010 9:43 AM

    Hi.......
    Welcome to SAP Business One Forum.....
    Unfortunately this is the wrong forum you posted here.
    I would suggest you post it in SDK or System Administration Forum and definitely you get the solution and close this thread from here......
    Regards,
    Rahul

  • In ecatt - how to check at database level using ABAP

    Hi,
    How to check at database level using ABAP in Ecatt tool.
    say,for example I want to check a particular sales order is invoiced or not ,at the database level and if it is invoiced I have stop proceeding to invoicing of that sales order number.
    Could anybody suggest on this with an example?
    thanks.

    Hi,
    you can use the command GETTAB to access single db records.
    Full specified or partitial specified keys can be use at GETTAB. It will return always only one record, also if a couple could match your selection.
    For more advanced scenarios you can also use eCATTs Inline ABAP. In a block between the commands ABAP. ENDABAP. you can code ABAP statements, e.g. SELECT ... INTO TABLE ...
    eCATT script parameters of type 'V' defined in that script using ABAP/ENDABAP will be transfered into the ABAP block and back to script after ABAP perform.
    Best regards
    Jens

  • Why can I not make a secure connection using safari?

    why can I not make a secure connection using safari?

    I have the exact same problem.  I just updated to 4.3.3 and now my inline controls on my earphones don't work.  The earphones work, but the controls don't.  It doesn't even recognize that there is a mic attached.  Even with the earphones in it still uses the built in mic. Why did my controls stop working?!

  • How to create standby database by using duplicate

    Dear all,
    How to create standby database by using duplicate,is there some doc to read?

    Hi;
    You can use
    Step-By-Step Guide To Create Physical Standby On Normal File System For ASM Primary using RMAN [ID 838828.1]
    Creating Physical Standby using RMAN Duplicate Without Shutting down The Primary [ID 789370.1]
    Also use goole, there are many blog-site-dogs mention that topic. From googling:
    Creating a Standby Database with Recovery Manager
    http://docs.oracle.com/cd/B19306_01/backup.102/b14191/rcmdupdb.htm
    http://www.pythian.com/news/248/recipes-for-creating-a-managed-standby-with-rman/
    http://docs.oracle.com/cd/B19306_01/server.102/b14239/rcmbackp.htm
    Regard
    Helios

  • How to make different users to use different Plan_Tables?

    How to make different users to use different Plan_Tables?
    I want each user use his own's Plan_Table. How to achieve this goal?

    qkc wrote:
    How to make different users to use different Plan_Tables?
    I want each user use his own's Plan_Table. How to achieve this goal?Which version of Oracle - if you're on 10g or later you are already (effectively) doing this.
    If not, then copy the 10g strategy back to your version; in outline:
    <ul>
    drop all existing plan tables
    create a table (but call it plan_table$) in the SYS schema (you may prefer to use SYSTEM) as a global temporary table on commit preserve rows
    create a public synonym plan_table for plan_table$
    grant select insert update delete on plan_table to public
    </ul>
    Look in $ORACLE_HOME/rdbms/admin/catplan.sql in a 10g version of Oracle to check how it's done.
    Each user gets a private (temporary) table in their temporary tablespace whenever they use the plan_table
    Their private data disappears when there session ends.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Error while applying patchset 11.1.0.7 to 11.1.0.6

    Hi, I am a new DBA and would appreciate any help on this. I am in the process of upgrading my database from 10.2.0.4 to 11.1.0.7. I installed 11.1.0.6 and was applying the 11.1.0.7 patch. I installed the 11g patchset successfully and was working on '

  • Canon GL2 and Final Cut Pro X

    Relatively new to the Final Cut Pro X thing, so I may be missing something stupid, but here goes... I am trying to import from a GL2.  I go to camera import and gain camera control...  I then start importing. Problems start when it plays, it creates

  • CARO_ROUTING_READ

    Hello,   I am trying to use CARO_ROUTING_READ FM to get the routing details related to PLNNR number. I am providing the following input as datuv : 01.01.2010 PLNNR :50093636 PLNTY: N PLNAL : 1 When i call the FM using my sample report it is giving sy

  • Non hp cartridge ERROR

    ERROR MESSAGE = NON HP CARTRIDGE PRINTER WILL NOT PRINT

  • Why cant i do simple things like add to an array list :( :( :(

    i dont know why i cant do this :( late in the day maybe? ArrayList menu; MenuItem ma=new MenuItem("Test","na",0,true); addMenuItem(ma); private void addMenuItem(MenuItem obj)     menu.add(obj);     Collections.sort(menu);     }im getting a nullpointe