About catching exception??

Can anyone help me? I want to create a utility class which catches different sorts of exceptions and pass programmer generated messages through the request object back to the servlet controller which instantiates the utility class whenever an exception occurs.The contoller caches the exception in it's try-catch block and then instantiates the utility class.But how to pass the exception to my utility class and catch it again there and generate more user friendly messages??

My utility class contains catch blocks for all types
of exceptions.I want to catch the exact exception and
create user friendly messages there only.If I pass
exception object from the controller to the utility
class how to make it's catch blocks catch the passed
exception??I understood what you said, but that's not how you usually do it, but you can if you want:
// Code from some method
        try {
            throw new IOException("Test");
        } catch (Exception e) {
            Utility.handleExeption(e);
// The utility class
class Utility {
    public static void handleExeption(Throwable t) {
        try {
            throw t;
        } catch (IOException ex) {
            System.err.println("IOException " + ex);
        } catch (Throwable ex) {
            System.err.println("Throwable " + ex);
}Note that you probably don't want to catch throwables. It was just to show that it can be done.
Kaj

Similar Messages

  • ABOUT CATCHING EXCEPTIONS IN WEBDYNPRO

    IN WEBDYNPRO I WANT TO HANDLE EXCEPTION
    SO IN TRY WHAT I HAVE TO WRITE
    AND IN CATCH WHAT I HAVE TO WRITE
    PLESE GIVE ME CODE

    hi,
    bind this method to any action as action handler r event handler
    public void method_name()
    try
      // your block of code
        catch(Exception e)
          wdcomponentAPI.getmessagemanager.raiseException(“Exception” +e,true);
    hope this helps u,
    Regards,
    Arun

  • Catch exceptions that occur in the constructor of a managed bean

    Hello,
    I would like to catch exceptions that might occur in the constructor of a managed bean and redirect to an error page. My beans need to get data from a database and if the database is not accessible, an error page is to tell the user "try again later". I don't want to write an action or actionListener that is invoked by a button klick on the previous page to make error handling easier, because an actionListener should not know about the next page and what data the next page will need.
    I read all postings about this topic I could find in this forum. And there are three solutions I tried:
    1) register an error-page in web.xml
    Is there an example for using this in a JSF application? It did not work. I got a "Page not found" exception
    2) Use a phase listener. But how can a phase listener do this? Is there an example? I don't think it can do it in the beforePhase method because this method is called before the constructor of the managed bean is called.
    3) Use a custom ViewHandler. This is my renderView method which creates a "Page not found" Exception.
    public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
    ViewHandler outer = context.getApplication().getViewHandler();
    try {
    super.renderView(context, viewToRender);
    } catch (Exception e) {
    context.getExternalContext().redirect("/error.jspx");
    Several people write they've done it one or the other way. Please share your knowledge with us !!
    Regards,
    Mareike

    Hallo Mareike,
    Maybe I should abandon managed beans, create my own
    "unmanaged" ones inside of an action listener and put
    them somewhere my pages can find them.
    Its a pity, because I like the concept of managed
    beans.sure setter injection of JSF is fine!
    well workaround could be using <h:dataTable rendered="#bean.dbAccessible" ...>
    In your constructor you catch the exception and set
    dbAccessible = false;
    or you use error pages of webcontainer,
    but the pages couldn't contain JSF components, IMHO
    only plain JSP files.
    BTW perhaps somebody on MyFaces' list knows the solution:
    http://incubator.apache.org/myfaces/community/mailinglists.html
    Regards,
    Mareike-Matthias

  • Why catching Exception is bad idea??

    Hi,
    Why it is said that catching an Exception is a bad idea. Any how we get the actual cause in stackTrace of Exception object.!
    Plz help

    Catching exceptions (lowercase e) is not a bad thing. Catching Exception (uppercase E) is generally bad.
    Lowercase e exceptions refer to the entire Throwable hierarchy--everything that can be thrown and caught. Often you want to catch and handle them, or catch and wrap and rethrow them.
    Uppercase E Exception is a particular class of exception, and it's the parent class of all checked exceptions and many unchecked exceptions. When your code has catch Exception, you're saying that almost no matter what goes wrong, you want to handle it the same way. And you're also assuming that if the methods that you're calling change to throw more or fewer exceptions, your code won't need to know or care about it.
    In general you want to catch more specific subclasses of Exception, so that you can handle each one properly, and you know that your code is handling precisely the correct set of exceptions.

  • Catching exceptions

    Maybe a stupid question but is there any common practice when it comes to handling exceptions in Java? Should I declare throws for the whole method or should I use a try-catch construction? I can see the advantage of passing exception to the calling methods but this means that many methods must be throwables or catch the exceptions so it's kind of a circle of exceptions...
    /P

    You usually don't want to do
    catch (Exception e) {}
    Somewhat less onerous is
    catch (Exception e) { //handle it }
    Normally what you'd do is define your own exception classes that extend Exception. A common approach is to use a package-based hierarchy, with specific exceptions for specific types of errors.
    // package com.mycompany.dbstuff might have these
    public class DatabaseException extends Exception { /*...*/}
    public class NoSuchTableException extends DatabaseException { /*...*/ }
    public class  LoginFailedException extends DatabaseException { /*...*/}
    // package com.mycompany.accountmanagement package may have these
    public class AccountException extends Exception {/*...*/}
    public class IllegalAccountNumberExceptoin extends AccountException {/*...*/}
    // etc.Each exception simply has constructors that call super(same args), and possibly the ability to take another Throwable as a constructor arg, which is then mapped to a member variable so you can later call getCause() or getWrappedException to see which exception led to this one.
    At any given layer, you catch exception thrown by the layers it uses, and wrap them in an exception for your current layer.
    // in the AccountClass
    public AccountInfo getAccountInfo(int acctId) throws AccountException {
        if (acctId < 0) {
            throw new IllegalAccountNumberException("No negative account numbers");
        try {
            database.login(uname, passwd);
            databse.getAccountInfo(acctId);
        catch (DatabaseException exc) {
            exc.printStackTrace();
            throw new AccountException(exc);
    }This way, the user of the accountmanagement package doesn't need to know what database package accountmanagement uses. If I call an accountmanagement method, I only have to deal with an account relatd exception. If it's IllegalAccountNumber, I can prompt the user to reenter the acct number. If it's other, I can say "Couldn't retrieve account info, please try again" or some such thing.
    And yes, I know, if the login failed, you'd want to propagate that, so the user could reenter the password. I'd make a separate AccountLoginFailedException and wrap that around the DBLoginFailed, because the user of the Account class is trying to access the account, not the database.
    Also, you often do want to print stack traces. Not in your user's face--off in a log file somehwere. If you've got exceptions that are ocurring for reasons other than user typos, you want to record as much info as you can about them.

  • Catching Exception in RMI

    Hello,
    I have this problem. I have this method in my RMI IF
    public Object performSomething() throws RemoteException
    try
    doSomething();
    catch(Exception e)
    RemoteException eEx = new RemoteException(e.getMessage(), e.getCause());
    eEx.setStackTrace(e.getStackTrace());
    throw eEx;
    but when i logged the Exception that i caught (as well as the stack trace), i got null for the exception message and null also for each message in the stackTraceElement. Does anyone has an idea why this has happened.
    And btw, the exception that i excepted was an sql exception.
    Thanks a lot =)

    That's because you're constructing your own, and destroying all the information in the original exception. Just cast it to RemoteException, don't construct a new one, or better still just catch the RemoteException (and the SQLException directly:
    catch (RemoteException exc)
    catch (SQLException exc)
    }It is rarely correct to catch Exception except in toy code or at the bottom of Runnable.run() methods.
    Indeed, it is also rarely best to log and rethrow. This is a well-known antipattern. The catcher that has to finally catch the exception and do something about it should log it too.

  • Howto catch exception

    Spring MVC + DWR
    the exception throw and i got the fellows from the log.
    you will see the "Unknown Source", it's much complicated to find which LINE throws the NULLPOINTEREXCEPTION
    1) how to get the exception with more details(no "Unknown Source"), maybe i should catch all the exception before it send to UI
    2) can you give me some advice or articles about the exception handling.
    java.lang.NullPointerException     
    at space.service.admin.forbid.AdminForbidServiceImpl.addForbidUser(Unknown Source)     
    at space.service.admin.forbid.AdminForbidServiceImpl.addForbid(Unknown Source)     
    at space.web.dwr.beans.admin.AdminBean.forbidUserWithReason(Unknown Source)     
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     
    at java.lang.reflect.Method.invoke(Method.java:585)     
    at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)     
    at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)     
    at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)     
    at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)     
    at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)     
    at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)     
    at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)     
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)     
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)     
    at space.web.filters.SignonFilter.doFilter(Unknown Source)     
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)     
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)     
    at space.web.filters.OpenServiceInViewFilter.doFilter(Unknown Source)     
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)     
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)     
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)     
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)     
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)     
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)     
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)     
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)     
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)     
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:833)     
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)     
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285)     at java.lang.Thread.run(Thread.java:595)

    Compile your source code with the 'debug' option enabled to get rid of 'unknown source'.

  • What do you think about using exceptions for something more than errors

    if you look the java.lang.Exception description at the JDK javadoc, you can see the following text:
    "The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch."
    ... we can�t see "error" word anywhere!!
    What do you think about using exceptions for something more than errors? Can be possible use them as a way for send information to upper layers?
    Thankx in regards...

    it seems that what you say is a functional way of achiveing that, yes
    but Exceptions are generally reserverd for "Exceptional" situations ie program messing up or invalid data
    it does require a fair bit of processor time to actually generate and throw an Exception.
    so, all in all its "better" to use "normal" condition flow control to achive what you want.. you can always return early, break loops, call methods to pass information

  • How to catch exception into a String variable ?

    I have a code
    catch(Exception e)
                e.printStackTrace();
                logger.error("\n Exception in method Process"+e.getMessage());
            }when i open log i find
    Exception in method Process null.
    But i get a long error message in the server console !! I think thats coming from e.printStackTrace().
    can i get the error message from e.printStackTrace() into a String variable ?
    I want the first line of that big stacktrace in a String variable.
    How ?

    A trick is to issue e.printStackTrace() against a memory-based output object.
    void      printStackTrace(PrintStream s)
             // Prints this throwable and its backtrace to the specified print stream.
    void      printStackTrace(PrintWriter s)
    //          Prints this throwable and its backtrace to the specified print writer.Edited by: BIJ001 on Oct 5, 2007 8:54 AM

  • How to catch exception while validating the username and password in hbm

    Hi,
    I do want to set the username and password dynamically in hibernate.cfg.xml
    Here below is my configuration file.
    {code<hibernate-configuration> 
    <session-factory> 
           <property name="hibernate.bytecode.use_reflection_optimizer">false</property> 
           <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
           <property name="hibernate.connection.pool_size">10</property> 
           <property name="show_sql">true</property> 
           <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> 
           <property name="hibernate.hbm2ddl.auto">update</property> 
           <property name="current_session_context_class">thread</property> 
           <property name="show_sql">true</property> 
         </session-factory> 
    </hibernate-configuration>{code}
    Also im getting that session factory object like the below code.
    public class Sessions {        private static SessionFactory sessionFactory;      private static Configuration configuration = new Configuration();        static {          try {              String userName = GuigenserviceImpl.userName;              String password = GuigenserviceImpl.password;              String hostName = GuigenserviceImpl.hostName;              String portNo = GuigenserviceImpl.portNo;              String sId = GuigenserviceImpl.sId;                  configuration                      .setProperty("hibernate.connection.username", userName);              configuration                      .setProperty("hibernate.connection.password", password);              configuration.setProperty("hibernate.connection.url",                      "jdbc:oracle:thin:@" + hostName + ":" + portNo + ":" + sId);                try {              configuration.configure("/hibernate.cfg.xml");              sessionFactory = configuration.buildSessionFactory();              GuigenserviceImpl.strAccpted = "true";              }              catch (Exception e) {                    e.printStackTrace();                  GuigenserviceImpl.strAccpted = "false";              }            }          catch (HibernateException hibernateException) {              GuigenserviceImpl.strAccpted = "false";              hibernateException.printStackTrace();          }          catch (Throwable ex) {                GuigenserviceImpl.strAccpted = "false";              ex.printStackTrace();              throw new ExceptionInInitializerError(ex);          }      }          public static SessionFactory getSessionFactory() {          return sessionFactory;      } 
    So, in this above scenario, suppose if im giving the wrong password means exception should be caught and the string variable "GuigenserviceImpl.strAccpted" should be assigned to false.
    But im getting the SQL Exception only in console like wrong username and password. And finally i couldn't able to catch the exception in Sessions class, static block.
    Anyone can help me in catching that SQL Exception in my Sessions class and i need to handle that SQL Exception in my class.
    Im getting this following exception message in my console.
      INFO: configuring from resource: /hibernate.cfg.xml  Apr 6, 2009 2:47:00 PM org.hibernate.cfg.Configuration getConfigurationInputStream  INFO: Configuration resource: /hibernate.cfg.xml  Apr 6, 2009 2:47:00 PM org.hibernate.cfg.Configuration doConfigure  INFO: Configured SessionFactory: null  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: Using Hibernate built-in connection pool (not for production use!)  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: Hibernate connection pool size: 10  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: autocommit mode: false  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@192.168.1.12:1521:orcl  Apr 6, 2009 2:47:00 PM org.hibernate.connection.DriverManagerConnectionProvider configure  INFO: connection properties: {user=scott, password=****}  Apr 6, 2009 2:47:01 PM org.hibernate.cfg.SettingsFactory buildSettings  WARNING: Could not obtain connection metadata  java.sql.SQLException: ORA-01017: invalid username/password; logon denied        at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)      at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:204)      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406)      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)      at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:799)      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:368)      at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)      at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)      at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)      at java.sql.DriverManager.getConnection(DriverManager.java:525)      at java.sql.DriverManager.getConnection(DriverManager.java:140)      at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)      at com.beyon.ezygui.server.Sessions.<clinit>(Sessions.java:39)      at com.beyon.ezygui.server.GuigenserviceImpl.testRPC(GuigenserviceImpl.java:322)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    Thanks in advance.
    Thanks & Regards,
    Kothandaraman N.

    Hi,
    Myself hardcoded that username and password checking like the below code.
    String name = loginData.get("userName").toString();
              String pswd = loginData.get("pswd").toString();
              String hstName = loginData.get("hName").toString();
              String prtNo = loginData.get("portNo").toString();
              String sid = loginData.get("sId").toString();
              SessionFactory sessionFactory = null;
              try {
                   if (name.trim().equals(userName) && pswd.trim().equals(password)
                             && hstName.trim().equals(hostName)
                             && prtNo.trim().equals(portNo) && sid.trim().equals(sId)) {
                        sessionFactory = Sessions.getSessionFactory();
                        strAccpted = "true";
                   } else {
                        strAccpted = "false";
              } catch (Exception e) {
                   e.printStackTrace();
                   strAccpted = "false";
              }I have my own values in string objects, then comparing that values with the values from login form. If both values are matching, then i will do configurations in hibernate.
    ResourceBundle resourceBundle = ResourceBundle
                   .getBundle("com.beyon.ezygui.server.Queries");
         public static final String connection_url = resourceBundle
                   .getString("connection.url");
         public static final String userName = resourceBundle.getString("userName");
         public static final String password = resourceBundle.getString("password");
         public static final String hostName = resourceBundle.getString("hostName");
         public static final String portNo = resourceBundle.getString("portNo");
         public static final String sId = resourceBundle.getString("sId");The above are the String objects i'm checking for the match with values from login form.
    Thanks & Regards,
    Kothandaraman N.

  • How to catch exception of JMS when call onMessage()?

    I write a consumer client implement onMessage(),
    in my main() method ...
    try {
    _adapter = new Adapter(checkConsumer,env);
    _adapter.setSelector("client = 'Receive1'");
    _adapter.start();
    System.out.println("Hello...");
    } catch(Exception e) {
    _adapter = null;
    System.out.println("Unable to start adapter: " + e.getMessage());
    _adapter.start() will call onMessage() my onMessage like this
    public void onMessage(Adapter adpt, Message message) {
    try {
    if(message instanceof TextMessage) {
    // Write the text out as read String text = ((TextMessage)message).getText();
    // Do CHECK Process adpt.demoOut("Receive CHECK Text is :" + text);
    //System.out.println("class name is " + consumerName);
    } else {
    // This is just a message (no particular type) } } catch (Exception e) {
    try {
    adpt.warn("Error outputing data: " + message.getJMSMessageID());
    } catch(Exception ignore) {
    } adpt.warn("\tError: " + e.getMessage());
    // Do some exception process }
    If the JMS Server shutdown, how can I catch the exception?

    You might want to try with exception listener that JMS specification provides.

  • How to catch exception when have max connection pool

    hi,
    i have define in oracle user that i could have max 10 sessions at the same time.
    I have jdbc datasource & connection pool defined at glassfish server(JSF application).
    now, if in application is too many queries to the database then i have error: nullpointer exception - becouse when i try to do:
    con = Database.createConnection(); - it generates nullpointer exception becouse there isn't free connection pool
    i try to catch exception like this:
    public List getrep_dws_wnioski_wstrzymane_graph() {     int i = 0;     try {     con = Database.createConnection();     ps =    (Statement) con.createStatement();     rs = ps.executeQuery("select data, klasa, ile_dni_wstrzymana, ile_wnioskow from stg1230.dwsww_wstrzymane_dws8 order by data, klasa, ile_dni_wstrzymana, ile_wnioskow");     while(rs.next()){       rep_dws_wnioski_wstrzymane_graph.add(i,new get_rep_dws_wnioski_wstrzymane_graph(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4)));       i++;     }     } catch (NamingException e) {         e.printStackTrace();     } catch (SQLException e) {         e.printStackTrace();     } catch (NullPointerException e) {         e.printStackTrace();         throw new NoConnectionException();  // catch null 1     } finally {     try {         con.close();     } catch (SQLException e) {         e.printStackTrace();     } catch (NullPointerException e) {         e.printStackTrace();         throw new NoConnectionException();  // catch null 2     }     } return rep_dws_wnioski_wstrzymane_graph; }
    but at line:
    con.close();
    i have nullpointerexception
    and
    at line
    throw new NoConnectionException(); // catch null 2
    i have: caused by exception.NoConnectionException
    what's wrong with my exception class? how to resolve it?
    public class NoConnectionException extends RuntimeException{     public NoConnectionException(String msg, Throwable cause){       super(msg, cause);     }     public NoConnectionException(){       super();     } }
    at web.xml i have defined:
    <error-page>         <exception-type>exception.NoConnectionException</exception-type>         <location>/NoConnectionExceptionPage.jsp</location>     </error-page>

    thanks,
    i did it and i have error:
    java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)
    at logic.Database.createConnection(Database.java:37): conn = ds.getConnection();
    public class Database {
         public static Connection createConnection() throws NamingException,
                    SQLException {
                Connection conn = null;
                try{
                    Context ctx = new InitialContext();
              if (ctx == null) {
                   throw new NamingException("No initial context");
              DataSource ds = (DataSource) ctx.lookup("jdbc/OracleReports");
              if (ds == null) {
                   throw new NamingException("No data source");
              conn = ds.getConnection();  // here's exception when max connections to database
              if (conn == null) {
                   throw new SQLException("No database connection");
                } catch (NamingException e) {
                    e.printStackTrace();
                    throw new NoConnectionException(); 
             } catch (SQLException e) {
                 e.printStackTrace();
                    throw new NoConnectionException(); 
                catch (NullPointerException e) {
                 e.printStackTrace();
                    throw new NoConnectionException();  // obsluga bledy na wypadek jesli braknie wolnych polaczen do bazy
            return conn;
    }and at my ealier code i have error:
    at logic.GetDataOracle.getrep_dws_wnioski_wstrzymane_graph(GetDataOracle.java:192)
    at line: con = Database.createConnection();
    in code:
    public List getrep_dws_wnioski_wstrzymane_graph() {
        int i = 0;
        try {
        con = Database.createConnection();
        ps =    (Statement) con.createStatement();
        rs = ps.executeQuery("select data, klasa, ile_dni_wstrzymana, ile_wnioskow from stg1230.dwsww_wstrzymane_dws8 order by data, klasa, ile_dni_wstrzymana, ile_wnioskow");
        while(rs.next()){
          rep_dws_wnioski_wstrzymane_graph.add(i,new get_rep_dws_wnioski_wstrzymane_graph(rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4)));
          i++;
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new NoConnectionException();
        } finally {
        try {
            if(con != null)
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new NoConnectionException(); 
    return rep_dws_wnioski_wstrzymane_graph;
    }so what's wrong?
    i have limit max sessions 10 at oracle so i set at my connection pool 5 connections as max. But when i get max 5 sesssins and try to execute next query then i can't catch exception..

  • How to catch exception thrown from a function module?

    Hi all,
             When we are calling a function module from JSPDynpage setting some import parameters, If in some case an exception is thrown in the function module.  How can we catch the same exception in the JSPDynpage program?
    Thanks & Regards,
    Ravi

    Hi Ravi
                                    Try this
                                                try
                    Object retMsgs = output.get(bapiretrunmsgobject);
                      if(result != null )
    IrecordSet rmsg = (IrecordSet) result
                   catch(Exception ex)
                        printException(ex, "Error getting function result");
    Lemme know for any further questions.
    Regards
    Praveen

  • SFTP adapter error : Catching exception calling messaging system

    Error: com.aedaptive.sftp.adapter.SFTPException : Not all messages were delivered succesfully
      Could not deliver message to XI: com.sap.aii.af.lib.mp.module.ModuleException: senderChannel 'ca09269447583427adc545f8c23d244b': Catching exception calling messaging system
    This is error message which i get in sender communication channel while working  with SFTP adapter.

    Hi Pooja,
    I think it would be better to add getcause() to get the cause of the issue.
    Ref: http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/af/lib/mp/module/ModuleException.html
    Thanks,

  • Biginner's question about catch statement

    hi im just a biginner
    normally u guys write catch statement like
    catch (FileNotFouldException exception)
    System.out.println (exception);
    something like that . but what is the exception here
    is it object name? or class name or what
    i mean the word exception after FileNotFoundException
    i just don't understand

    It's the type of the exception to which the catch block should apply.
    You could have this:
    try {
      // stuff
    } catch (FileNotFoundException fnfe) {
      fnfe.printStackTrace();
    } catch (IOException ioe) {
      ioe..printStackTrace();
    } catch (NumberFormatException nfe) {
      nfe.printStackTrace();
    } catch (Exception x) {
      ex..printStackTrace();
    }Note that FNFE extends IOE, so if the IOE is caught first, the FNFE would be caught in that block too. That's why you catch the general Exception last - if you do it at all.

Maybe you are looking for

  • Sharepoint foundation create your own theme

    Hi, I was wondering.. We recently had a visit from a person who have giving us a presentation of Sharepoint in our company.  That person was talking about the free version of Sharepoint -> Sharepoint Foundation and he told us that it was possible jus

  • Can the Graphics card on an iMac 24" be upgraded?

    Not an expert on graphic cards, but can the ones in an iMac 20" or 24" be upgraded whenever a better one is released? I don't mind taking it to the Apple Store if that's they only way to upgrade it. Also has anyone ever run Oblivion with Parallels or

  • Error in creating table

    Hi, i'm creating the following table and having this error: ERROR at line 8: ORA-00907: missing right parenthesis This is the sql: CREATE TABLE baditemlist ( idbaditemlist NUMBER(16), idproducttypelist NUMBER(3), item VARCHAR2(20), CONSTRAINT pk_idba

  • Get all directories...

    I am trying to get this code to work, but i a returning some errors that i can't get rid of. import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class Search extends JFrame {      public static void main(String[

  • Picklist Values - a question.

    Hi, We got a list of values from business to be entered in a Picklist field. Later our business changed their mind and gave us a different list. 1) Is there is a way to delete the unwanted picklist values? It appears to me that the only option is to