使用Java

时间:2018-08-18 07:20:38

标签: java db2-zos

连接到DB2 zOS服务器时出现以下错误。 有人可以帮忙吗? 我们已经将Jar文件db2jcc4.jar与其他与JDBC相关的Jar文件一起使用了。 我还需要使用“ db2jcc_license_cu.jar”文件吗? 我在解决这个问题上遇到了困难。

我们也尝试了db2jcc.jar,但没有成功。

Java代码如下。

import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DB2Connection {

    public DB2Connection() {
        // TODO Auto-generated constructor stub
    }

    public static void main(String[] args) {

        String jdbcClassName="com.ibm.db2.jcc.DB2Driver";
        String url="jdbc:db2://ip-address:port/mydb";

        String user="user";
        String password="password";

        Connection connection = null;
        try {
            //Load class into memory
            Class.forName(jdbcClassName);
            System.out.println("**** Loaded the JDBC driver");
            //Establish connection
            connection = DriverManager.getConnection(url, user, password);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            if(connection!=null){
                System.out.println("Connected successfully.");
                try {
                    connection.close();
                } catch (SQLException e) {
                   // e.printStackTrace();
                    StringWriter errors = new StringWriter();
                    e.printStackTrace(new PrintWriter(errors));
                    System.out.println("Exception: " + errors.toString());
                }
            }
        }

    }

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.
An attempt was made to access a database, ABCP, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2057][11264][4.11.77] The application server rejected establishment of the connection.
An attempt was made to access a database, ABCP, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
        at com.ibm.db2.jcc.am.gd.a(gd.java:319)
        at com.ibm.db2.jcc.am.gd.a(gd.java:365)
        at com.ibm.db2.jcc.t4.ab.u(ab.java:1674)
        at com.ibm.db2.jcc.t4.ab.n(ab.java:536)
        at com.ibm.db2.jcc.t4.ab.a(ab.java:343)
        at com.ibm.db2.jcc.t4.ab.a(ab.java:115)
        at com.ibm.db2.jcc.t4.b.m(b.java:1242)
        at com.ibm.db2.jcc.t4.b.b(b.java:1113)
        at com.ibm.db2.jcc.t4.b.d(b.java:696)
        at com.ibm.db2.jcc.t4.b.c(b.java:682)
        at com.ibm.db2.jcc.t4.b.a(b.java:367)
        at com.ibm.db2.jcc.t4.b.<init>(b.java:307)
        at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:214)
        at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:460)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at beans.KBSourceTargetDefBean.testConnection(KBSourceTargetDefBean.java:1136)
        at beans.KBSourceTargetDefBean.setCommand(KBSourceTargetDefBean.java:435)
        at com.solix.controller.BeanController.setCommand(BeanController.java:970)
        at com.solix.controller.BeanController.loadModel(BeanController.java:407)
        at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at filter.ValidateTokenFilter.doFilter(ValidateTokenFilter.java:121)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at filter.UserValidateFilter.doFilter(UserValidateFilter.java:244)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at filter.GenerateTokenFilter.doFilter(GenerateTokenFilter.java:110)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:0)

由于信誉不足,我无法添加评论,但听起来“ ABCP”可能不是正确的数据库名称。 在这里看看:http://www-01.ibm.com/support/docview.wss?uid=swg21443723 它列出了查找数据库名称的方法。 如果使用正确的名称,请仔细检查端口。

关于许可问题。 在我的应用程序中,我同时使用db2jcc4.jar和db2jcc_license_ciuz.jar 我相信您需要_ciuz,jar来访问DB2 z / OS而不是_cu.jar,但是通常许可证问题导致的错误与您显示的错误不同。