导入db2jcc_license_cu.jar和db2jcc.jar包后,用下面的代码测试连接:
package com.conking.bill.db2Conn; import java.sql.*;
public class DB2Conn { private String DIRVER = "com.ibm.db2.jcc.DB2Driver"; private String URL = "jdbc:db2://localhost:50000/SAMPLE"; private String USERNAME = "db2admin"; private String PASSWORD = "bill"; private Connection conn = null; public DB2Conn(){ try { Class.forName(DIRVER); } catch (ClassNotFoundException e) { e.printStackTrace(); } } public Connection getConn()throws Exception{ conn = DriverManager.getConnection(URL,USERNAME,PASSWORD); System.out.println("========"); return conn; } public static void main(String[] args)throws Exception { DB2Conn db2 = new DB2Conn(); db2.getConn(); }
}
|
阅读(862) | 评论(0) | 转发(0) |