Only letting one instance of my application run
hi guys,
My application will allow the user to interact with the database. The database will be stored on a local machine, and not on a network, so that only one person can access it at a time.
The problem is, I believe a user can launch two instances of my application simultaneously, and therefore there are potential problems.
So I want the user to only ever be able to launch one instance of the JFrame through which all interactions to the DB are made.
So MyApp.java contains
class MyApp
public void main (String[] args)
MyFrame mF = new MyFrame();
}Now, is it the right idea of mine to make mF singleton? Or is it the wrong approach?
But what is confusing me is...if at the java prompt I type
java MyApp
and then I type, once again
java MyApp
will these two be treated as two completely different running of programs? Say I had mF as a singleton. Does this mean there can exist one instance of mF in each of my two different runnings of MyApp, or are the two somehow connected, which means that if I ran MyApp a second time theer'll be some sort of error cos mF already exists and cos it is a singleton, it can't exist twice?
Sorry if I havent made myself clear. I'm very confused myself.
Thanks.
AU
My application will allow the user to interact with
the database. The database will be stored on a local
machine, and not on a network, so that only one
person can access it at a time.If using jdbc then local or remote only really effect your database driver choice not your code.
The problem is, I believe a user can launch two
instances of my application simultaneously,Yes.
and therefore there are potential problems. Potential but not that difficult to avoid.
So I want the user to only ever be able to launch one
instance of the JFrame through which all interactions
to the DB are made.If you think about responsibilities, then data integrity is not the responsibility of the UI, its the responsibility of the DBMS.
Now, is it the right idea of mine to make mF
singleton? Or is it the wrong approach?A Singleton will only ensure that a jre has a single instance. If you start multiple instances of the jre then there can be one instance of the application in each.
The best solution is to use your databases normal locking process through the JDBC api
The simplest solution is for your program to lock either the database, the table or the record you are interested in. You can do this by creating a lock record on a seperate table. If the insert fails to create the record, somebody else is already using the dataset. If it succeeds then is available. You will need a way to forcible clear the lock if your application stops unexpectedly.
Similar Messages
-
"Only a single instance of this application can run" Have you seen this yet?
Hi -
Please excuse a newbie's ignorance - I've never posted to any forums before :-)
I am using Win7 Professional and IE9 on a well-spec'd HP PC (4GM Ram, dual core, lost of hard disk space etc).
I have successfully downloaded Adobe Reader (install_reader 10....exe @ 703kb) using Win7.
I cannot run this file (I have tried all I talk about here with Reader 9 and with Firefox; all the same errors noted below get repeated)
The error message is headed: "UI_ReaderInstaller" and the text in the message is "Only a single instance of thsi application can run"
The only option given is an "OK" button and leaves one having achieved nothing!
I have never had a previous version of Adobe reader on this PC; this is a first time install attempt.
If I search my PC for "UI_ReaderInstaller" it does not give any results!
Please might someone more competent that I help me out here? Maybe you've experienced this and found the solution? Please might you share your knowledge with me?
Thanks for reading and giving this your attention. It is much appreciated.
Highland DHi Ankit
Thanks for taking the troubel to reply. Sorry if I didn't give full information (I thought I had!)
I have successfully doenloaded the intsaller to my PC (see last post and "PScreen 1" enclosed
When I try to run it I get the error described in my last post (see "PScreen 2" enclosed).
I really need your help so thanks again
Highland D -
I try to follow the steps 1-3, as it shows. After it downloads, after step 2, a dialog box pops up saying “Open Executable File? Then it says it may contain viruses or malicious code and to be careful when opening file. So I click OK, then step 3 occurs, file name lists as: install_flashplayer11x32_mssd_aih(2).exe. So then I hit “Run”. Then another dialog box pops up titling “UI_FlashPlayerInstaller”, and it says “Only a single instance of this application can run”, “OK”. I’ve checked to see if there is another version installed, but I don’t see any. I am operating a Windows 32 Bit, FireFox,
Download the full installer from this FAQ http://forums.adobe.com/thread/909550
Save it to disk, then close all browser windows and run the downloaded installer. -
Hello, Can someone help me with Adobe Flash Player installation ?
I have tried too many things to install it but keep getting this message " only a single instance of this application can run.
I can't see any Adobe applications, I've tried deleting all files adobe and still nothing.
I have opened the task manager and try to end the processes related to Adobe manually by selecting 'End Process' and then try to install it, but nothing happened.
I've tried 'clean boot' but neither worked.I downloaded the 'Adobe unistaller' from the official page and the 'latest version of flash player' but it doesn't work!.
I've also went on the Adobe website and it said this error message was due to the flash application but I deleted all of those files to and still nothing.
I've got firefox and windows 7.If you haven't done so already, reboot your computer, then re-run the installer you downloaded.
-
Sir,I can't install Adobe 17X32.I have Win 7 system.All previous versions have been uninstalled and yet I am getting a message--ONLY A SINGLE INSTANCE OF THIS APPLICATION CAN RUN.How do I remedy the situation?
Thanks,
Message was edited by: Maria Vargas
Removed personal email address, which should not be included in a public forum.Hi Viraj,
Please try the offline installer posted at the bottom of the Installation problems | Flash Player | Windows page, in the 'Still having problems' section.
Maria -
"Only a single instance of this application can run" error when installing Flash
I deleted Flash Player when trying to solve a Shockwave Flash Google Chrome issue, and after being unable to solve it I switched to Firefox. I now can't get the installer to open. I double-click on it, it asks me if I want to run it. I click Yes, then the window closes and the installer doesn't open. When I try running the installer again, I get the error message "Only a single instance of this application can run". I have tried everything. I closed Firefox, restarted my computer, and ran the Flash Player uninstaller. I am running Windows 8.1 64-bit with Mozilla Firefox and I am trying to run the latest version of Flash Players as of October 26 2014. Please help!
The download link has moved since then: http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe
-
Reinstalling - "Only a single instance of this application can run"
I had to uninstall Adobe Reader some months back and ever since have been unable to reinstall. I get through the first couple download steps, and click yes to "allow the following program to make changes to this computer", but then it all closes down and sometimes I get the "Only a single instance of this application can run" box pop up. I googled that error message and have spent hours trying every tip on how to resolve it on various message boards but nothing works and I really need to be able to open pdfs again. Thanks for any help you can provide.
If you are in Windows (which we don't know), you can try using this tool to first remove all traces of Reader from your computer:
http://labs.adobe.com/downloads/acrobatcleaner.html
Then, you can download the full offline Reader installer from
http://get.adobe.com/reader/enterprise/
After downloading, restart your computer and run the installer before doing anything else. -
I get this error message: only a single instance of this application can run
When I try to open my bank statement I get this message: only a single instance of this application can run. Just wondering what that means, and how do I open a file with adobe reader?
Adobe Reader | Edit | Preferences | Security (Advanced)
That is, start Adobe Reader.
Chose Preferences from the Edit menu
Look at the left hand side for Security (Advanced) and click on it
Now look for the option to turn off Protected Mode. -
Help! Every time I try to download the newest update I get a dialogue box that states " Only a single instance of this application can run at a time".
Hello,
What error, if any, is being displayed when you attempt to install Flash Player?
Please post the contents of the /Users/<YourUserID>/Library/Logs/FlashPlayerInstallManager.log for the install attempts that are failing. These will be listed at the end of the file. Each attempt begins and ends with --- log start --- and --- log end ---.
Thank you in advance.
Maria -
Hi Guys,
SSIS 2012 ETL is failing only at one server (No BIDS) but running successfully from BIDS on different sever . In this ETL, I have used Stored Procedure in OLEDB Source.
Note: I have couple of ETLs developed in 2005 using same logic and upgraded to 2012, working perfectly.
I am getting Error Message:
SSIS
Error Code
DTS_E_OLEDBERROR.
An OLE DB
error has occurred.
Error code: 0x80004005.
An
OLE DB
record is available.
Source: "Microsoft OLE DB Provider for SQL Server"
Hresult: 0x80004005
Description: "Error converting data type varchar to datetime.".
Unable
to retrieve
column information
from the data
source. Make
sure your target
table in
the database is
available.
"OLE DB Source"
failed validation
and returned
validation status
"VS_ISBROKEN".
I tried below word around and found It is working perfectly.
I loaded data into a table (dbo.TEMP) using Stored procedure and then I used this dbo.TEMP table in OLEDB source and then found no issue.
MY SP Details: (This SP I am calling in OLEDB source of ETL) and when I run it from one server IT is working fine and when I run from ETL dedicated Server getting error: Guys Help me out.
USE
[TEST_DB]
GO
SET
ANSI_NULLS ON
GO
SET
QUOTED_IDENTIFIER ON
GO
ALTER
PROCEDURE [DBO].[SP_TEST]
--EXEC [DBO].[SP_TEST] '2014-09-30','2014-10-01'
@FROMDATETIME
DATETIME,
@TODATETIME
DATETIME
AS
SET
NOCOUNT ON
BEGIN
DECLARE
@FROMDATEKEY INT,
@TODATEKEY INT,
SET
@FROMDATEKEY=
CONVERT(VARCHAR(10),@FROMDATETIME,112)
SET
@TODATEKEY=
CONVERT(VARCHAR(10),@TODATETIME,112)
IF 1 = 1
BEGIN
SELECT
CAST(NULL
AS DATETIME)
AS TXN_DATE
, CAST(NULL
AS DATETIME
) AS PROCESS_DATE
, CAST(NULL
AS money)
AS S1_AMT
, CAST(NULL
AS money)
AS S2_AMOUNT
, CAST(NULL
AS money)
AS S2_INVALID_AMOUNT
, CAST(NULL
AS money)
AS INVALID_MOVED_IN_VALID_S2_AMOUNT
, CAST(NULL
AS VARCHAR(20))
AS SYSTEM_ID
, CAST(NULL
AS money)
AS S3_AMT
END
SELECT
TXN_DATE
,PROCESS_DATE
,S1_AMT
,S2_AMOUNT
,S2_INVALID_AMOUNT
,INVALID_MOVED_IN_VALID_S2_AMOUNT
,SYSTEM_ID
S3_AMT
FROM
DBO.TABLE_1
WHERE TNX_DATE_KEY
BETWEEN @FROMDATEKEY
and @TODATEKEY
UNION
ALL
SELECT
TXN_DATE
,PROCESS_DATE
,S1_AMT
,S2_AMOUNT
,S2_INVALID_AMOUNT
,INVALID_MOVED_IN_VALID_S2_AMOUNT
,SYSTEM_ID
S3_AMT
FROM
DBO.TABLE_2
WHERE TNX_DATE_KEY
BETWEEN @FROMDATEKEY
and @TODATEKEY
UNION
ALL
SELECT
TXN_DATE
,PROCESS_DATE
,S1_AMT
,S2_AMOUNT
,S2_INVALID_AMOUNT
,INVALID_MOVED_IN_VALID_S2_AMOUNT
,SYSTEM_ID
S3_AMT
FROM
DBO.TABLE_3
WHERE TNX_DATE_KEY
BETWEEN @FROMDATEKEY
and @TODATEKEY
END
Data Source Mode: SQL Command for Variable
"EXEC [DBO].[SP_TEST] '"+ (DT_WSTR, 24) @[User::V_EXTRACT_FROM_DT] +"','"+ (DT_WSTR, 24) @[User::V_EXTRACT_TO_DT] +"'"
Where variable @[User::V_EXTRACT_FROM_DT] and @[User::V_EXTRACT_TO_DT] is defined as DATETIME
Thanks Shiven:) If Answer is Helpful, Please VoteHi,
Yes you are right. At one sever where I was getting error, DateTime was in USA format and Where It was running successfully was in AUS format.
I changed from USA to AUS and I did another changes:
Data Source Mode: SQL
Command
EXEC [DBO].[SP_TEST]
@FROMDATETIME = ?,
@TODATETIME = ?
and It is working fine.
Thanks Shiven:) If Answer is Helpful, Please Vote -
Prevent two instances of an application running simultaneously
Hi,
This is the code which I use to prevent two instances of an application running simultaneously.
public void init()
new Thread(new Runnable() {
public void run() {
try
ServerSocket socket = new ServerSocket(9876);
socket.accept();
catch (Exception ex)
// already running
System.out.println("Socket Exception"+ex);
System.exit(0);
}}).start();
}This code is not working for mac. Please help with a solution/alternative.
Regards,
RonycodingMonkey wrote:
If this is an applet, at least call super.init() in your init() method, though it would probably be better to rename the method.Aside from the fact that I hope the applet is signed, or he can't get a socket of any kind anyway. And it makes the calling of accept that much worse, as now he is opening a port to a client machine (unbeknownst to the user). -
How to restrict only one instance of web service running at a time
Hi All,
Have a requirement to ensure that only one instance of java web service is active at any point of time.
Using Application Server 10.1.3.4. Not the soa suite.
Thanks
SaikrishnaThanks for the reply..
I have a java web service that pulls up some files produced periodically from remote machine and uploads them to some doc mgmt system and then update the database that what files are uplaoded successfully so that during next run it will ignore those files.
so, if my web service executes second time before completion of first run. It would pick files that were already processed by first run since the first run might have not updated the databse yet.
Thanks
Saikrishna -
I want to be able to use only one instance of Pod Farm for my guitars, and have all of my guitar tracks run through it while I'm recording.
What he said. Or here is a similar approach with a picture.
1. Press the SEND button on every stereo (or mono) guitar track you want to send through the effect. Then select a free bus.
2. Make sure you turn up the amount of send (in db). Holding alt while leftclicking on this circle sets the send level to 0 db wich is good.
3. Open the mixer (Cmd+2). Please see that I here have turned the output off from the stereo guitar track. That way the only output will be the BUS, in your case the AmpTrack bus where all your guitars will pass through. If you want both the original guitar sound AND the Ampfarm effect then just set all outputs on your guitar tracks to Stereo Out, like the AmpF Bus track is set in my picture.
4. Insert your AmpFarm plugin here. I don´t have that plug so I inserted Waves Renes Axe for demo purpose.
Adjust the volume/effect of every guitartrack by turning the circle input shown as 2. in my picture.
I now see that you mentioned Pod Farm, not AmpFarm. But I guess it´s the same trick.
Have fun.
Heyclown.
Message was edited by: WizardSongs - Typhoos -
Running Air in More than One Instance of an Application
Is there a work around to allow more than one instances of an Air Application to run?
Currently our client uses dual monitors they will spin up two applications. One is to Inquiry data the other is to enter data. I know I can create another project and deploy it under another name but that seems clunky.
We are using AIR with Flex/Blaze/FlexMdi.
Any information would be greatly appreciated.
Thanks
SteveHi,
I'm not too sure if the workaround proposed below will work or not. But it seems worth a shot:
Create a new window when you get the invoke event. Find your desired screen's bounds by going through the static array Screen.screens. Assign that bounds to your newly created window. -
Stop more than one instance of app from running
hi,
is there any way to stop more than one version of an application from running? i've seen topics on singelton but i'm not sure if that's what i need, i'm a little confused on that. what i need to do is stop the main app from running if it's already running, not some object within the app. something like being able to run only one instance of ms word. i was thinking about using a file, writing to it and deleting it when the app closes, so if the file exists the new instance will know something is running and not run, but the problem is if the app crashes because of windows, i won't be able to delete that file. any ideas?
Thanks.1. The app should implement a special tiny server it tries to start on a specific range of private ports.
The Well Known Ports are those from 0 through 1023.
The Registered Ports are those from 1024 through 49151
The Dynamic and/or Private Ports are those from 49152 through 65535
- http://www.iana.org/assignments/port-numbers
2. When the app starts, it tries to find a server already running on one of your defined ports, connect and listen for a special message you can choose: "app xyz by soni29 already running".
If found, the application displays a message and terminates.
Otherwise it starts the server and continues.
Maybe you are looking for
-
I am really new to Solaris so please forgive me if I sound really dumb. I was able to install Solaris 10, turned off my computer and now all I recieve is System failed memory test. Please help have tried different memory sticks and still recieve the
-
Bapi_po_create is not creating Purchase Orders for multiple records in file
Hi All. iam trying to create contracts and Purchase Orders In me21n,me31k . here iam using bdc for contract creation against services and using bapi_po_create for PO Creations. in this process i could create contracts and POs for the first record in
-
Hi, I am using oracle 10gR1on windows.I have created a standby machine(Physical standby) and want to open in read only mode first time it is open in read only mode but after manually recovery want to open in read only mode.It is not open in read only
-
Can I de-install ios 8.0.2 from my iphone 5s
can I un-install ios 8.0.2 from my iphone 5s
-
How do you promote a static route over a directly connected?
Hi all, I have a need for a static route to be used instead of a directly connected route. (Long story - involving firewalls and anti-spoofing.. but can go further if required) I am using a Cisco 3750 switch. I notice directly connected routes have a