Published on InterSystems Developer Community (https://community.intersystems.com)

主页 > Java 连接到InterSystems IRIS数据库 - 使用 JDBC

文章
Jingwei Wang · 九月 16, 2022 阅读大约需 1 分钟

Java 连接到InterSystems IRIS数据库 - 使用 JDBC

连接前准备:

  1. Java 开发环境
  2. InterSystems JDBC 驱动
  3. Connection String

步骤:

  1. 配置 Classpath :指向InterSystems JDBC 驱动 - intersystems-jdbc-3.0.0.0.jar
  2. Connection String,其中import com.intersystems.jdbc*;用来导入驱动,User是命名空间名称。
    import com.intersystems.jdbc*;
    import java.sql.Connection;
    public class JDBCConnection{
    public static void main (String[] args) throws Exception {
    String dbUrl = "jdbc:IRIS://127.0.0.1:1972/User"; //replace
    String user = "SQLAdmin";
    String pass = "deployment-password";
    
    IRISDataSource ds = new IRISDataSource();
    ds.setURL(dbUrl);
    ds.setUser(user);
    ds.setPassword(pass);
    Connection dbconnection = ds.getConnection();
    System.out.println("Connected to InterSystems IRIS via JDBC.");
          }
    }
#Java #JDBC #InterSystems IRIS for Health

源 URL:https://cn.community.intersystems.com/post/java-%E8%BF%9E%E6%8E%A5%E5%88%B0intersystems-iris%E6%95%B0%E6%8D%AE%E5%BA%93-%E4%BD%BF%E7%94%A8-jdbc