是不是该jdbc:db2://172.16.2.213:50000/awmts ? 感觉端口号弄错了,瞎猜的.

解决方案 »

  1.   

    There are two different ways of JDBC-connecting to DB2 offered by IBM:1) access via the COM.ibm.db2.jdbc.app.DB2Driver 
    This access requires DB2 Client-software (DB-Connect) installed on the local machine (the computer where tomcat runs). 
    To use this access, you must call the Client-Configuration programm of DB2 and make a local name for the Database you want to access.
    Now you can open it in JDBC with the url jdbc:db2:<local-databasename>
    By the way: having given the name, you could also acces it via the jdbc-odbc bridge.2) The alternative way is to connect via the COM.ibm.db2.jdbc.net.DB2Driver 
    This access is designed for easy-to-deploy clients tlike applets or stand-alone clients where an installation of the (native) DB2-client is too complicated. (In fact it is)
    Access is slower compared to the app-driver. 
    To be able to use it, you must run the db2jstrt <portnumber> command on the DB-Server. (NOT on the computer, where the tomcat runs., but on the computer, where DB2 runs).
    To run this command, there are two ways (you must do it physically on the db2-server):
    -just open a DB2-console (you find it in the task-bar) and type the command
    -if you don't find the DB2-console on the task bar: open a console and navigate to the IBM-installation/SQLLIB/bin directory and type the commandAfter that, you can JDBC connect with the net-driver via the url 
    jdbc:db2:/<DB2-server-IP>:<tport-number>/<database-name>
    <port-number> is the number, you used with the db2jstrt commandclearly for a webserver, the natural choice would be the app-driver第一种我建了一个别名,搞定,第二种还没完成,我觉得应该是db2jstrt <portnumber>时有问题,我直接db2jstrt 50000(是数据库的端口号)。
      

  2.   

    你可以查找db2的开发文档,里面有java连接数据库的例子,两种驱动的连接方式都有.
      

  3.   

    你的连接方式写的不对,还是应该是"jdbc:db2://172.16.2.213:50000/awmts"
    建议你使用这个包看看com.ibm.db2.jcc.DB2Driver
    当db2是架在aix/unix上面时,注意web容器类库使用的不是db2jcc.jar,而是db2jcc_javax.jar和jb2jcc_license_cu.jar ,同样在ibm/sqllib/java/目录下