Two applications sharing database

Hi,
I have one database with information and two different applications who both can read and write in that database.
But how can i implement that if one application is writing in the database that the other one can't access the database?

It can be done with Lock and Conditions
An example of Producer/Consumer problem , Producer and Consumer are 2 different threads Producer uses set and Consumer uses get methods. Both of those methods are implemented in the class below, with locks you make sure that each time ONLY one of these threads has exclusive acess to the class methods.
In the example Conditions are used so that Producer cant write when the buffer is full (buffer is an int variable here, capable of holding one int at a time) so the thread enters in await state.Similar the Consumer cant read before the Producer writes the new number (avoiding the consumer to read any duplicates). When the condition is satisfied a signal occurs so that if a thread was in the waiting state for that condition it can now continue.
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.Condition;
Lock accessLock = new ReentrantLock();
Condition canWrite = accessLock.newCondition();
Condition canRead = accessLock.newCondition();
public void set(int value)
        accessLock.lock();   
        try
            while(occupied)
                displayState("Buffer full. Producer waits.\n");
                canWrite.await();
            buffer = value;
            occupied = true;
            displayState("Producer writes "+value);
            canRead.signal();
        catch(InterruptedException exception)
            exception.printStackTrace();
        finally
            accessLock.unlock();
public int get()
        int readValue = 0;
        accessLock.lock();
        try
            while(!occupied)
                displayState("Buffer empty.Consumer waits\n");
                canRead.await();
            occupied = false;
            readValue = buffer;
            displayState("Consumer reads "+readValue);
            canWrite.signal();
        catch(InterruptedException exception)
            exception.printStackTrace();
        finally
            accessLock.unlock();
        return readValue;
    }If you understand the concept of locks and conditions you can easily apply them to control the access over your database.
Hope i ve been of some assistance!

Similar Messages

  • Lync reporting: Found QOEMatrics database stores media related info of all interactions(Audio,Video ,conferences) except IM and application sharing.

    Do we have any way to let QOEMatrics db to store media info of every sessions(including IM,sharing)?
    Ref:Lync 2010 SQL reporting databases and tables.

    The following types of content are not archived with Archiving Server:
    Peer-to-peer file transfers.
    Audio/video for peer-to-peer instant messages and conferences.
    Desktop and application sharing for peer-to-peer instant messages and conferences.
    For the detailed information, see
    http://technet.microsoft.com/en-us/library/jj204900.aspx
    Lisa Zheng
    TechNet Community Support

  • BC4J/UIX: Multiple Application Modules / Database Connections

    My UIX application must have access to two databases. One is the main database for the application and the other contains lookup information. The lookup database is shared by many applications of different types. I need to display values in the UIX page and also create a composite view from tables in each database.
    My understanding of this is that a UIX page requires a root Application Module which can have nested application modules allowing construction of a complex application. It appears that a UIX page must be tied to the root Application Module and then the nested modules can be referenced and used later in the UIX page.
    Can I create a root Application Module that contains a nested application module that connects to a different database? If so, are there limitations in building associations between the AM's that use different databases?
    If this is possible, how do I do it? I have created separate projects: one for each of the databases I mentioned and one for the main application module in a separate project. I try to create a "New Business Components Package" and "EJB Entity Facades for existing Entity Beans". The two application modules do not appear. (I created jar files for each of them and referenced these as libraries in the root module project.) Is this the correct approach? I have not found documentation that shows me how to do this yet so I admit I could be completely off base.

    Okay, I figured out that I have to build all of the BC4J packages under the same project and that the EJB Entity Facades is not what I should be working with.
    Maybe I will figure out the rest before too long.

  • Can two applications share  the same domain ?

    Hello experts,
    I have done a web application using struts, now the client need is splitting my application into two and accessing them like
    First App :http://servername:port/demo/one/index.jsp
    Two App: http://servername:port/demo/two/index.jsp
    Is it possible that both the applications sharing single domain name?
    Thanks in advance.
    SRI.

    Hello,
    This can be done. the domain names can be same the context path will distinguish the service like
    http://servername:port/demo/one/index.jsp Context part starts from Demo which can remain same and then you can have different services like one,two,three etc
    to be more easy we
    http://servername:port/service/app-name/ etc..
    Please do let me know for more information.
    Thanks
    Suresh

  • Accessing shared database throws exception from one of 2 web roles

    Setup:
    Shared database
    Main site and "admin site" each using separate web roles accessing shared database.
    I had things working and running correctly until about 2 days ago.  Then, only the "admin site" stopped working.  I am using the same code to access the database across both sites but am getting the following exception when trying to access the
    database in the admin site:
    Message: Unable to open connection to "Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0".
    Stack Trace: at IBatisNet.DataMapper.SqlMapSession.OpenConnection(String connectionString) at IBatisNet.DataMapper.SqlMapSession.OpenConnection() at IBatisNet.DataMapper.Commands.DbCommandDecorator.System.Data.IDbCommand.ExecuteReader() at IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject[T](RequestScope
    request, ISqlMapSession session, Object parameterObject, T resultObject) at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject[T](ISqlMapSession session, Object parameterObject, T resultObject) at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject[T](ISqlMapSession
    session, Object parameterObject) at IBatisNet.DataMapper.SqlMapper.QueryForObject[T](String statementName, Object parameterObject) at AutoOffers.Persistence.SqlMapperWrapper.QueryForObject[T](String statementName, Object parameter) at AutoOffers.Persistence.Mappers.DbUserMapper.FindByEmailAddress(String
    emailAddress) at AutoOffers.Persistence.Repositories.UserRepository.FindByEmailAddress(String emailAddress) at AutoOffers.Core.Domain.Services.Authentication.MembershipService.ValidateUser(String username, String password) at Admin.AutoOffers.Web.Controllers.HomeController.Login(LoginModel
    model, String returnUrl) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,
    IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
    at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
    asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
    asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult
    asyncResult)
    NOTE: I've tried to go to the v4 provider but get the same error (except with v4 in place of v4).  I would suspect something amiss with my application if I didn't have a working one using shared code...though I'm still not ruling out that I'm doing
    something wrong, just waiting for input from here.
    Thanks in advance.

    Hey there, and apologies for the lack of response.  Are you still having this issue and still needing help?  If so can you tell me a little more.  Where is the application running (web/worker rolls)? what are the details on the SQL Database?
    Thanks Guy

  • ORA-02050 ORA-02068 ORA-03113 in apex application shared db link

    Dear all,
    I got error occasionally ORA-02068: following severe error from INV_FBIH ORA-03113: end-of-file on communication channel
    when I login into application on Apex.
    INV_FBIH is shared database link
    there is error:
    ORA-02050: transaction 11.26.780771 rolled back, some remote DBs may be in-doubt
    ORA-02068: following severe error from INV_FBIH
    ORA-03113: end-of-file on communication channel
    Database is: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit
    Is there any solution for this problem?
    Regards,
    Ed,
    Edited by: 852611 on May 24, 2013 8:27 AM

    I've had some problems in the past with in-doubt transactions with a DB link to a Sybase database. I can imagine it is more difficult for Oracle to manage transactions over a DB link if the the database is not Oracle. Especially with SQL Server/Sybase that do their own commit by default. Might that be the case here?
    ORA-03113: end-of-file on communication channelThis also indicates a network problem.
    You can also post this in the General Database forum.

  • Why is my through put better with two applications than one application?

    I have two functions, acquire data and write date to database.  If I divide these two functions into two applications run under one project, my through put is 100 Hz; but if put both function into one application my through put 10 Hz.

    Code woudl help. Without it we would be shooting in the dark as to what your issue is.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Connection between two SQL Azure Databases

    We have a requirement to move data (partial data in a table based on policy conditions) between two SQL Azure Databases. Want to know the best possible way to do this.
    We are not looking at Data Sync Framework - as this is only a Preview version and we have to use this in an ongoing basis in Production and the volume of data is quite high.
    The option that we have currently is to use an on premise stored procedure - that will have two link servers to the source and target SQL Azure Databases and do the data movement in one transaction.
    Are there any other better options to do this ? Any pointers will be helpful.

    Hi Kothai Ramanathan,
    According to your description, if you just want to moving part of the data from a huge table between two different SQL Server database, you can use
    SQL Server replication to sync the part of data via articles. However, in SQL Azure database, it does not support SQL Server replication, if you want to migrate database, as other post, you
    can use Data-Tier Application Import and Export or other ways.
     In addition, for just moving the part of data,  you can also create two Linked Servers between local SQL Server database and two different SQL azure database. For example, you can get the changed data from the first Linked
    Server and saved the data to Local database, then insert these data to the other azure database via the second Linked Server.
     For more information, see:
    http://azure.microsoft.com/blog/2012/09/19/announcing-updates-to-windows-azure-sql-database/
    http://blogs.msdn.com/b/sqlcat/archive/2011/03/08/linked-servers-to-sql-azure.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to install and configure an UNIX Oracle shared database

    Hello everybody,
    we have a SUN Solaris UNIX,
    we have no problem for installing and configurate a typical database.
    So we want a "shared" database (multithread).
    When we try (deployement of a java application with JDevelopper), we cannot access to our instance of the shared database.
    The error message is :
    "SQLException: The network adapter could not establish the connection".
    The architecture of our project include CISCO firewalls.
    I think the configuration of Multi thread Server is not Ok or there are
    a bug with firewalls.
    How can i check a good shared configuration ?
    What is the good configuration ?
    If Somebody can help me with response and eventually samples of good
    initialisation files like init.ora, listener.ora, sqlnet.ora ...
    Thank you very much.

    You can try this methodology to test connectivity :
    From the server itself :
    sqlplus username/password@tns
    where tns is the alias of your database containing :
    SID , machine ( where your db reside ) and port.
    If you cannot connect from here , then check your tnsname.ora if you got the right entry.
    From a client : ( different machine )
    where tns is the alias of your database containing :
    SID , machine ( where your db reside ) and port.
    If you cannot connect from here , then check your tnsname.ora if you got the right entry
    use SQLPLUS first to test connectivity, and if you were
    able to run this process then move on run your java codes.
    If installing sqlplus from the client is a hassle, first write a
    java code testing just the connectivity with sqlplus installed
    on the first machine and make it work first. Then you can
    use this code to other clients without installing sqlplus.

  • Two Application Server Instances on one Soalris Machine

    Hi,
    I've two Application Server Instances, 9.0.2 and 9.0.4 on one Solaris box. Can anybody tell me how I can change the port number of the Oracle Enterprise Manager?

    IN part because the host and port information is threaded in a LOT of different files. And, if you are farming, some of those files are inside the repository database.
    This was partially addressed in the Oracle AppServer 10g R1 (9.0.4) - using the 'change' scripts.

  • How to combine two applications with different workspaces in APEX

    Hi,
    Can anyone help out in merging two applications with different workspaces in APEX 3.2 ?
    Thanks in advance,

    Hello Satya,
    >> I am Satya …
    Please take one more step to help us and update your forum handle to something friendlier than user123… Thanks.
    >> Can anyone help out in merging two applications with different workspaces in APEX 3.2 ?
    This is not a trivial task.
    You didn’t mentioned if both workspaces sharing the same APEX instance, or they are on two different instances (machines). I believe the latter is a pre-condition to a success.
    First you need to remember that importing an APEX component, like a single page, is possible only to the same application that it was exported from. This is still valid if you have the same workspace on two separate APEX instances – one is an import of the other (which makes it an identical copy). Still, the application ID must be the same, or you’ll get the following error: “This page was exported from a different application or from an application in different workspace. Page cannot be installed in this application.”
    You can’t simply manipulating the export file, if the two workspaces are sharing the same APEX instance, as all workspaces on the same instance shares the same APEX metadata files, and you’ll receive a “unique constraint violated” error messages. That means you can’t import one application into the workspace of the other, even if you are using a different application ID.
    As far as I can see, the only viable way of doing an application merge is to have two identical workspaces, on two separate APEX instances. The two applications should share the same application ID, although this parameter can be changed in the import file. You should export the page in one application – on the first instance – and import it into the other application – on the second instance.
    You should also make sure that the exported page ID doesn’t exist on the target application, otherwise it will be replaced by the new imported page. Also, if the imported page include references to shared components that are not defined on the second application, it might also pose a problem.
    As I said, this is not trivial. The benefits are mostly depend on the amount and complexity of the pages you want to merge. If they are not many, and simple, you should consider just re-creating them on the target application. If they are very complex, the merge might fail anyway.
    Regards,
    Arie.
    Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

  • Two apps sharing same port

    Hi, I have two applications running on Windows 7 Home premium which both use port 443  - Battlefield 4 and WD MyCloud.
    With the remote access enabled on the Mycloud, battlefield4 loses server connectivity after a period, typically 30 minutes or so.
    Turning off the Mycloud remote facility removes the battlefield4 server disconnects - but this is not an ideal fix.
    I'm new to port forwarding but did attempt to forward port 43 to 491 (random choice on my part). This port config on the BT Router I named bf4.  However this did not work and I wonder how the router knows I only want the Battlefied4 forwarded and not
    WD Mycloud.  Am i going about this the right way?
    Any advice gratefully received.
    Regards
    Graham

    Hi,
    Skype might use port 443, but all depends on your configuration, you can refer to this guide to change the settings
    Which ports need to be open to use Skype for Windows desktop?
    https://support.skype.com/en/faq/FA148/which-ports-need-to-be-open-to-use-skype-for-windows-desktop
    1) can several running applications use the same port e.g. Skype, BF4 and MyCloud?
    Extracted from the MSDN article
    The TCP/IP protocol uses a 16-bit number, called a port, to differentiate connections to multiple network applications running on the same machine. If an application is listening on a port, then all TCP traffic for that port goes to that application.
    Other applications cannot listen on that port at the same time.
    http://msdn.microsoft.com/en-us/library/aa395195(v=vs.110).aspx
    I also would like to sharing this link with you
    http://stackoverflow.com/questions/1694144/can-two-applications-listen-to-the-same-port
    2) If I forward port 443 to a different port on my PC, how does this only work for a specific app?
    Personally, the application declares on which port it is listening. to change the port for an applciation, I suggest you contact the application vender, or you need to check with the documentation of that specific application.
    NOTE
    This
    response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.
    Microsoft
    does not control these sites and has not tested any software or information found on these sites.
    Yolanda Zhu
    TechNet Community Support

  • Application sharing not working

    Hi,
    I configured various settings according to the docs on help.sap.com for this application sharing. The instant messaging is working but the app sharing is not working. I am just getting a blank screen whenever I try to start a session. Am I missing some or the other thing. Can anyone tell what could be the reason.
    rgds,

    Hi,
    I might repeat some of the steps that you have already perform, but this just to make sure that everything is covered.
    Let’s concentrate on the sharer machine (the machine from which the user is trying does start application sharing):
    In this stage, it is clearly a problem of downloading the ActiveX if you can't see one of the application sharing objects under Internet Option -> Security -> Custom Level.
    The names of the objects that you should look for are:
    ExpApplSelect” or “ExpApplShareX”.
    1.Did you tried to start application sharing from more than one machine? Is this behavior happened also on the other machines?
    2.The windows user that is logged on to the machine and is performing the download should be administrator on that machine. Is that is the case?
    3.Do the browser security settings allow the downloading and running of the signed ActiveX control? The following entries are relevant:     
      - Download signed ActiveX control- set to prompt.
      -  Run ActiveX control and plug-ins – set to enable
    4. Do you receive any messages when trying to start the application sharing? Do you receive a prompt window for downloading the ActiveX?
    Thanks,
    Eynat

  • Problem rename sharepoint 2010 search service application admin database

    Hi all,
    i have a problem that hopefully someone has an answer to.  i am not too familiar with sharepoint so please excuse my ignorance.
    we have sharepoint 2010 on a windows 2008r2 server.  everything seems to work fine.  but as you know, the default database names are horrendous.  i have managed to rename all of them, except for the "search service application" admin
    database.
    the default is: Search_Service_Application_DB_<guid>
    the other 2 databases (crawl and property) were renamed without a problem.
    we are following the article from technet on how to rename the search service admin db (http://technet.microsoft.com/en-nz/library/ff851878%28en-us%29.aspx).  it says to enter the following command:
    $searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "new database name" -DatabaseServer "dbserver"
    however, i get an error about identity being null.  no big deal, i add the -Identity switch and the name of my search service application.  but the real problem comes the error it throws:
    Set-SPEnterpriseSearchServiceApplication : The requested database move was aborted as the associated search application is not paused.
    At line:1 char:54
    + $searchapp | Set-SPEnterpriseSearchServiceApplication <<<<  -Identity "Search Service Application" -DatabaseName "SharePoint2010_Search_Service_Application_DB" -DatabaseServer "dbserver"
        + CategoryInfo          : InvalidData: (Microsoft.Offic...viceApplication:
       SetSearchServiceApplication) [Set-SPEnterpriseSearchServiceApplication], I
      nvalidOperationException
        + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.SetSearchS
       erviceApplication
    when i look at the crawling content sources, i see "Local SharePoint Sites" and it's status is Idle.  i even looked at this article on how to pause the search to no avail.  (http://technet.microsoft.com/en-us/library/ee808864.aspx)
    does someone know how i can rename my Search Service Applcation Admin database properly?  or at least "pause" that service so i can rename it?
    thank you all in advanced

    If you want to have no guids for your search admin db, i recommend you check out this script :)
    just delete your search service application (assuming you have just started)
    Alpesh Nakar's Blog
    Alpesh
    Just SharePoint Just SharePoint Updates
    SharePoint Conference Southeast Asia
    Oct 26-27 2010 Contributing Author
    SharePoint 2010 Unleashed
    MCTS: SharePoint 2010 Configuration
    MCITP: SharePoint 2010 Administrator

  • How do I stop two iphones sharing contacts?

    How can I stop two iphones sharing contacts and apps?

    Stop syncing them with the same address book or cloud service.

Maybe you are looking for