SHARE
TWEET

Untitled

a guest Aug 18th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.PrintWriter;
  2. import java.io.StringWriter;
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. public class DB2Connection {
  7.  
  8.     public DB2Connection() {
  9.         // TODO Auto-generated constructor stub
  10.     }
  11.  
  12.     public static void main(String[] args) {
  13.  
  14.         String jdbcClassName="com.ibm.db2.jcc.DB2Driver";
  15.         String url="jdbc:db2://ip-address:port/mydb";
  16.  
  17.         String user="user";
  18.         String password="password";
  19.  
  20.         Connection connection = null;
  21.         try {
  22.             //Load class into memory
  23.             Class.forName(jdbcClassName);
  24.             System.out.println("**** Loaded the JDBC driver");
  25.             //Establish connection
  26.             connection = DriverManager.getConnection(url, user, password);
  27.  
  28.         } catch (ClassNotFoundException e) {
  29.             e.printStackTrace();
  30.         } catch (SQLException e) {
  31.             e.printStackTrace();
  32.         }finally{
  33.             if(connection!=null){
  34.                 System.out.println("Connected successfully.");
  35.                 try {
  36.                     connection.close();
  37.                 } catch (SQLException e) {
  38.                    // e.printStackTrace();
  39.                     StringWriter errors = new StringWriter();
  40.                     e.printStackTrace(new PrintWriter(errors));
  41.                     System.out.println("Exception: " + errors.toString());
  42.                 }
  43.             }
  44.         }
  45.  
  46.     }
  47.  
  48. Error while validating the given DB details com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2057][11264][4.11.77] The application server rejected establishment of the connection.
  49. An attempt was made to access a database, ABCP, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
  50. com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2057][11264][4.11.77] The application server rejected establishment of the connection.
  51. An attempt was made to access a database, ABCP, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
  52.         at com.ibm.db2.jcc.am.gd.a(gd.java:319)
  53.         at com.ibm.db2.jcc.am.gd.a(gd.java:365)
  54.         at com.ibm.db2.jcc.t4.ab.u(ab.java:1674)
  55.         at com.ibm.db2.jcc.t4.ab.n(ab.java:536)
  56.         at com.ibm.db2.jcc.t4.ab.a(ab.java:343)
  57.         at com.ibm.db2.jcc.t4.ab.a(ab.java:115)
  58.         at com.ibm.db2.jcc.t4.b.m(b.java:1242)
  59.         at com.ibm.db2.jcc.t4.b.b(b.java:1113)
  60.         at com.ibm.db2.jcc.t4.b.d(b.java:696)
  61.         at com.ibm.db2.jcc.t4.b.c(b.java:682)
  62.         at com.ibm.db2.jcc.t4.b.a(b.java:367)
  63.         at com.ibm.db2.jcc.t4.b.<init>(b.java:307)
  64.         at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:214)
  65.         at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:460)
  66.         at java.sql.DriverManager.getConnection(DriverManager.java:664)
  67.         at java.sql.DriverManager.getConnection(DriverManager.java:247)
  68.         at beans.KBSourceTargetDefBean.testConnection(KBSourceTargetDefBean.java:1136)
  69.         at beans.KBSourceTargetDefBean.setCommand(KBSourceTargetDefBean.java:435)
  70.         at com.solix.controller.BeanController.setCommand(BeanController.java:970)
  71.         at com.solix.controller.BeanController.loadModel(BeanController.java:407)
  72.         at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
  73.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  74.         at java.lang.reflect.Method.invoke(Method.java:497)
  75.         at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
  76.         at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
  77.         at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
  78.         at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
  79.         at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
  80.         at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
  81.         at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
  82.         at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  83.         at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
  84.         at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
  85.         at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
  86.         at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
  87.         at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  88.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  89.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  90.         at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  91.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  92.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  93.         at filter.ValidateTokenFilter.doFilter(ValidateTokenFilter.java:121)
  94.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  95.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  96.         at filter.UserValidateFilter.doFilter(UserValidateFilter.java:244)
  97.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  98.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  99.         at filter.GenerateTokenFilter.doFilter(GenerateTokenFilter.java:110)
  100.         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  101.         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  102.         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
  103.         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  104.         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
  105.         at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
  106.         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
  107.         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
  108.         at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
  109.         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
  110.         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
  111.         at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
  112.         at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  113.         at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
  114.         at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
  115.         at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  116.         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  117.         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  118.         at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  119.         at java.lang.Thread.run(Thread.java:745)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top