Java-nightmares

I am trying to write a program to check if an Oracle DB is up and working. If not, start up a backup DB and start the application that uses it on a different system. I am having isses with the return values not being integers as I state. I am starting to lose my hair over this mess.
Here is a copy of the program I have started to test the connection and print txt of what it does. When I print the returned int, I get something other than an int. So I can't write my checks on it. Any help would be great.
Siam
import java.sql.*;
import java.util.*;
//import oracle.jdbc.driver.*;
public class dbtest extends Object
private Connection connection;
public int dbtest()
String url = "jdbc:odbc:server";
String user = "user";
String pass = "pass";
// Load ODBC Driver
try
System.out.println("Start Driver load");
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded, start connection");
connection = DriverManager.getConnection( url, user, pass );
System.out.println("Connection complete");
catch ( ClassNotFoundException cnfex )
System.err.println("Failed to load JDBC/ODBC driver");
cnfex.printStackTrace();
return 1;
catch (SQLException sqlex)
System.err.println("Unable to connect");
sqlex.printStackTrace();
return 2;
System.out.println("Connected to DB");
try
connection.close();
catch ( SQLException sqlex )
System.err.println ("Unable to Disconnect");
sqlex.printStackTrace();
return 3;
System.out.println("Connected and disconnected from DB");
return 0;
public static void main (String[] args)
System.out.println("start of dbtest");
final dbtest test = new dbtest();
System.out.println(test);
if (test == 0)
System.out.println("Connected and disconnected from DB");
System.exit(0);
System.out.println("Could not connect to dB");
System.out.println("Now load backup db and start new netMS");
}

That is how I had it written before, but I was getting the error that I can't reference a static to a non-static variable. Here is how it was written. But in line:
if (dbStatus == 0);
I get "non-status variable dbStatus cannot be referenced from a static context"
The program is only a snipit from the whole. Afiter it checks to see if the database is running, if it failed, it will kick off the startup files for Oracle on another server plus start an application. These two I can right in a shell script. Once it is all done, I will probably put the test in a loop and run the app continuously checking the DB every 5 or 10 minutes. Kicking off the startups only if the condition is met.
Program follows:
import java.sql.*;
import java.util.*;
//import oracle.jdbc.driver.*;
public class dbtest extends Object
private Connection connection;
private int dbStatus = 0;
public dbtest()
String url = "jdbc:odbc:server";
String user = "user";
String pass = "pass";
// Load ODBC Driver
try
System.out.println("Start Driver load");
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded, start connection");
connection = DriverManager.getConnection( url, user, pass );
System.out.println("Connection complete");
catch ( ClassNotFoundException cnfex )
System.err.println("Failed to load JDBC/ODBC driver");
cnfex.printStackTrace();
dbStatus = 1;
catch (SQLException sqlex)
System.err.println("Unable to connect");
sqlex.printStackTrace();
dbStatus = 2;
System.out.println("Connected to DB");
try
connection.close();
catch ( SQLException sqlex )
System.err.println ("Unable to Disconnect");
sqlex.printStackTrace();
dbStatus = 3;
System.out.println("Connected and disconnected from DB");
dbStatus = 0;
public static void main (String[] args)
System.out.println("start of dbtest");
final dbtest test = new dbtest();
System.out.println(test);
try
if (dbStatus == 0);
System.out.println("Connected and disconnected from DB");
System.exit(0);
catch (Exception e)
System.err.println("Exception error in dbStaus");
System.out.println("Could not connect to dB");
System.out.println("Now load backup db and start new netMS");
}

Similar Messages

  • Should I restore Java Shared Archive in 10.3.9

    Does anyone know if restoring the Java Shared Archive (JSA) is still necessary on a Mac running OS X 10.3.9, QuickTime 7.1.2, and Java 1.4.2? I know that restoring the JSA was an optional step for those users whose Java implementation stopped working under the combination of OS X 10.3.9 and QuickTime 7.0.4. But, I'm wondering if it is still necessary (optional or not) now that QuickTime 7.1.x is released.
    Here's why I'm asking. I recently updated my dad's iBook G4 to OS X 10.3.9 and QuickTime 7.1.2. The iBook went straight from 10.3.8 to 10.3.9 and QT 6.5.2 to 7.1.2. I applied Security Update 2006-003 (which, apparently, automatically included the Java Update for Mac OS X 10.3.9). I performed each of these many upgrades one at a time. I repaired permissions and/or rebooted between each update and I'm pleased to say that there were NO problems with the installations and the iBook is working just great!
    The only update I haven't yet done is the Java Security Update 4.0. I plan to do that in the next day or so. Anyway, when I upgraded my Power Mac G4 to OS X 10.3.9, I lived through the QuickTime 7.0.4 / broken Java nightmare! I still haven't applied the Security Update 2006-003 or the QuickTime 7.1.x updates on my Mac because I was wary of Java being broken again. But, I was willing to use my dad's iBook as a guinea pig! I hoped that going straight to QuickTime 7.1 would avoid the broken Java problem. Apparently, it (or the Java Update for 10.3.9) did avoid the problem. I'm more comfortable with the idea of updating QuickTime on my own Mac.
    But, as I said, I'm wondering if I should restore the JSA on my dad's iBook.

    After successfully updating my dad's iBook and not running into any problems, I decided to update my own Power Mac G4 from QuickTime 7.0.1 to 7.1.2.
    Well, my Java applications are broken AGAIN! I don't get a segmentation fault error message when I type java -version in Terminal. My own amateur Java programs run. Safari doesn't crash and Java applets work properly. But, standalone Java apps crash just like they did with QuickTime 7.0.4 installed!
    I was perfectly willing to stay with QuickTime 7.0.1 indefinitely but I want to buy TV shows from the iTunes Music Store and I can't do that unless I upgrade QuickTime to at least version 7.0.3 (which I believe is where the conflicts with Java began)!
    Are there any other Panther users who have found a solution to this catch-22?
    Power Mac G4   Mac OS X (10.3.9)   QuickTime 7.1.2, Java 1.4.2_09

  • Web Start Application fails after upgrade to JRE 1.6.0_u33

    I have a production application that uses java web start for deployment. All has gone well, but we are experiencing problems when testing upgrading to the latest JRE update 1.6.0_u33.
    The application is composed of several jar files, all of which are signed with a code signing certificate. However, after updating the JRE, I receive the error :
    #### Java Web Start Error:
    #### Unsigned application requesting unrestricted access to system
    Unsigned resource: the first jar file in my jnlp
    This is a pretty odd error, since the jar is definitely signed. I can find it in the webstart cache and run jarsigner -verify against it and it verifies successfully.
    If I remove the application and reinstall it, everything works fine, but this is a pretty unacceptable solution for thousands of users, many of which are not very technical.
    Does anyone have any solutions or has anyone encountered the same problem? It is currently a showstopper for us to taking this new JRE update which contains some critical security updates we would like to have implemented.
    Thanks in advance for any help.

    Hi
    I have seen this post a little bit late, but... We have also encountered such issue.
    There is another workaround than ask people to empty the java web start cache.
    In order to force the end user's computer to download again you application entirely, we have signed again ALL the jar files and uploaded them to our server.
    That works well but... if somebody download the "new" files and upgrades java to 1.6_0_33 afterwards... same issue will appear again.
    Please observe that the traffic in this forum has started to decrease strongly. That's not amazing when you see that you cannot count on this product.
    Java web start has never worked correctly and that for a long time. This one suffers of numerous bugs and regressions. We should rather call it Java Nightmare Neverstart
    It's a shame.
    Sun has been acquired by Oracle but that does not seem change anything.
    Java RIP
    Claude

  • Getting Current Source Line Number

    I am pulling my already sparse hair out trying to perform the most remedial of tasks: I am trying to trace my code execution to debug it and to log error messages, which is done in C with something like the ubiquitous
    'printf ("%s:%d\n", __FILE__, __LINE__);'
    I can't for the life of me find anything like __FILE__ and __LINE__ in Java.
    How do I determine the current source line number??? I could live without the __FILE__ part if I had to, but the line number is imperative. Where do I get it?
    Thanks,
    Bill Rebey

    "debug" still being a hard work in Java... the oldest Java nightmare :^)))
    you may avoid this problem using labels in your code (the problem you must fill your code with debug stuff - if the code is a big one, you will get crazy about that :^) )
    or you may adopt a tool able to trace your code execution....
    JBuilder do it for you...
    Togheter is another good software available out there
    (unfortunatelly, both of them are really expensive...)
    I don�t remember now about other tools.. (the java has a flag to produce debug output - check in the forum about the debug syntax....)

  • Java Web Services - a nightmare?!

    Hello Techies,
    Java Web Services has been a nightmare for me. I would like to take your help in understanding it better. I have read many articles on it. But I did not ,yet, get a complete picture on it. They say there are JAX RPC , JAX WS , Axis and so many varities of Web Services. Its so confusing. Will you be kind enough to give a simple overview Java Web Services ? and Where do i start , If i have to learn it ? Any good source of information to learn them?
    Sincere thanks.

    I'm also facing the same problem with you to understand what is web service and how to go about it. Until today I still confusing but I tried to understand it by running a few tutorials. So far the cool one is at http://www.myeclipseide.com/documentation/quickstarts/webservices_jaxws/.

  • Nightmare with java

    Hi,
    I'm currently trying to install a game onto my laptop, however when I click the supplied java installation, it runs the begins proccessing only to crash half way through!
    After exploring the internet it seems that the game is fine, it is however that the latest update of java cannot support this older game. I installed the same game 6 months ago, however recently uninstalled to free up some space, but decided to reinstall it.
    My question is if anyone can help how i can revert back to the original java version that i was using 6 months ago?
    any help/advice would much appreaciated!

    Dale:
    You need to give us better info in your profile. Your computer is listed as running 10.3. That gives no clue of what version of Java you are running, that you were previously running. Please update your profile, and then tell us what verision of Java is troublesome.
    Good luck.
    cornelius

  • I am trying to open my Nightmare 2.jar file but java will not open. It says check console for error messages but there appears to be none. I have the latest version of java and I have both the 64 bit and 34 bit se6 set to the top of the list.

    Just like in the title of this discussion the file will not open. Any suggestions? That would be grrreat.

    Hi,
    The D810 requires Camera Raw 8.6 or later - the latest version that is compatible with Photoshop Elements 12 is Camera Raw 8.5 as far as I can see.
    You need to either buy a new version of Photoshop Elements or use the free Adobe DNG converter.
    DNG  Converter 8.8
    Win – http://www.adobe.com/support/downloads/detail.jsp?ftpID=5888
    Mac – http://www.adobe.com/support/downloads/detail.jsp?ftpID=5887
    Useful Tutorial
    http://www.youtube.com/watch?v=0bqGovpuihw
    Brian

  • You need a java SE 6 Runtime

    I have Mountain Lion on my MacBook Pro and every time I run "Dreamweave" or "Eclipse" for example, I get this message: "To open "Eclipse" you need a java SE 6 runtime. Would you like to install it now ?".
    I've tried installing it many many times, manualy and from this notification but it doesnt work.
    I've tried installing Java 7 and tried uninstalling Java 7 then installing "Java For OSX 2013-002" and dosent work too !
    everytime I install any Java version I tried this "java -version" I got this result "No Java runtime present, requesting install." !
    anybody can help ?
    Thanks

    Contact the developers of that software for a updated 10.8.3 verison that runs off Java 7.
    They are likely working on it or perhaps something better not relying upon Java at all.
    Java is a real security nightmare lately.
    Security Issues Warning List

  • Why is Java so hard?

    I know it's a lot easier than c++, but compare to VB.NET or to C#.NET it's a nightmare.
    For example, some code working under the IDE for loading images from a package directory won't work after jaring the project, since the images are jared. Why then, does it work from the IDE?
    I've been trying to find a simple code example that describes how to print a screenshot without saving it to a file, and I have not succeeded, so I'll give that up in my project(just a college project, not realy important).
    Many things that used to work when runing with the 1.4 jre, but not working anymore with the 1.5 jre.
    I've been working hours on designing GUI with the Intellij's GUI designer and once the app is runing, teh pack() is invoked and hours of work went down the drain. Why do I need to spend hours on GUI when .net developers just put the components where they want them to be, and focus on the bussiness logic?
    Apart from the challenge in beating the language (which I don't enjoy, since otherwise I would have chosen C++), is there a reason for all that?
    And is it possible that someday Java will be as intuitive as VB.NET?
    The basics of the language are easy to learn, but once you've passed that, it can be hell soetimes.
    I have no talent in graphics or in GUI designing, and therefore I find the .net enviroment much more suitable for me.
    Should I stick with Java?

    I know it's a lot easier than c++, but compare to
    VB.NET or to C#.NET it's a nightmare.Have you written a lot of C++? Or is this just something you've read? How do you know?
    For example, some code working under the IDE for
    loading images from a package directory won't work
    after jaring the project, since the images are jared.
    Why then, does it work from the IDE?Because that's the way IDEs work.
    I've been trying to find a simple code example that
    describes how to print a screenshot without saving it
    to a file, and I have not succeeded, so I'll give
    that up in my project(just a college project, not
    realy important).College? So you're an undergrad with how many years of programming experience?
    Many things that used to work when runing with the
    1.4 jre, but not working anymore with the 1.5 jre.I've not found that to be true.
    I've been working hours on designing GUI with the
    Intellij's GUI designer and once the app is runing,
    teh pack() is invoked and hours of work went down the
    drain. Why do I need to spend hours on GUI when .net
    developers just put the components where they want
    them to be, and focus on the bussiness logic?It might have more to say about the kinds of problems you're used to solving. What's the biggest problem you've done? What's the largest team you've worked on?
    IntelliJ is the best IDE I've ever used (yes, I've used Visual Studio). I can't speak to its UI designer, because I don't do Swing apps. Everything is a Web app to me these days, and UI designers take care of that in Macromedia.
    Apart from the challenge in beating the language
    (which I don't enjoy, since otherwise I would have
    chosen C++), is there a reason for all that? Yes, because enterprise scale problems are just harder than student assignments.
    And is it possible that someday Java will be as intuitive as VB.NET?There are frameworks to help. Take a look at Trails.
    The basics of the language are easy to learn, but
    once you've passed that, it can be hell soetimes.Yes, because the kinds of problems people like to solve beyond student problems are indeed hell. It's not easy in .NET, either.
    I have no talent in graphics or in GUI designing, and
    therefore I find the .net enviroment much more
    suitable for me.Then use that, by all means.
    Should I stick with Java?Probably not. Who cares?
    %

  • How to print a JTable  in Java Swing ?

    Hi,
    I have an application written in java swing.Now I want to write a print module that prints some details.The details includes the JTextArea and JTable that changes in size dynamically.One solution i found is to put them in a panel and print that panel.But it is static.The size of JTable and JTextArea changes, according to the given input.Please give me a solution for this.

    Printing is a bit of a nightmare, actually. Most of the trouble is layout. Basically a Printable is passed a page number and a graphics context and has to work out what components go on that page and where. It can't depend on the pages being requested in sequence.
    You can call getPrintable from a JTable, and you can call that through your own Printable in order to add extra pages. However you can't ask a Printable how many pages it's going to produce, you just have to invoke it and see if it returns a code to say that the page is out of range.
    And the Printable JTable generates is very limited, the table has to occupy full pages, you can't tell it to start in a different place on the first page, or find out how much space it's used on the last page. The headers and footers generate JTable's own idea of a page number, not yours.
    You can call print() on most Swing components, but you'll need to set their size and location first, and/or mess with the transformation in the graphics context.

  • Just finished my first Java application. What's next?

    Thanks to the kind help from everyone on this forum and some intensive labor for the last couple of months, I've finally given birth to my first Java application. I used Netbeans as my IDE of choice. During the development stages I would run my project directly from the IDE. In the project folder, a total of five folders were created: build, dist, nbproject, src, and test as well as two files build.xml and manifest.mf.
    Being a newbie in this field, I was wondering about the remaining steps needed to distribute the application. Here are some questions that come to mind:
    1) I know I can simply just double-click the project's *.jar* file to get it work. Is that the norm with Java applications or do I need to create a different file? I'm used to seeing *.exe* files. I'm also used to seeing an installation process, which brings me to my next question.
    2) Do you simply just zip the entire project folder and allow people to download it on their computer hoping they know how to access the *.jar* file?
    3) Seeing that I've only been testing the application in Netbeans, will there be file path or classpath problems if I run it on other computers? Are there necessary steps I need to follow to avoid such problems?
    4) Do you take any precautionary steps to protect your code? Do you lock the folders?
    5) In the future, if I decide to add a small fee to download the application, how hard would it be to add a password activation feature? (I know this could get pretty complex)
    Thanks in advance for all your suggestions.

    mohogany wrote:
    Thanks to the kind help from everyone on this forum and some intensive labor for the last couple of months, I've finally given birth to my first Java application. I used Netbeans as my IDE of choice. During the development stages I would run my project directly from the IDE. In the project folder, a total of five folders were created: build, dist, nbproject, src, and test as well as two files build.xml and manifest.mf.
    Being a newbie in this field, I was wondering about the remaining steps needed to distribute the application. Here are some questions that come to mind:
    1) I know I can simply just double-click the project's *.jar* file to get it work. Is that the norm with Java applications or do I need to create a different file? I'm used to seeing *.exe* files. I'm also used to seeing an installation process, which brings me to my next question.It's quite common to provide a shell script (batch file, etc) to launch the app.
    2) Do you simply just zip the entire project folder and allow people to download it on their computer hoping they know how to access the *.jar* file?You can do. There are also installation utilities around. InstallAnywhere is the only one I've ever used, but others do exist.
    3) Seeing that I've only been testing the application in Netbeans, will there be file path or classpath problems if I run it on other computers? Are there necessary steps I need to follow to avoid such problems?Probably. The best way to avoid them is to test them, and to not ever depend on the CLASSPATH environment variable. That's a portability nightmare.
    4) Do you take any precautionary steps to protect your code? Do you lock the folders? Nope.
    5) In the future, if I decide to add a small fee to download the application, how hard would it be to add a password activation feature? (I know this could get pretty complex) Don't bother. Unless you've got something amazing, in which case you'll be needing lawyers, it's not worth the trouble of charging for it. No offence, but your first Java app is hardly going to set the world on fire anyway.
    No matter what you try and do to stop people stealing your code, they'll manage it. Or, alternatively, just steal your idea instead.

  • Renaming a file from java

    Hello,
    I want to rename a file from a Java Application and I want this operation was very speed.
    I would renaming was "atomic".... not interruptable from Operative System.
    I made this operations in two ways: does anyone explain me if one of these is more efficient than the other one?
    Thank you very much all in advance
    Diego
    First implementation
                            String tmpStateName = stateFname + ".tmp";
                            tmpStateFile = new File(tmpStateName);
                            tmpStateFileStream = new FileOutputStream((tmpStateFile));
                   pd.store(tmpStateFileStream, "System shutdown");
                            tmpStateFile.renameTo(new File(stateFname));
    Second implementation
                            String stateFnameTmp = stateFname + ".tmp";
                   pd.store(new FileOutputStream (stateFname + ".tmp"),
                   "System shutdown");
                            String command = "mv " + stateFnameTmp + " " + stateFname;
                            Runtime.getRuntime().exec(command);
    ....

    But calling exec method of Runtime could I be faster
    than the first implementation??
    I thought that the first implementation was heavier
    (more Java objects created) than the second one...
    Was I wrong?Maybe.
    However it is not relevent. It is just flat out stupid to make things that convoluted in the name of "performance". Especially something like this. All you are really doing in the second implementation is creating a brittle, unmaintable nightmare.
    So don't do that.
    Last but not least I would highly suspect that the first implementation will be faster anyway. You don't seem to be counting on the expense of creating a new process which is not "light" relatively speaking.

  • Up date java on mac os 10.6.8

    I can not up date java on my OS 10.6.8. Every time i try it says that an error occurred. Does anyone knows what can i do to correct it?

    Install it manually
    https://support.apple.com/kb/DL1573
    You might have to run through this list of fixes to see what other problems might be casusing it to fail to install
    ..Step by Step to fix your Mac
    Also you should be seriously considering not using Java at all, it's a security nightmare.
    Or disable it when not in use, via the browsers preferences especially.

  • How to provision all assignments in OK status to backend(ABAP, JAVA)

    Hi Experts,
    SAP IDM 7.2, SP8
    Sometimes due to inconsistencies, users have assignments (inherited privileges (part of role)) with OK status in IDM but missing in backend systems.
    Question 1: Is there any standard way to provision such user's all assignments (with OK status)?
    1. I have tried uIS_RepairEntry internal function but it does not touch assignments in OK status if there are no structural changes required.
    2. uPrivReconcile only reconcile failed/declined assignments.
    3. I have tried uIS_SetDirty internal function but it does not trigger any assignment which is in OK status.
    Infact it says that If an MX_PERSON entry is set dirty, this entry is marked dirty and all assignments will be reconciled but assignments in OK status are not provisioned.
    Question 2: What does "all assignments will be reconciled" means here if it does not provision all assignments in OK status (mcExecState = 0 or 1).
    4. I have created a job and created a script to use uProvision internal function to implement logic to trigger hook task 4 of repo(ABAP/JAVA) for the user.
    for ABAP it works fine but for JAVA repo ,  stored procedure “mxpt_get_privilege_type” checks for audit id and pending privilege mskey and so check fails.
    so, executing task  “SetJavaRoleForUser&Group” directly via script works fine.
    Question 3:
    I am interested to know if anyone has implemented anything better than this (point 4) to provision all assignments (with OK status) of user from IDM to backend system.
    Kindly assist.
    Thanks a lot in advance.
    Regards,
    Pradeep

    Thanks for posting this Pradeep. I was also looking for solution for the same issue.
    Hi Siarhei,
    I did IDM support for 2 customers and both had this issue and we resolved by re-adding the roles to the user. Its a cumbersome process as we have to remove the role, wait for de-provisioning tasks finish for all corresponding repositories and then add it back. If the user has only one role in IDM and removing them triggers user deletion in back-end which is a nightmare for support consultants and we have to answer alot of audit questions for manual operation on a user in a fully automated landscape (Priv:$rep:only can be added to avoid user deletion but the visibility was not allowed for us as it was considered as internal IDM system privilege).
    Currently in my new assignment, we have no change access in production. Hence we cannot re-add the access. so we need to develop a solution for this issue before we go-live fully. Pradeep's 4th point is a good starting point for us.
    Kind regards,
    Jaisuryan

  • Is there any java programming tool/editor available??

    I am new to java and need to do my class work. I need an editor/programming tool for writing, editing and compiling java applications. I have been suggested TextPad. But is there anything more advanced and sophisticated available than TextPad. I heard name eclipse many times. Do they make something regarding this??
    Thanks for help.

    SoulTech2012 wrote:
    nclow wrote:
    BigDaddyLoveHandles wrote:
    Eclipse and Netbeans are two popular free IDEs. Many would argue that as a beginner, you should concentrate on the Java language itself and stick with TextPad.
    I started out learning C with vi and emacs, and I turned out okay.I did almost all of my programming schoolwork in college using pico/nano over telnet/ssh. The good ol' days...Good?! I'll take Eclipse over vi any day ;-)
    I still have nightmares!!!Heretic. Burn him!
    VI4Ever! It Eclipses Eclipse.

Maybe you are looking for

  • How to permanently connect to a minimal without being on the same network?

    I'm trying to connect my mini-mac to my mac book pro permanently so that they will appear in each other's finders even when they are not on the same network. I've done it before but I can't remember how I did it. Help?

  • Clicking noise from Ac adaptor while charging using 600W inverter

    I am trying to charge my laptop from a 12 volt battery through a 600w inverter. However the latop won't charge and the charger just makes a clicking noise. Does any one know why this is? And can anyone help me?

  • Producer not found error message

    We getting a JMSException "Producer not found" when we attempt to send a message to a JMS distributed queue.           We configuration involves setting up a cluster wide distributed queue with JMS Servers on every node in our cluster for failover an

  • Video Conferencing: Client - Server - Client(s)

    I need a solution or idea for : A Client who has webcam stream his/her webcam, not to indvidual clients using multicast tech. it only sends stream to server. and the Users who want to see his/her webcam fetch the webcam from the server. In this techn

  • SAP CRM to MS Access Interface

    I have a CRM to MS Access Interface that I have to set up. Has anyone set that up before and if so; How was it done? Any documentation on that?