0

我正在尝试将通过 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

“praxav11”我从 DSNR 工具中获得,根据它是我想要的 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)
4

3 回答 3

1

我希望可以从您运行代码的机器上访问数据库服务器......

于 2015-05-08T10:22:27.880 回答
0

好点...也许您可以尝试此解决方法,因为您在 Tomcat 中。使用此链接
http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html 设置上下文文件中的数据库资源。在应用程序的 web.xml 文件中引用它。并编写一个查找 JNDI 并建立连接的代码片段。这将通过 TomCats 的眼睛确认问题所在。

在运行代码之前,不要忘记将包含驱动程序的 CONNX jar 文件复制到 Tomcat 主目录 (CATALINA_HOME) 中。

于 2015-05-08T12:45:20.257 回答
0
Class.forName("com.Connx.jdbc.TCJdbc.TCJdbcDriver").newInstance();
TCJdbcDataSource ds = new TCJdbcDataSource();
ds.setGateway("<GateWay_IP>");
ds.setPort((short)7500); //default port
ds.setDSN("<Your_DSN_IP>");
ds.setUser("<UserName>");
Connection con = ds.getConnection();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
于 2016-12-06T10:54:27.260 回答