Try catch problem

Here's my code:
import javax.swing.*;
import java.io.*;
public class Customer
     try
          public RandomAccessFile file = new RandomAccessFile("customer.txt", "rw");
     catch(FileNotFoundException fnfe)
     public static void readCustomer(String telp)
     public static void writeCustomer(String telp, String name, String add1, String add2)
and here's the error msg:
C:\TEMP\Tar\TestOrder\Customer.java:7: illegal start of type
     try
^
C:\TEMP\Tar\TestOrder\Customer.java:20: <identifier> expected
^
2 errors
Tool completed with exit code 1
Can anyone pls tell what i did wrong? btw, i used TextPad to compile it
Thanks
Daffy

hi,
try and catch should be in a method.
try this
public class Customer
public RandomAccessFile {
     try
file = new RandomAccessFile("customer.txt", "rw");
     catch(FileNotFoundException fnfe)

Similar Messages

  • Try  Catch problem CS6

    All my try catch scripts don't work on CS6
    $.strict = false;
    function myGetScriptPath() {
    try{
    return app.activeScript;
    catch(myError){
    return File(myError.fileName);
    myGetScriptPath()
    Can anyone tell me the problem?
    Thanks
    Trevor

    Thanks for trying Pickory,
    I have Windows 7, with both indesign CS5 and creative cloud CS6 installed
    After experimenting I found that the script works fine on the machine with just CS5 on it.
    But on the one that has both doesn't work when called from either version of the ESTK but does from either version of indesign.
    When I try run the script from the CS5 ESTK It automatically opens and runs from the CS6 ESTK.
    I am not keen on uninstalling the CS5 ESTK as I don't know how long I'll keep creative cloud.
    Bellow is a alternative try catch script because the above one will not invoke an error if run from indesign so it won't call the catch.
    cs = app.activeDocument.characterStyles.item("myCharacterStyleName");
    try {alert ("Try $.strict = " +$.strict); myCharacterStyle.name}
    catch (myError) { alert ("Catch $.strict = " +$.strict + "\r" + myError)}
    I'm quite desperate for an answer.

  • Try catch problem in a while loop

    I have computerGuess set to -1 and that starts the while loop.
    but I need to catch exceptions that the user doesnt enter a string or anything other than a number between 1 and 1000.
    but computerGuess is an int so that the while loop will start and I wanted to reset computerGuess from the user input using nextInt().
    The problem is if I want to catch exceptions I have to take a string and parse it.
    import java.util.Scanner;
    public class Game {
         //initiate variables
         String computerStart = "yes";
         String correct = "correct";
         String playerStart = "no";
         int computerGuess = 500;
    public void Start()
         //setup scanner
         Scanner input = new Scanner(System.in);
         int number = (int)(Math.random()*1001);
         System.out.println(welcome());
         String firstAnswer = input.nextLine();
         if(firstAnswer.equalsIgnoreCase(computerStart)== true)
              System.out.println(computerGuess());
              //while (userAnswer.equalsIgnoreCase(correct) == false){
                   System.out.println();
         if(firstAnswer.equalsIgnoreCase(playerStart) == true)
              long startTime = System.currentTimeMillis();
              int currentGuess = -1;
              while (currentGuess != number){
              System.out.println(playerGuess());
              String guess = input.next();
              //currentGuess = Integer.parseInt(guess);
              if (currentGuess < number)
                   System.out.println("too low");
              if (currentGuess > number)
                   System.out.println("too high");
              if (currentGuess == number)
                   long endTime = System.currentTimeMillis();
                   System.out.println("Well done, the number is " + number);
              int i = -1;
              try {
                i = Integer.parseInt(guess);
                   } catch (NumberFormatException nfe) {
                        //System.out.println("Incorrect input, please try again.");
              if ( i < 0 || i > 1000 ) {
                   System.out.println("Incorrect input, please try again.");
         private String computerGuess()
               String comGuess = ("The computer will guess your number.\n" +
                        "Please enter \"too high\", \"too low\" or \"correct\" accordingly.");
               return comGuess;
         private String welcome()
              String gameWelcome = "Welcome to the guessing game \n" +
                                        "The objective is to guess a number between 1 and 1000.\n" +
                                        "You can guess the computer's number or it can guess your's.\n" +
                                        "You may enter \"quit\" at any time to exit.\n" +
                                        "Would you like the computer to do the guessing?";
              return gameWelcome;
         private String playerGuess()
              String playerWillGuess = "Guess a number between 1 and 1000.";
              return playerWillGuess;
    }The catch works , but because computerGuess is int -1 so that the while loop will run, I cannot use the input to change computerGuess because it is a string.

    the i was a mistake. and i commented on the other code, because it wasnt working at that moment. I need help understanding the try catch method.
    I want to catch any input that isn't an integer , and I would also like to catch any input that isn't a string at other parts of my program.

  • Return statement and Try Catch problem

    Hi!!
    I've got the next code:
    public ResultSet DBSelectTeam(String query) {
    try {
    Statement s = con.createStatement();
    ResultSet rs = s.executeQuery(query);
    return rs;
    } catch (Exception err) {
    JOptionPane.showMessageDialog(null, "ERROR: " + err);
    But I need a return statement in the catch-block, but I don't know what's the best option.
    Help...
    Many thanks.

    The error message is: "missing return statement", Yes, I know.
    You have to either return from the catch statement, or throw from the catch statement, or return or throw after the catch statement.
    The only ways your method is allowed to complete is by returning a value or throwing an exception. As it stands, if an exception is thrown, you catch it, but then you don't throw anything and you don't return a value.
    So, like I said: What would you return from within or after catch? There's no good value to return. The only remotely reasonable choice would be null, but that sucks because now the caller has to explicitly check for it.
    So we conclude that catch shouldn't return anything. So catch must throw something. But what? You could wrap the SQLE in your own exception, but since the caller is dealing with JDBC constructs anyway (he has to handle the RS and close it and the Statement), there's no point in abstracting JDBC away. Plus he has to deal with SQLE anyway in his use of the RS and Statement. So you might as well just throw SQLE.
    So since you're going to just throw SQLE anyway, just get rid of the try/catch altogether and declare your method throws SQLException

  • Plugin and try/catch problem

    I have a plug-in that was working perfectly until I added an FileOutputStream and its corresponding try/catch block. Now when I try to run my plugin, the popup menu come up corrctly but when I click to run my code it tells me the operation is not available. If I delete those three line it works fine again.
    Instead or try/catch I could do run() throws XYZException, but that gives an error. Any ideas how I can get this fixed? Thanks

    turns out that was not really what was causing the error. I was using the iText library, and I had added it to the classpath of the plugin but I didnt add it to the runtime classpath, so my 'new' eclipse windows was not working properly. Thanks anyways

  • A try catch problem....

    public class trycatch{
    public static void main(String[] adsf){
    int i;
    try{i = 5;}
    catch(Exception e){}
    System.out.println("hello"+i);
    }at compile time, the compiler says i might not have been initialised, but why?
    I have done it in try catch block.

    do you people have any better idea rather than put
    all the codes in one try catch block?Yes.
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.InputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    public class Test{
           public static void main(String[] param){
                  if(param.length!=4)
                  System.out.println("please provide 4 attributes: protocol, host, port, and file");
                  URL resource = null;
                  try{resource = new URL(param[0], param[1], Integer.parseInt(param[2]), param[3]);}
                  catch(MalformedURLException murle){System.out.println("an murle occurs");return;}
                  InputStream openResource = null;
                  try{openResource = resource.openStream();}
                  catch(IOException ioe){System.out.println("an ioe occurs");return;}
                  FileOutputStream toFile = null;
                  try{toFile = new FileOutputStream(param[3]);}
                  catch(FileNotFoundException fnfe){System.out.println("an fnfe occurs");return;}
                  try{
                  for(int i = openResource.read(); i!=-1; i = openResource.read())
                  toFile.write(i);
                  catch(IOException ioe){System.out.println("an ioe occurs");}
    }Notice the initialization. That will now at least compile. And before you get your knickers in a knot the return statements are there for terminiating execution of the method (in this case program) when an error occurs.

  • Some code error-try catch problem

    import java.io.*;
    import java.sql.*;
    public class login1 extends HttpServlet
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException
    PrintWriter pw = res.getWriter();
    res.setContentType("text/html");
    String uid=(String)req.getParameter("formtext1");
    String pass=(String)req.getParameter("formtext2");
    Connection c;
    Statement s;
    ResultSet rs;
    ResultSetMetaData meta;
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    c = DriverManager.getConnection("jdbc:mysql://localhost:3306/projectmanager?username=\"root\"&password=\"\"", "", "");
    s = c.createStatement();
    s.execute("select * from login order by userid ");
    rs = s.getResultSet();
    while(rs.next())
    if(uid.equals(rs.getString(1)) && pass.equals(rs.getString(2)))
         HttpSession ses=req.getSession(true);
    ses.putValue("a",uid);
    res.sendRedirect("welcome");
    catch(Exception e){
    {pw.println(e);}
         res.sendRedirect("login");}
    this page on getting exception is not directing to login again...could any1 help me out plzz.....

    What is it doing otherwise? Try putting a "return;" after the sendRedirect(). Also for future posts, put your code inside the "code" tags so its easier to read.

  • Problem with a Try/catch exception

    Hello everyone here on the forums. I'm brand new to Java and have a bit of a problem with a try catch statement I'm making. In the following code if a user enters a non-integer number the program will display "Sorry, incompatible data." Problem is it gets caught in a loop and continues to display "Sorry, incompatible data." My aim with the try catch was if the user is not quite smart enough to understand quadratic programs don't use symbols and characters it would state it isn't correct and continue running the program.
    Heres my code thus far:
    package finishedquadraticprogram;
    import java.util.*;
    * @author Matt
    public class quad {
         * @param args the command line arguments
        public static void main(String[] args) {
            boolean verification = true;
            double a, b, c, root1, root2, discriminant;
            Scanner keyInput = new Scanner(System.in);
            while ( verification)
            try
            System.out.println("a: ");
            a = keyInput.nextDouble();
            System.out.println("b: ");
            b = keyInput.nextDouble();
            System.out.println("c: ");
            c = keyInput.nextDouble();
            discriminant = Math.sqrt(b * b - 4 * a * c);
            root1 = (-b + discriminant) / 2 * a;
            root2 = (-b - discriminant) / 2 * a;
            verification = false;
            System.out.println("Root 1 = " +root1+ "\nRoot 2 = " +root2);
            } //try
            catch  (InputMismatchException iMe)
              System.out.println( "Sorry. incompatible data." );  
    }I'm pretty sure the problem is something to do with the keyboard buffer, but I'm not sure what I need to do to either reset it or clear it, whichever one works. (Oh, and how would I go about making the program use complex numbers? I realize Java can't use complex numbers and will just display NaN ... any ideas how to make this work?)
    Thanks a lot for all of your help guys, it's appreciated.

    this is better:
    package finishedquadraticprogram;
    import java.util.*;
    /** @author Matt */
    public class quad
       private static final double TOLERANCE = 1.0e-9;
       /** @param args the command line arguments */
       public static void main(String[] args)
          boolean verification = true;
          double a, b, c, root1, root2, discriminant;
          Scanner keyInput = new Scanner(System.in);
          while (verification)
             try
                System.out.println("a: ");
                a = keyInput.nextDouble();
                System.out.println("b: ");
                b = keyInput.nextDouble();
                System.out.println("c: ");
                c = keyInput.nextDouble();
                discriminant = Math.sqrt(b * b - 4 * a * c);
                if (Math.abs(a) < TOLERANCE)
                   root1 = 0.0;
                   root2 = -c/b;
                else
                   root1 = (-b + discriminant) / (2 * a);
                   root2 = (-b - discriminant) / (2 * a);
                verification = false;
                System.out.println("Root 1 = " + root1 + "\nRoot 2 = " + root2);
             } //try
             catch (InputMismatchException iMe)
                System.out.println("Sorry. incompatible data.");
                keyInput.next();
    }

  • BufferedWriter try catch Scoping problem

    I developed a quick and dirty application to search through a file system for files that contain certain patterns in their names, and it works fine. My problem is I want to use a BufferedWriter to write the results out to a new text file, and a buffered writer must be enclosed in a try catch statement because of a possible IOException. Now the writer is out of scope of the method that needs to call it, and if I put it in the method a new writer and hence a new file will be created each time through. I am sure this is just a design flaw on my part but I have hit this problem before, I was wondering what is a way around this, so the writer can be instantiated, the method that will do that actual writing to the file will be called until the iteration is done, and then the program will exit.
    Here is my code, there are some unused variables and objects in there, namely I am not using the BufferedWriter at the moment and was just cutting and pasting from the console:
    Thanks!
    import java.io.*;
    import java.util.*;
    public class NextAttempt {
         static List<File> filelist = new ArrayList<File>();
         static PrintStream out = new PrintStream(System.out);
         static File f;
         public static void getWriter() {
              try {
                   BufferedWriter writer = new BufferedWriter(new FileWriter("C:\\FILE.txt"));
                        for(File f: filelist)
                             writer.append(f.getAbsolutePath());
              catch (Exception e) {}
         public static List<File> browse(File BASE) {
              File[] temp=BASE.listFiles();
                   for (int i=0;i<temp.length;i++) {
                        if(temp.getAbsolutePath().contains(File.separator+"PATTERN")&&temp[i].getName().contains(".ext") {     
                             out.println(temp[i].getAbsolutePath());
                             //filelist.add(temp[i]);
                        else if (temp[i].isDirectory()) {
                                  BASE=temp[i];
                                  rec(BASE);
                        else {
                             BASE=new File("PATH");
              return filelist;
         public static void rec(File BASE) {
              browse(BASE);
         public static void main(String[] args) {
              browse(new File("PATH"));
              out.println("Complete");

    Also you can keep passing the file lists up to the callers, so the initial invocation of browse() will return a list of all the files. When you recurse (which you're doing now, apparently), you can append the return value of the recursive call to the caller's own list of files.
    Then just print the whole list when you're done.
    Another thing you might want to think about... you could use the logging framework to list the files as log entries. That may or may not be useful. The advantage is that the logging code already deals with some of these issues; the disadvantage is that producing a formatted log might result in a format you can't use, or tweaking the format might be more trouble than doing something else.

  • Try-catch statment problems

    I'm trying to understand the try-catch statements. I'm trying to verify that a number entered is only within a range of 1-3, otherwise get the input again. But I'm not grasping the try-catch statements very well, and my code isn't working correctly. It seems to just by pass the catch statement completely. Any idea on what I'm doing wrong with this?
              try {
                   System.out.println("Enter the test number");
                   testNumb = scan.nextInt();
                   if(testNumb < 1 && testNumb > 3){
                        throw new Exception("Test Number not valid");
              catch(Exception e){
                   System.out.println(e + "please enter a valid test (number between 1-3)\nEnter the test number");
                   testNumb = scan.nextInt();
              }

    I don't understand why its still crashing, when it should catch the InputMismatchException, and run the code INSIDE of the exception, which asks the user to enter the input again. It does ask the USER, but it still just crashes.
    I've changed the method around so it is more like what post #8 said. But its still crashing, I'm not sure if its something specific I dont understand, or what.
         public static int studentTest(){
              Scanner scan = new Scanner(System.in);
              boolean acceptable = false;
                   while(!acceptable){
                        try {
                             System.out.println("Enter the test number");
                             testNumb = scan.nextInt();
                        catch(InputMismatchException ioe){
                             System.out.println("Test Number not valid, please enter a valid test (number between 1-3)\nEnter the test number");
                             testNumb = scan.nextInt();
                        if(testNumb < 1 || testNumb > 3){
                             System.out.println("Test Number not valid, please enter a valid test (number between 1-3)\nEnter the test number");
                             testNumb = scan.nextInt();
                        } else {
                             acceptable = true;
                   return testNumb;
         }

  • Can't find class because of try catch block ?!

    Hello,
    I'm using the JNI to use a java library from my c++ code.
    JNI can't find the "Comverse10" class below, but when i put the try catch block in createMessage in comment, FindClass succeeds ?!
    Unfortunatly i need the code inside the try block ;-)
    I tried a few things, but none of them worked:
    - let createMessage throw the exception (public void createMessage throws ElementAlreadyExistsException ), so there isn't a try catch block in createMessage => result: the same
    - make a "wrapper" class Comverse that has a Comverse10 object as attribute and just calls the corresponding Comverse10.function. Result: Comvers could be found, but not constructed (NewObject failed).
    Can someone tell me what is going on ?!
    Thank you,
    Pieter.
    //Comverse10 class
    public class Comverse10 {
    MultimediaMessage message;
    /** Creates a new instance of Comverse10 */
    public Comverse10() {
    public void createMessage() {
    TextMediaElement text1 = new TextMediaElement("Pieter");
    text1.setColor(Color.blue);
    SimpleSlide slide1 = new SimpleSlide();
    //if i put this try catch block in comment, it works ?!
    try{
    slide1.add(text1);
    catch(com.comverse.mms.mmspade.api.ElementAlreadyExistsException e){}
    MessageContent content = new MessageContent();
    content.addSlide(slide1);
    this.message = new MultimediaMessage();
    message.setContent(content);
    message.setSubject("Mijn subjectje");
    for those of you who are intersted: here's my C++ code:
    //creation of JVM
    HRESULT Java::CreateJavaVMdll()
         HRESULT HRv = S_OK;
    char classpath[1024];
         jint res;
         if(blog)     this->oDebugLog->Printf("CreateJavaVMdll()");
         strcpy(classpath,"-Djava.class.path="); /*This tells jvm that it is getting the class path*/
         strcat(classpath,getenv("PATH"));
         strcat(classpath,";D:\\Projects\\RingRing\\MMSComposer;C:\\Progra~1\\j2sdk1~1.1_0\\lib");     //;C:\\Comverse\\MMS_SDK\\SDK\\lib\\mail.jar;C:\\Comverse\\MMS_SDK\\SDK\\lib\\activation.jar;C:\\Comverse\\MMS_SDK\\SDK\\lib\\mmspade.jar
         //------Set Options for virtual machine
         options[0].optionString = "-Djava.compiler=NONE"; //JIT compiler
         options[1].optionString = classpath;                                        //CLASSPATH
         //------Set argument structure components
         vm_args.options = options;
         vm_args.nOptions = 2;
         vm_args.ignoreUnrecognized = JNI_TRUE;
         vm_args.version = JNI_VERSION_1_4;
         /* Win32 version */
         HINSTANCE hVM = LoadLibrary("C:\\Program Files\\j2sdk1.4.1_01\\jre\\bin\\client\\jvm.dll");
         if (hVM == NULL){
              if(blog) oDebugLog->Printf("Can't load jvm.dll");
              return E_FAIL;
         if(blog) oDebugLog->Printf("jvm.dll loaded\n");
         LPFNDLLFUNC1 func = (LPFNDLLFUNC1)GetProcAddress(hVM, "JNI_CreateJavaVM");
         if(!func){
              if(blog)     oDebugLog->Printf("Can't get ProcAddress of JNI_CreateJavaVM");
              FreeLibrary(hVM);     hVM = NULL;
              return E_FAIL;
         if(blog)     oDebugLog->Printf("ProcAddress found");
         res = func(&jvm,(void**)&env,&vm_args);
         if (res < 0) {
    if(blog)     oDebugLog->Printf("Can't create JVM with JNI_CreateJavaVM %d\n",res);
    return E_FAIL;
         if(blog)     oDebugLog->Printf("JVM created");
         return HRv;
    //finding Comverse10 class:
    HRESULT CALLAS MMSComposer::InitializeJNI(void)
         HRESULT HRv=E_FAIL;
         DWORD T=0;
         try
              if(blog)     oDebugLog->Printf("\nInitializeJNI()");
              bJVM = FALSE;
              jni = new Java(oDebugLog);
              if(jni->CreateJavaVMdll()!=S_OK){
                   if(blog)     oDebugLog->Printf("CreateJavaVMdll() failed");     
                   return HRv;
              jclass jcls = jni->env->FindClass("Comverse10");
              if (jcls == 0) {
    if(blog)     oDebugLog->Printf("Can't find Comverse10 class");
                   jclass jcls2 = jni->env->FindClass("test");
                   if (jcls2 == 0) {
                        if(blog)     oDebugLog->Printf("Can't find test class");
                        return HRv;
                   if(blog)     oDebugLog->Printf("test class found %08x",jcls2);
    return HRv;
              if(blog)     oDebugLog->Printf("Comverse10 class found %08x",jcls);
              jmethodID mid = jni->env->GetMethodID(jcls , "<init>", "()V");
              if (mid == 0) {
                   if(blog)     oDebugLog->Printf("Can't find Comverse10() constructor");
    return HRv;
              if(blog)     oDebugLog->Printf("Comverse10() constructor found");
              jobject jobj = jni->env->NewObject(jcls,mid);
              if(jobj==0)
                   if(blog)     oDebugLog->Printf("Can't construct a Comverse10 object");
    return HRv;
              if(blog)     oDebugLog->Printf("Comverse10 object constucted");
              //Create Global reference, so java garbage collector won't delete it
              jni->jobj_comv = jni->env->NewGlobalRef(jobj);
              if(jni->jobj_comv==0)
                   if(blog)     oDebugLog->Printf("Can't create global reference to Comverse10 object");
    return HRv;
              if(blog)     oDebugLog->Printf("global reference to Comverse10 object %08x created",jni->jobj_comv);
              bJVM=TRUE;
              HRv=S_OK;
         }     catch( IDB * bgError ) { throw bgError->ErrorTrace("InitializeJNI::~InitializeJNI",HRv, 0, T); }
              catch(...) { throw IDB::NewErrorTrace("InitializeJNI::~InitializeJNI",HRv, 0, T ); }
              return HRv;

    >
    I would guess that the real problem is that that the
    exception you are catching is not in the class path
    that you are defining.Thanks jschell, that was indeed the case.
    I don't have the docs, but I would guess that
    FindClass() only returns null if an exception is
    thrown. And you are not checking for the exception.
    Which would tell you the problem.Ok, i'll remember that. But what with exceptions thrown in my java code, the documents say
    // jthrowable ExceptionOccurred(JNIEnv *env);
    // Determines if an exception is being thrown. The exception stays being thrown until either the native code calls ExceptionClear(), or the Java code handles the exception
    so, what if the java code throws an exception and catches it, will i be able to see that in my c++ code with ExceptionOccurred ?
    or
    should the java method be declared to throw the exception (and not catch it inside the method)
    Again, thank you for your help, it's greatly appreciated !

  • Exception handling with try/catch in acrobat

    Hi
    I have a problem using a try/catch block in my acrobat document-script. Try to enter the following into the debugger-console:
    try{nonexistentFunction();}catch(e){console.println('\nacrobat can't catch')}
    and run it. The output will be:
    nonexistentFunction is not defined
    1:Console:Exec
    acrobat can't catch
    true
    The whole point of a rty/catch block is for the application  NOT to throw an exception, but instead execute the catch-part of the  statement. However, acrobat does both: It throws an exception AND  executes the catch-block.
    Is there another way to suppress the exception, or to make the try/catch-block work as it's supposed to?

    > Also Adobe provides for free the JS or compiled file for Acrobat Reader to support the JS console.
    Where is that file located ? How to install it or where to place it ?
    What is the method referred by try67 on his site where he sells a product ?
    Is that the same as the compiled file you refer to ? or did he sell his solution to adobe ?
    It is helpful if people can get an idea of the nature of choices available and make informed decisions, than a cloak and dagger approach.
    For some jobs that we have, I have been very frustrated by a consultant who wont even give basic info for transparent billing despite all assurances for privacy, as a result we are forced to do the job ourselves.
    Dying Vet

  • Catch problem for JSPs, can't i use Oracle9iAS for our  Application ?

    Hi,
    I have deployed .ear file by using OC4J. I am facing catch problem, in defferent situations.
    1. We used pager tag library for search nagivation, it is not working proper.
    2. 'Creation of new object(in my case enterprise,certificate,role etc.)' is not working
    properly. What ever i try to create it is giving Error in
    TrainiumPKCallBean :javax.ejb.DuplicateKeyException: Entity already exists
    3. And some of my pages not giving proper results, but if i edit that .jsp file, then it
    gives correct request for that time. If i want correct result, then again i have to edit and
    save that page.
    I belive all the above problems are coming due to catch.
    If this problem continues, we can't use Oralce9iAs.
    please give me solution..
    thanks in advance
    srinivas.

    Hi Srinivas,
    I must admit, I had difficulty understanding your question. With your
    permission, I'll try and rephrase it. Hopefully I have understood it
    correctly, and can offer something constructive.
    I assume that "TrainiumPKCallBean" is a CMP entity bean. You are invoking
    the "create()" method in that bean's home interface from your JSP, correct?
    When you invoke the "create()" method of a CMP entity bean's home interface,
    OC4J will try and insert a row into the relevant database table(s).
    A "DuplicateKeyException" means that OC4J is trying to insert a row
    that has a primary key of an already existing row in the database
    table. The only way to avoid the "DuplicateKeyException" is either
    try to use a different primary key value, or delete the row from the
    database table with the primary key that you are trying to insert.
    So I suppose that by editing the JSP, you are changing the primary
    key value to something that doesn't already exist in the database.
    Unfortunately, based on the (lack of) information you have supplied,
    I can't offer anything else -- sorry {:-(
    If you wouldn't mind supplying the following information -- it may
    help me to help you solve your problem(s).
    1. Version of OC4J
    2. JDK version
    3. Operating system
    4. Complete error message and stack trace
    5. Part(s) of the code that are causing the problem
    Good Luck,
    Avi.

  • Compile time errors for large code in try-catch blocks

    Hi, Has anyone ever faced this problem of a compile time error, where the Java compiler returns with the following error that Code is too large for try block.
    I have about 5000 thousand lines in my try-catch block and am facing this problem. Please suggest possible solutions

    1) Are you sure that your try/catch blocks contain 5 million lines?! I seriously don't believe this.Sounds like generated code. The generator needs to be a bit cleverer. In particular, it seems to be generating repeated blocks of code that ought to be stuffed into methods somewhere.

  • Try catch trouble

    hi all, im quite new to java and am having a bit of trouble with a try catch statement
    try
              System.out.println("Enter your level: ");
              level = data.nextInt();
              while (!VLevel(level))
         System.out.println("Enter your level: ", LEVEL);
                   dstfloor = read_in.nextInt();
              catch(InputMismatchException exception)
    System.err.println("Invalid level");
    continue;
    the problem i have is that when it triggers the exception, it just repeats the 'invalid level' line infinitely. any ideas?
    thanks

    If this line is causing an exception: dstfloor = read_in.nextInt();Then dstfloor's value will not change.
    Because you are using continue in the catch, the loop will run unfinately with dstfloor having the same value.
    You will need to modify the dstfloor var either in the catch or in the finally.
    Edited by: Azzer_Mac on Apr 24, 2008 9:08 AM

Maybe you are looking for

  • 1394 net adapter not working in device manager

    I,m running the KT4 Ultra  with fire wire on board with XP prof. Every thing is working fine except in device manager I have two listings for the 1394 net adapter.The first has the yellow explantion mark, Code ten."this device won't start. And the se

  • Multidimensional array with start-job

    Hi! I'm trying to improve a script that will read in a CSV file to an array, divide it up to 4 chunks. So I will have 4 arrays and inside each array I have properties for computername, ip addresses and so forth. ($arrComputers[0][56].ComputerName) So

  • Missing MS documents after install Office 2008

    Hello I am running MAC OX 10.6 and just re-intalled Office 2008.  Prior to this I had to have my OS re-installed by Apple.  I can see all my document folders in FINDER however all folders are empty

  • Bash update stuck on gray screen

    I received a notification to install the new bash update for Mavericks. I clicked the button and the install process began by rebooting my laptop to a light gray screen with nothing but the cursor. The software update did warn that it would reboot to

  • Unix and XI...Query

    Hi, I just want to know how I can Interface with an Unix System. The Business Case is that there is a Unix system which captures some Inventory data and then at the end of Half day they Download the data in EXCEL and do a BDC upload...   How can XI b