package spring.batch.controller; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Test1 { public static void main(String[] args) { try { // 需要引入db2jcc4.jar Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } // 必须使用IP String url = "jdbc:db2://192.168.10.7:50000/SAMPLE"; try { Connection con = DriverManager.getConnection(url, "db2admin", "你的密码"); System.out.println(con); } catch (SQLException e) { throw new RuntimeException(e); } } }
DB2 连接测试代码
最新推荐文章于 2024-08-21 13:55:04 发布