我试图将通过Tomcat运行的基于Java的程序连接到CONNX数据库,但是标题中出现错误。这是我的代码,其中删除了一些标识信息:
String driver = "com.Connx.jdbc.TCJdbc.TCJdbcDriver";
String connectionString = "jdbc:connx:DD=praxav11;Gateway=<server name>";
String user = "<user>";
String pass = "<pass>";
Class.forName(driver);
dbConnection = java.sql.DriverManager.getConnection(connectionStr, user, password);
我一直在使用以下指示:
http://www.connx.com/products/connx/CONNX%2010%20UserGuide/connxcdd32a/opening_a_connection_jdbc_driver.htm
我从DSNR工具获得了“ praxav11”,根据它就是我想要的CDD的CDD-DSN,所以我非常有信心。
对于网关,我尝试了服务器名称和服务器IP。我非常有信心的用户名和密码是正确的,无论如何,我都会为这些用户得到一个不同的错误。
是否有人对错在哪里有什么想法或对尝试什么有任何建议?我真的为此空白,并尝试强行强制使用它,但我无法使其正常工作。
完整的错误是:
com.$company.DBDataSetException: java.sql.SQLException: Connection refused: connect
at com.$company.DBDatabase.setConnection(DBDatabase.java:43)
at em.cabbench.$client.ERPInterface$client.connectToConnx(ERPInterface$client.java:137)
at em.cabbench.$client.ERPInterface$client.getERPRawMaterialPrice(ERPInterface$client.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at em.cabbench.RequestTypes.call(RequestTypes.java:1120)
at em.cabbench.CabBenchSrv.processRequest(CabBenchSrv.java:988)
at em.cabbench.CabBenchSrv.doGet(CabBenchSrv.java:828)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Connection refused: connect
at com.Connx.jdbc.TCJdbc.TCJdbcDriver.connect(TCJdbcDriver.java:251)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.$company.DBDatabase.setConnection(DBDatabase.java:40)
... 23 more
Couldn't connect to CONNX
java.lang.NullPointerException
at com.$company.DBDatabase.closeConnection(DBDatabase.java:66)
at em.cabbench.$client.ERPInterface$client.getERPRawMaterialPrice(ERPInterface$client.java:171)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at em.cabbench.RequestTypes.call(RequestTypes.java:1120)
at em.cabbench.CabBenchSrv.processRequest(CabBenchSrv.java:988)
at em.cabbench.CabBenchSrv.doGet(CabBenchSrv.java:828)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
最佳答案
我希望可以从运行代码的机器上访问数据库服务器。
关于java - 无法将Java连接到CONNX:java.sql.SQLException:连接被拒绝:connect,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30121044/