[問題] 設定JDBC連線informix資料庫的問題

看板java作者 (gg)時間13年前 (2012/10/24 23:27), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
目前我只想要測試程式是否能夠和informix連線成功 主機在其他電腦上,本機應該只要裝JDBC driver不用裝Tomcat之類的 但我的程式只能執行到System.out.println("Driver OK") 所以我想請教hwae5500是否一定要改成ip,另外hwae5500後面沒有加port 是不是和ODBC不同不能省略,一定要加port才正確 或者錯誤訊息有其他的問題 public class DBConnection { public static void main(String args[]) { Connection connection = null; Statement statement = null; ResultSet resultSet = null; String dbURL = "jdbc:informix-sqli://hwae5500/affil/:INFORMIXSERVER="+ "shme5500;user=test;password=test;"; try { Class.forName("com.informix.jdbc.IfxDriver"); System.out.println("Driver OK"); connection =DriverManager.getConnection(dbURL); System.out.println("connection OK"); } catch (SQLException s) { //System.out.println("SQLException "); s.printStackTrace(); } catch (Exception e) { System.out.println("Exception :"+e.toString()); } } } 錯誤訊息: Driver OK java.sql.SQLException: Message text will be provided in later releases java.lang.NullPointerException at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:487) at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1429) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.informix.jdbc.IfxDriver.connect(IfxDriver.java:254) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at DBConnection.main(DBConnection.java:19) Caused by: java.lang.NullPointerException at com.informix.asf.Connection.prepareIP_PortInfo(Connection.java:2073) at com.informix.asf.Connection.prepareForConnect(Connection.java:2004) at com.informix.asf.Connection.<init>(Connection.java:322) at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1055) ... 8 more -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 36.226.25.150
文章代碼(AID): #1GY0ZKIQ (java)