Error on Try statement

I receive a message 'Illegal start of type' on the first Try statement when compiling the following code. I'd appreciate any ideas on why this error occurs.
import java.util.*;
import java.sql.*;
import java.io.*;
import java.lang.*;
public class VPAsql {   
String fieldValue;
Connection connection = null;
VPAsql() {
//public static void main(String args[]) {
try {   
String driverName = "COM.ibm.db2.jdbc.app.DB2Driver";
Class.forName(driverName);
String url = "jdbc:db2:SAMPLE";
String username = "db2admin";
String password = "password";
connection = DriverManager.getConnection(url, username,
password);
} catch (ClassNotFoundException e) {
System.err.println("Driver not found");
} catch (SQLException e) {
System.err.println("Could not connect");
System.err.println(connection);
insertSampleTable(String passedFieldValue){
this.fieldValue = passedFieldvalue;
try {
Statement stmt = connection.createStatement();
String sql = "INSERT INTO SAMPLE.PNVPA(PONUMBER) VALUES
(passedFieldvalue)";
stmt.executeUpdate(sql);
} catch (SQLException e) {
}

Uncomment the main method (or put another method with right signature there)

Similar Messages

  • Syntax error using try statement in WLST

    Hi All,
    I have a WLST script to create some JMS resources.
    I want to implement exception handling in such a way that if the script fails at any point, all the changes done should be reverted back.
    However, whenever I am trying to put a try block, the script is throwing syntax error on the first line after the try statement.
    Please find below the script I am using. Please suggest
    import sys
    from java.lang import System
    *# Putting a try statement here results in a syntax error at the below line*
    print "Starting the script ..."
    connect('weblogic',password,'t3://osbdev:7001')
    edit()
    startEdit()
    servermb=getMBean("Servers/osb_server")
    if servermb is None:
    print 'Value is Null'
    else:
    +# Creating the JMS Server+
    jmsserver1mb = create('WLSTJMSServer','JMSServer')
    jmsserver1mb.addTarget(servermb)
    +# Creating the JMS Module+
    jmsMySystemResource = create("WLSTJmsSystemResource","JMSSystemResource")
    jmsMySystemResource.addTarget(servermb)
    subDep1mb = jmsMySystemResource .createSubDeployment('WLSTJMSSubDeployment')
    subDep1mb.addTarget(jmsserver1mb)
    theJMSResource = jmsMySystemResource.getJMSResource()
    connfact1 = theJMSResource.createConnectionFactory('WLSTConnFact1')
    connfact1.setJNDIName('jms.WLSTConnFact1')
    connfact1.setSubDeploymentName('WLSTJMSSubDeployment')
    print "Creating WLSTQueue1..."
    jmsqueue1 = theJMSResource.createQueue('WLSTJMSQueue1')
    jmsqueue1.setJNDIName('jms.WLSTJMSQueue1')
    jmsqueue1.setSubDeploymentName('WLSTJMSSubDeployment')
    print "Creating WLSTQueue2..."
    jmsqueue2 = theJMSResource.createQueue('WLSTJMSQueue2')
    jmsqueue2.setJNDIName('jms.WLSTJMSQueue2')
    jmsqueue2.setSubDeploymentName('WLSTJMSSubDeployment')
    *# try statement is working at only this point of the program*
    try:
    save()
    activate(block="true")
    print "script returns SUCCESS"
    except:
    save()
    cancelEdit(defaultAnswer="y")
    print "Error while trying to connect to server !!!"
    print "Unexpected error: ", sys.exc_info()[0]
    dumpStack()
    raise
    Edited by: Chintan Parekh on Mar 16, 2011 7:06 AM

    Hi Chintan,
    Try doing copy pasting the below code, you have to hit the tab or space after try or except to create its block and keep an eye on the alinement's of it.
    try:
         save()
         activate(block="true")
         print "script returns SUCCESS"
    except:
         save()
         cancelEdit(defaultAnswer="y")
         print "Error while trying to connect to server !!!"
         print "Unexpected error: ", sys.exc_info()[0]
         dumpStack()Also I made the alinement's properly and the script is running properly with out any error.
    print "Starting the script ..."
    connect('weblogic','weblogic','t3://localhost:7001')
    edit()
    startEdit()
    servermb=getMBean("Servers/AdminServer")
    if servermb is None:
         print 'Value is Null'
    else:
         # Creating the JMS Server
         jmsserver1mb = create('WLSTJMSServer','JMSServer')
         jmsserver1mb.addTarget(servermb)
         # Creating the JMS Module
         jmsMySystemResource = create("WLSTJmsSystemResource","JMSSystemResource")
         jmsMySystemResource.addTarget(servermb)
         subDep1mb = jmsMySystemResource .createSubDeployment('WLSTJMSSubDeployment')
         subDep1mb.addTarget(jmsserver1mb)
         theJMSResource = jmsMySystemResource.getJMSResource()
         connfact1 = theJMSResource.createConnectionFactory('WLSTConnFact1')
         connfact1.setJNDIName('jms.WLSTConnFact1')
         connfact1.setSubDeploymentName('WLSTJMSSubDeployment')
         print "Creating WLSTQueue1..."
         jmsqueue1 = theJMSResource.createQueue('WLSTJMSQueue1')
         jmsqueue1.setJNDIName('jms.WLSTJMSQueue1')
         jmsqueue1.setSubDeploymentName('WLSTJMSSubDeployment')
         print "Creating WLSTQueue2..."
         jmsqueue2 = theJMSResource.createQueue('WLSTJMSQueue2')
         jmsqueue2.setJNDIName('jms.WLSTJMSQueue2')
         jmsqueue2.setSubDeploymentName('WLSTJMSSubDeployment')
    # try statement is working at only this point of the program
    try:
         save()
         activate(block="true")
         print "script returns SUCCESS"
    except:
         save()
         cancelEdit(defaultAnswer="y")
         print "Error while trying to connect to server !!!"
         print "Unexpected error: ", sys.exc_info()[0]
         dumpStack()Below is the output
    java weblogic.WLST test.py
    Initializing WebLogic Scripting Tool (WLST) ...
    Welcome to WebLogic Server Administration Scripting Shell
    Type help() for help on available commands
    Starting the script ...
    Connecting to t3://localhost:7001 with userid weblogic ...
    Successfully connected to Admin Server 'AdminServer' that belongs to domain 'Domain_7001'.
    Warning: An insecure protocol was used to connect to the
    server. To ensure on-the-wire security, the SSL port or
    Admin port should be used instead.
    Location changed to edit tree. This is a writable tree with
    DomainMBean as the root. To make changes you will need to start
    an edit session via startEdit().
    For more help, use help(edit)
    You already have an edit session in progress and hence WLST will
    continue with your edit session.
    Starting an edit session ...
    Started edit session, please be sure to save and activate your
    changes once you are done.
    MBean type JMSServer with name WLSTJMSServer has been created successfully.
    MBean type JMSSystemResource with name WLSTJmsSystemResource has been created successfully.
    Creating WLSTQueue1...
    Creating WLSTQueue2...
    Saving all your changes ...
    Saved all your changes successfully.
    Activating all your changes, this may take a while ...
    The edit lock associated with this edit session is released
    once the activation is completed.
    Activation completed
    script returns SUCCESSRegards,
    Ravish Mody
    http://middlewaremagic.com/weblogic
    Come, Join Us and Experience The Magic…
    Edited by: Ravish Mody-MiddewareMagic on Mar 16, 2011 8:33 PM

  • When i try to download software for Ipad I get an error message that states "the network connection timed out".

    I need help download software for my Ipad. I get an error message that states "the network connection timed out"

    Disable or Turn off you firewall and and anti-virus software and try the download again.
    Stedman

  • 500 Internal Server Error OracleJSP: code too large for try statement catch

    We have an application which uses JSPs as front end and we are using Struts 1.1. When we run one of the JSP it shows the following error after executing .We are using OCJ4 server having version 9.0.4.0
    500 Internal Server Error
    OracleJSP: oracle.jsp.provider.JspCompileException:
    Errors compiling:E:\oracle\product\10.1.0\AS904\j2ee\home\application-deployments\VAS3006\vas\persistence\_pages\\_Requirement .java
    code too large for try statement catch( Throwable e) { 
    7194
    code too large for try statement catch( Exception clearException) { 
    44
    code too large for try statement try { 
    23
    code too large public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { 
    The JSP/application runs okay on one machine (System Tesing machine)with OCJ4 server having version10.1.2.0 but throughs an error on other machine( Development machine)with OCJ4 server having version9.0.4.0.The question is why it is running on one machine ane giving error on other machine I am aware that there can't be more than 64kB of code between try-catch block .Total size of the generated JSP class in our case is 577KB.
    Is the problem because of different version of Application server OC4J?.Is it any fix for this? Or Can anyone please suggest a work around. Or is there a method by which the JSP generated code is split between different try - catch blocks rather than a single try-catch block.Utlimately We don't know the whether is it a problem with JVM or hardware .
    It would be really helpful if you would provide me with some suggestion and input.
    Regards
    Shyam

    Sir,
    I am aware of the limitations of JVM that it won't allow java code more than 64Kb in method but we are using different versions of Application server .Application is working okay with OC4J application server(10.1.2.0) but gives error on Application server with version 9.0.4.0. Is this a problem with OC4J application server 9.0.4.0. I had gone through the documentation ofOC4J 9.0.4.0.application server but it does not mention about the this bug/fixes.
    Please giude me on the same.
    Regards,Shyam

  • Error in jsp:Code too large for try statement

    Hi friends,
    When i try to run a jsp program i am getting error "code too large for try statement". How can i rectify it rather than truncating that jsp? is there another way?
                                                  Basha

    Basha,
    When we were implenting an e-form component which was very big, the only way we were able to achieve it was by
    "jsp includes". In the main form simply included muliple
    jsp pages, where each was a section of the e-form.
    we have not found any other better way.
    Hope this helps.
    -Venkat Malempati
    Message was edited by: Venkat Malempati
    Message was edited by: Venkat Malempati

  • How do you avoid a code too large for try statement error message while com

    i have the jsp which is having 142 fields
    i am trying to dispaly 142 fields its showing the above error
    at runtime
    i think JVM is not allowing to complie the jsp
    please any body give me the solution for it

    I've got the same error with Weblogic 8.1 .
    When I tried to visit a JSP I wrote, which had many tags, the page showed the error: code too large for try statement.
    I'v reviewed a lot of discussions through the internet and solved the problem at last by adding one parameter to weblogic.xml.
      <jsp-descriptor>
         <jsp-param>
              <param-name>noTryBlocks</param-name>
              <param-value>true</param-value>
         </jsp-param>
      </jsp-descriptor>Hope this may help you out.

  • Error: code too large for try statement, when compiling a big java file.

    Hi,
    I have a big java file ( around 16000 lines). When compiling it, I got following error message:
    MyMain.java:15233: code too large for try statement
    } catch ( Throwable t ) {
    In MyMain.java, I just repeat following statements about 1000 times.
    try {
    if ( year >= 2002 ) {
    System.out.println( "year: Evaluation version is not valid" );
    } else {
    System.out.println( "year: Evaluation version is still valid" );
    } catch ( Throwable t ) {
    if ( year >= 2002 ) {
    System.out.println( "year: Evaluation version is not valid" );
    } else {
    System.out.println( "year: Evaluation version is still valid" );
    I tried 1.3 and 1.4 javac compiler, there was some error.
    How to make compiler to compile this code?
    Thanks,

    Hi,
    I have a big java file ( around 16000 lines). When
    compiling it, I got following error message:
    MyMain.java:15233: code too large for try statement
    } catch ( Throwable t ) {
    I tried 1.3 and 1.4 javac compiler, there was some
    error.
    How to make compiler to compile this code?
    You don't. Each method has an absolute limit on the number of byte codes. You have reached that limit. The limit is part of the specification and JVMs will refuse to run classes that exceed the limit. So even if you could compile it, it wouldn't run.
    It is quite common for code generators to generate large monolithic blocks of code. Presumably this is how you got to this spot. Modify the code generator to break it into smaller blocks.
    If you did it manually then you did it wrong. And you will have to manually break it into smaller blocks. (And re-examine your design since it is probably wrong.)

  • Javac(1.4.2) gives error in import statement

    Hi All,
    I am facing a surprising problem. I have 2 java class files. I write the import statement for second one in the first one. There is no package & these are in the same directory. I have compiled the second one. But when I try to compile the First one. Javac throws error at import statement like below :
    D:\Clubs\oct\6>javac -d . ManojTest.java
    ManojTest.java:1: '.' expected
    import SessionBean;
    ^
    1 error
    My Java Files are as below :
    import SessionBean;
    public class ManojTest
         public static void main(String args[])
    //ManojTest.java
    public class SessionBean
         public static void main(String args[])
    //SessionBean.java
    I have compiled SessionBean.java successfully but when I try to compile ManojTest.java I get error mentioned above.
    However this probelm comes when I use j2se 1.4.2.. but works in j2se 1.3.1..
    Another way could be I use package structure.
    But I can't do any of these, as I have to port my big project to j2se1.4.2.. from j2se1.3.1.. (Live project is running on Tomcat).
    Problems is similar in Unix & Windows both.
    Is this javac compiler issue or there is some setting which I can make.
    I have already included . (dot) in PATH & CLASSPATH environment varibales.
    Please help me out if there is any way around this, as i am stuck up in between
    thank you
    Manoj :confused:

    Use a package and then add that package in your classpathOr don't use a package, leave the file in the default (noname) package, and don't use the import statement. Java will find it in the default package without the import.
    Explicit import statements from the default package are no longer allowed

  • Getting error message that states itunesexe has been set to run in compatibilty mode for an older versions of windows for best results turn off compatibility mode for itunes before you open it .How do i turn off compatibility mode?

    recieved error message that states" itunes exe has been set to run in compatibility mode for an older versions of windows for best results turn off compatibility mode for itunes before you open it. How do i access compatibility mode and turn it off ? Believe i have Windows 7.

    Try the following document, only be sure that none of the boxes in the compatibility tab are checked (not just the compatibility mode box itself): 
    iTunes for Windows: How to turn off Compatibility Mode

  • I am trying to upgrade my PC iTunes to 10.6 iget an error message that states an older version of bonjour canot be removed contact your tech support group. Can someone help?

    I am trying to upgrade my PC to iTunes to 10.6 version, and i get an error message that states the older version of Bonjour cxanot be removed contact your support group. Can anyone help.

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any Bonjour entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another install. Does it go through this time?

  • Error processing request in sax parser: Error when executing statement...

    Hello,
    I want to INSERT data from R/3 System to AS400 via JDBC adapter into a DB2 database. The interfaces from R/3 are Ok. but i have some problems to use the JDBC in DB2 Systems. The message in comunitation channel is:
    " Error processing request in sax parser: Error when executing statement for table/stored proc. 'SPE106TST' (structure 'STATEMENT'): java.sql.SQLException: SPE106TST de SADMT1 no válido para la operación."
    in the SXMB_MONI -> Request Message Mapping payloads this:
    The connection to the database is fine, Sender adapter with a SELECT * works perfect.
    Please Can anyone help me solve this problem? I'm lost.
    Best regards,
    Edited by: Nicola Occhipinti on May 22, 2008 7:40 PM

    Hi Nicola,
    This error occurs when the receiver side structure is incorrect.
    Your structure seems to be correct.
    Please use lower case for action, access and table.
    Please check whether the field names are exactly the same as in the actual Database table sadmt1.SPE106TST.
    Check if the table has permissions to write.
    You can try an alternate structure without using table tag.
    <ns0:MT_XMLSQL_SPEC xmlns:ns0="urn:damm.com/pi/EmployeeMasterData">
    <STATEMENT>
    <sadmt1.SPE106TST action="INSERT">
    <access>
    <CODEMP>D</CODEMP>
    <CODPRO>00202339</CODPRO>
    <NOMPRO>ROSIQUE PERALSGENIS</NOMPRO>
    <DIRPRO>GIRONA</DIRPRO>
    <POBPRO>S. VICENS HORTS</POBPRO>
    <RUTA>0</RUTA>
    <ORDEN>0</ORDEN>
    <NOMINA>S</NOMINA>
    </access>
    </sadmt1.SPE106TST>
    </STATEMENT>
    </ns0:MT_XMLSQL_SPEC>
    Hope your problem gets solved.
    -Shamly

  • Exception not being thrown in try statement

    I am trying to write a small program to handle exceptions. However, the program will not compile because it is giving me an error saying the exception InvalidDocumentCodeException will never be thrown in body of coresponding try statement. Here are the two programs:
    public class InvalidDocumentCodeException extends Exception {
    InvalidDocumentCodeException (String message) {
    super(message);
    and
    import java.util.Scanner;
    public class Main2 {
    // Creates an exception object and possibly throws it.
    public static void main (String[] args) {
    char designation;
    String input = null;
    int valid = 0;
    Scanner scan = new Scanner (System.in);
    System.out.print ("Enter a 2-digit designation starting " + "\n" +
    "with U, C, or P, standing for unclassified, " + "\n" +
    "confidential, or proprietary: ");
    input = scan.nextLine();
    try {
    designation = input.charAt(0);
    if(designation == 'U')
    valid++;
    else if(designation == 'C')
    valid++;
    else if(designation == 'P')
    valid++;
    else if(designation == 'u')
    valid++;
    else if(designation == 'c')
    valid++;
    else if(designation == 'p')
    valid++;
    catch (InvalidDocumentCodeException problem) {
    System.out.println("Invalid designation entered " +
    problem);
    System.out.println ("End of main method.");
    can anyone tell me what I am doing wrong here?

    kenporic wrote:
    Forgive me, This is the first time I have used this sight and I should have been more precise. Thanks for all the help, but this is an excercise in how to handle exceptions in Java. One way is to "throw" the exception to another class to be handled. The other is to handle the exception within the running class. The throws program That I have works. The problem that I am having is handling the exception within the class without coding the "throws" statement. I am supposed to use the try-catch method in doing this. In the example I was given to follow, the code did not specifically throw the exception. If the input was not handled in the processing code then the catch statement is supposed to call to the exception class somehow?Okay, there are two families of exceptions--checked and unchecked.
    Checked: These are for things that are not part of the "happy path" of your code, but that your code may reasonably be expected to deal with. They're not necessarily signs of a bug in your code, nor do they indicate a problem in the JVM that's beyond your control. They're for things like when a file you're looking for doesn't exist (so maybe you handle it by asking the user to pick a different file), or a network connection being lost (so maybe you handle it by waiting a few seconds and trying again).
    When a checked exception occurs, since it's an expected and recoverable occurrence, you're expected to deal with it. So, when one of these exceptions can occur in your method, your method is required to either a) handle it (with catch) or b) let the caller know that HE might be asked to deal with it.
    We must either handle it:
    void doFileStuff(String path) {
      try {
        do file stuff
      catch (IOException exc) {
        retry--which means the whole try catch would be in a loop
        or maybe just substitute some default values that don't have to come from a file
    }Or let our caller know that he's going to have to handle it (or pass it on to his own caller):
    void doFileStuff(String path) throws IOException) {
      // this might throw an exception, but it's not this method's job to handle is, so it bubbles up to our caller
      do file stuff;
    Unchecked: These are things that are either bugs in your code (like a NullPointerException) or serious problems with the JVM that are beyond our control (like OutOfMemoryEror). These can occur anywhere, and it's not generally our code's job or our caller's job to deal with them, so they don't need to be caught or declared like checked exceptions do. You can catch them, and there are some places where it's appropriate to do so, but leave that aside for now.
    Unchecked exceptions are RuntimeException, Error, and every class that descends from them. Checked exceptions are everything else under Throwable, and Throwable itself.
    Now, when you do
    void foo() throws SomeException {You're telling the compiler that this method might throw that exception.\
    If SomeException is a checked exception, the compiler is able to tell whether your claim that you might throw it is true. Since it's checked, every method that might throw it must declare it. So the compiler can look at all the methods you call and see if they throw SomeException. If none of them do, and you don't explicitly put throw new SomeException(...); in your foo() method, then the compiler can be absolutely sure that there's no way foo() will throw SomeException. So it won't let you claim to throw it.
    On the other hand, is SomeException is unchecked, then since methods aren't required to report the unchecked exceptions they can throw, the compiler has no way of knowing whether some method you call might throw SomeException, so it always lets you declare it (and never requries you to).

  • Report -Error in SQL Statement

    Hi to All,
    Whe I ran the report on ODS its giving the following error.
    Error Error in SQL Statement:DBIF_RSQL_INVALID-RSQL
    Error Error When generating the SQL statement
    Error reading the data of Infoprovider ZABCXX
    Abort system error in Program SAPLRRK0 and form RSRDR;SRRK0F30-01
    Note:ZABCXX is a Multiprovider
    Then I identified data type  is mismatched for 4 characteristics in ODS , I have changed the data type from Date to Char then deleted the data from ODS and reloaded the six Init packages with different selections.
    After reloading I ran the report still same error its showing.
    Is any bug in stadard program?
    Pls can anyody throw some light on my problem.
    Thanks,
    Sha.

    Hi,
    Try using transaction code ListCube and see if you are able to see some entries in BW system itself.
    Also in RSRT -> Query -> Environment -> Delete old abaps
    Also in RSRT -> Query -> Environment -> Generate Queries
    And let us know the outoput .
    Hope that helps.
    Regards
    Mr Kapadia
    Assigning points is the way to say thanks in SDN.

  • Error in SQL Statement (ODS data loading Error)

    Hello Gurus...
    I am trying to loading the data Info Source To ODS in my ODS Key Figure Z_IVQUA (Invoice Quantity)
    is getting the Error Message Data shows 0 from 0 Records.
    I was Remove the Key Field from ODS Then try to load the data but i am getting same Error..
    Error in SQL Statement: SAPSQL_INVALID_FIELDNAME F~/BIC/Z_INVQUA
    Errors in source system
    Please Suggest....
    Thanks
    Prakash

    Hello All...
    Really appreciate if you can give me some advise. Thanks.
    Prakash
    Edited by: Prakash M on Jan 14, 2009 2:14 PM

  • Error in SQL Statement: SAPSQL_INVALID_TABLENAME /BI0/V0FIGL_C01F

    Hi,
    When I am executing datasource 80FIGL_C01 using T.code RSA3 in BW3.5, getting error Error in SQL Statement: SAPSQL_INVALID_TABLENAME /BI0/V0FIGL_C01F
    I am getting same error when pulling data from BW3.5 to BI7.0 at scheduling.
    Can I have your valuable insights on this.
    Thanks in advance!
    Sapna

    Hi,
    Try the report sap_factviews_recreate. Warning: the program generate the views for all infocubes. When you don't want to do this, debug the abap and delete the infocubes from the table G_T_CUBE.
    Or activate the infocube and re-generate the datasource.
    Sven

Maybe you are looking for

  • Problem deploying project with External Resource Integration with jars

    Hi, Please help ur how we can deploy a project in Enterprise server if that is integrated to some application which needs weblogic.jar. If this jar is made vesionable then it shows a size problem. If that jar is added to Install Drivers (In the confi

  • Inprocess inspection

    Hi experts One of my semifinished material i have routing with two operation from PP side . I add a new operation for QM inspection with Assign QM work center and assign inspection chracterestic in routing Now i have the following dout on this 1.What

  • Sustitution Problem

    Hi, I'm facing some problem in Substitution & using the same substitution in back also. when I go to add some value in Prerequisites and come back to save the system shows me the error message "Maximum formula length is reached'"   Message no. GB016 

  • Can I Display the System Variable CpInfoElapsedTime on my slides on realtime basis?

    I desire that users of my project view the time elapsed on each slide not as a static value but dynamic; i mean on a real time basis. Is this in any way possible? If it is how do i go about it Secondly, how do i move advance action(s) written and imp

  • \b Formatting number with a pattern?

    I am trying to format a number according to the given format by the user. For eg: if the given number is 1234 and the given pattern is ###.# then my output should be 123.4 Now this is a simple pattern . The input pattern could be even like this ###,#