Can i use single database connection in a hole java application?

can i use single database connection in a hole java application?.I have so many forms to use database connection.

Theoretically you can. Not only theoretically. I've seen lots of application which only uses one database connection (they were using, oracle or mysql)
The first reply given here assumed that the answer to
your question depends only on the design of your
application. That is not true.Yes it's true. Nothing in the original questions says that you aren't allowed to open or close the single connection that you have. It's looks more like the OP is interested in sharing a connection (i.e having a singleton or a connection pool with only one connection)
It does also depend on the behaviour of the database
in the background.
Most databases have a time out for connections that
are idle Not a problem. Most implementations of connection pools and applications which keeps a connection open have a timer which calls e.g. select * from dual (if you are using oracle) when the connection has been idle for X minutes.
(some, like db2 on z/OS, even cancel
connections, that are not idle, if they are open a
certain amount of time or have reached a given limit
of cpu seconds.)You would also have that problem if you had a connection pool with several connections.
In essence: If you have no control over the time
your application runs (and therefore your connection
is open) or over type or the configuration of the
database you are accessing, you can't do it.See above.
The closest thing to what you want would be using
PooledConnections, iif those are supported for the
database you want to access.Not true.
Kaj

Similar Messages

  • How can I use the database default time rather than Java supplied time

    I've searched over and over and nobody seems to have this issue so maybe its just me!
    When inserting a record I would like the a create_date column to automatically use the database time rather than a supplied time via JPA. That was all times a relative to the database which makes sense.
    The trouble is I cant figure out how to do this in a sensible manor.
    If I specify an column like :
         @Temporal(TemporalType.TIMESTAMP)
         @Column(name = "CREATE_DATE")
         private Date createDate;
    and IDL
    CREATE_DATE TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_DATE NOT NULL
    If I leave createDate null I get an exception. If modify the column to allow Nullable then column is set as Null.
    If I leave the column out of the entity bean and then and create a row then the database current time is inserted. The trouble then is that if I want to read the date I'm going to have to create a copy of the bean but with the CREATE_DATE in it, and this doesn't make sense.

    I should also mention that TopLink has always supported the ability to retrieve the current time from the database for use in optimistic locking. The TimestampLockingPolicy offers the ability to configure the next value being retrieved from the database instead of using the local time from the JVM. Our extended optimistic locking configuration does not currently support setting this option but it could be done using a descriptor customizer which can be configured in your persistence unit properties.
    Using optimistic locking may be a good solution for the last modified date since it will also ensure that you do not corrupt the database if someone else has incremented this value since your last read.
    Doug

  • How to store jpeg images in SQL server using NI database Connectivity Toolset. Can anyone please help me in this regard.

    Please tell how to store jpeg images in SQL Server using NI Database Connectivity Toolset.

    http://www.w3schools.com/sql/sql_datatypes.asp
    You setup a field as BLOB and store the binary of the picture there. Depending on the database it can be called differently as you can see in the link, in SQL server there's even a Image datatype.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • How to host one application using different database connection on OAS?

    Hi,
    Jdeveloper - 10.1.3.4
    Application - ADF/BC
    Oracle Application Server - 10.1.3
    Above our the specifications for our application,
    We have two database schemas different for development and production therfore we have different databse connections for the two,
    we have one application which is in production and enhacements on the same application are done by the development team.
    Since we have two different schemas for developement and prduction we use different database connections for the application on development and production.
    The problem is our Model and View Controller project are same, only the database connection file changes that's why we are able to host only on application at a time on our OAS. This is probably because the URL generated by OAS for developemnt and prodyction application is same.
    Is there a way we can host two instances of the same application with two different database connections on the a single OAS.
    Thanks & Regards,
    Raksha

    Use different deployment profiles each with a different context root for your application?
    See: http://one-size-doesnt-fit-all.blogspot.com/2009/02/configuring-separate-dev-test-prod-urls.html

  • How can I use two database in Dataset in SSRS?

    Hi,
    I am using one query to generate my SSRS report. In that query I am using subquery. Now I am pulling data from multiple tales.
    DB used in sub query is different than the rest of the tables DB.(So total I am using 2 DB(Database))
    So I see that in SSRS, I can connect query(In DataSet Properties) to one DATA_SOURCE only, how can I use other database which is I used in sub-query?
    I have to move this SSRS into PROD and I can't hard code that sub-query's DB name in my query.
    Please give me suggestion. Thanks!!
    Vicky

    In SSRS 2008 R2 you can use the Lookup function (http://technet.microsoft.com/en-us/library/ee210531.aspx ) and LookupSet function (http://technet.microsoft.com/en-us/library/ee240819.aspx
    Depending on your security set up, you can reference a table in a second database on the same server using a three part name:  database.schema.table.  This is more likely to work for you if you wrap your SQL command in a stored procedure.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Need to connect to upgraded Oracle EBS R12 version from R11. The current ODI set up is pointing to R11, Can i use the same connection to point to R12? Please hele experts..

    Need to connect to upgraded Oracle EBS R12 version from R11. The current ODI set up is pointing to R11, Can i use the same connection to point to R12? Please hele experts...
    Rp

    1. in physical connections part can i use the same work schema
    2. Can i use same contexts created or do i need to create everything as new and then try?
    Thanks,
    Rp.
    Hi,
    As you mentioned that you just upgraded the database, so the data is same and schema is same you can connect with the same work schema.
    Yes, you can use the same contexts , but need to do Reverse Engineering for your new database.
    And about data server, i think you also have no need to create new data server, if hostname,sid and port etc are same as these were with R11(consult with your DBAs regarding it)

  • When using the Database Connectivity Toolset, reads and writes with long binary fields are incompatible.

    I am trying to write LabVIEW Variants to long binary fields in a .mdb file using the Database Connectivity Toolset. I get errors when trying to convert the field back to a variant after reading it back from the database.
    I next tried flattening the variant before writing it and ultimately wound up doing the following experiments:
    1) If I use DB Tools Insert Data to write an ordinary string and read it back using a DB Tools Select Data, the string is converted from ASCII to Unicode.
    2) If I use DB Tools Create Parameterized Query to do an INSERT INTO or an UPDATE operation, specifying that the data is BINARY, then read it back using a DB Tools Select Data,
    the length of the string is prepended to the string itself as a big-endian four-byte integer.
    I can't think of any way to do a parameterized read, although the mechanism exists to return data via parameters.
    Presuming that this same problem affects Variants when they are written to the database and read back, I could see why I get an error. At least with flattened strings I have the option of discarding the length bytes from the beginning of the string.
    Am I missing something here?

    David,
    You've missed the point. When a data item is flattened to a string, the first four bytes of the string are expected to be the total length of the string in big-endian binary format. What is happening here is that preceding this four-byte length code is another copy of the same four bytes. If an ordinary string, "abcdefg" is used in place of the flattened data item, it will come back as <00><00><00><07>abcdefg. Here I've used to represent a byte in hexadecimal notation. This problem has nothing to do with flattening and unflattening data items. It has only to do with the data channel consisting of writing to and reading from the database.
    I am attaching three files that you can use to demonstrate the problem. The VI file c
    ontains an explanation of the problem and instructions for installing and operating the demonstration.
    Ron Martin
    Attachments:
    TestLongBinaryFields.vi ‏132 KB
    Sample.UDL ‏1 KB
    Sample.mdb ‏120 KB

  • How can i use Unix database in java?

    How can i use Unix database in Java?
    Message was edited by:
    JPro

    I have not a clue about FoxPro, but the db then is FoxPro and not Unix. The better question would be "How do I connect to FoxPro DB running on Unix with JDBC?".
    My answer to that would be, search the Internet for a JDBC driver.

  • How TO use configurable Database connection with ADF BC

    I have developed a simple JSF/ ADF BC web application that connects to a database and read/display data from the db tables. I have successfully deployed the application to Tomcat 5.5.17. However, now i need to change the database the application is connecting to. My question is How can I change the Database connection without having to change the application modules or rebuild the war file ??? In other words, is there a specific file (xml) where the database connection can be changed?

    If you set up the application with a data source (I am not sure if this is possible using another app server, I use OC4J), then you would just change it there. However if you created a database connection in the JDEV and pointed your data model to that, then you will have to change and rebuild.
    You might be able to edit the xml file that contains the setttings, I am not sure my CM guys dont allow this, all of our changes have to go through our code repository.

  • Can we use oracle database Instead of Cloudspace?

              hi there,Can we use oracle database instead of Cloudspace with the current implementation?
              If possible can you please send me the example
              1.ra.xml
              2.weblogic-ra.xml
              files for connection to oracle. i would really appreciate any support.
              thanx, raghu.
              

              Prasen,
              Could you tell me what specifically should I use for Oracle database instead of
              jdbc:cloudscape:rmi:CloudscapeDB;create=true.
              Can I use jdbc:weblogic:oracle for jdbc:cloudscape:Commerce? I am not familiar with
              Cloidscape URLs and drivers.
              Thanks,
              David
              prasen <[email protected]> wrote:
              >Raghu,
              > It depends upon your implementation of ResourceAdapter, particularly
              >your managedConnectionFactory. In the example we
              >supplied(BlackBoxNoTx.rar) it(database specific parameters) is being
              >passed to the ManagedConnectionFactory as one of its config-properties.
              >
              >Also ResourceAdapters have nothing to do with Databases. It just happens
              >that in the supplied example a Database Connection is being exposed as a
              >ResourceAdapter.
              >
              >Now if you want to use oracle database you may want to look into teh
              >source code of BlackBoxNoTx.rar's implementation.
              >
              >Hope this helps.
              >
              >regards,
              >prasen
              >
              >raghu wrote:
              >>
              >> hi there,Can we use oracle database instead of Cloudspace with the current
              >implementation?
              >> If possible can you please send me the example
              >> 1.ra.xml
              >> 2.weblogic-ra.xml
              >> files for connection to oracle. i would really appreciate any support.
              >> thanx, raghu.
              

  • Can we use different Databases (Oracle & SQL Server) in one report?

    Post Author: venki5star
    CA Forum: .NET
    Hi there.
    Can we use different databases (Oracle & SQL Server) in a same report?
    If possible how?
    Another question,
    Can we change the Provider Name at runtime of the given report. If so the above question is useless...
    Thanks in Advance.

    I tried this using Oracle Provider for OLEDB (the one that supplied by Oracle Client) and Crystal Reports 9. you can drag the column into designer but the image does not appear in preview.
    I guess it's because CR does not recognized it as image, and there are no information that the blob data is an image at all.

  • How to use JDBC database connection in Solaris

    Hi all,
    I am new to Solaris and i want to create an application using JDBC database connection.
    I want a small piece of code, probably a login page code that verifies the username from a OpenOffice database (.odb) file. I am particular to know the driver name, etc. If possible give the code using JNDI loopkup.
    Thanks in advance,
    Parasou.

    Sure no problem.
    Please stand by while I do your work for you.

  • Can I use Other database as the repository, Sybase/SQL Server? Urgent!!!

    Hi all,
    Can I use Other database as the repository, Sybase/SQL Server? Urgent!!!
    And Can I use other database store business data and sync with lite?
    Thanks ahead!!!

    Jonathan,
    No, it is not possible to use any other database than Oracle (8.1.7) or later .
    Oracle Lite will only work with Oracle.
    Regards

  • Can I use flashback database to recover it?-----QNo.115

    I have dropped a tablespace through RESETLOGS.
    Can I use flashback database to recover it?-----

    5.3.1 Limitations of Flashback Database
    http://download-east.oracle.com/docs/cd/B19306_01/backup.102/b14192/rpfbdb003.htm

  • Can i  use Oracle Database Audit Vault and Oracle Database Firewall on Solaris?

    Can i  use Oracle Database Audit Vault and Oracle Database Firewall on Solaris?

    4195bee8-4db0-4799-a674-18f89aa500cb wrote:
    i dont have access to My Oracle Support can u send text or html of document please?
    Moderator Action:
    No they cannot send you a document that is available only to those with access to MOS.
    That would violate the conditions of having such service contract credentials.
    Asking someone to violate such privileges is a serious offense and could get that other person's organization banned from all support and all their support contracts cancelled.
    Your post is locked.
    Your duplicate post that you placed into the Audit Vault forum space has been removed (it had no responses).
    This thread which you had placed in the Solaris 10 forum space is moved to the Audit Vault forum space.
    That's the proper location for Audit Vault questions.

Maybe you are looking for

  • How do I update/change the connect descriptor for a target RAC database in Cloud Control

    I have Cloud Control 12c Release 3 set up and monitoring many hosts and targets. However when monitoring my RAC (2 nodes), it cannot connect to the database instances (although it shows them as up). I get the message "IO Error: The Network Adapter co

  • HR Abap-RPTQTA00 enhancement

    Hi friends, anyone who made changes in rptqta00?? can you share your experince? I want to change the output this way: difference between generated leave in a year and the taken /availed leave should not exceed 40 days. is this possible? the stand rep

  • Numbers If Formula

    Help, I am trying to make an if formula, but can't get it to work. So what I need to do is - I'm using numbers to keep details of booking for an event, and I have set up a second table for people who said they would like to volunteer. On my booking t

  • Since recent upgrade of OS X Safari  won't download a readable adobe document.  Is there a fix?

    I was notified to upgrade OS X to 10.8.5.  Part of the upgrade was adjustments to Safari.  Now when I download a document into Adobe format it will not open and gives an alert that it is not able to be opened because it is damaged.  Never happened be

  • Command Server Behavior in CS4 Troubled

    Does anyone know what happened to the Command server behavior in CS4. When I use MX 2004 to create an Update Command, I get the following code on the page: set Command1 = Server.CreateObject("ADODB.Command") Command1.ActiveConnection = MM_sportstest_