{Denodo}Javaで接続

https://community.denodo.com/docs/html/browse/8.0/jp/vdp/developer/access_through_jdbc/access_through_jdbc
https://www.ibm.com/docs/ja/db2-for-zos/11?topic=applications-retrieving-data-from-tables-using-statementexecutequery-method

 


前提: Javaインストール済み

 

cd C:\Denodo\DenodoPlatform8.0\tools\client-drivers\jdbc

notepad a.java

---

import java.sql.*;
import java.io.*;

public class a {
  public static void main(String[] args) throws Exception {

    Connection conn = null;
    ResultSet rs = null;
    PreparedStatement ps = null;
    int ret = 0;
    Statement stmt = null;

    conn = DriverManager.getConnection("jdbc:denodo://localhost:9999/admin","admin","admin");
    conn.setAutoCommit(false);


    ps = conn.prepareStatement("select * from db01.b_tab1");
    rs = ps.executeQuery();
    while (rs.next()) {
      System.out.println(rs.getInt("col1") + "\t" + rs.getString("col2") + "\t" + rs.getString("col3"));
    }
    rs.close();
    ps.close();

    FileOutputStream stream = new FileOutputStream("./output.txt");
    OutputStreamWriter writer = new OutputStreamWriter(stream);
    
    stmt = conn.createStatement();
    rs = stmt.executeQuery("DESC VQL VIEW db01.b_tab1 ('replaceExistingElements' = 'yes', 'includeDependencies' = 'no')");
    while (rs.next()) {
      System.out.println(rs.getString(1) );
      writer.append(rs.getString(1) );
    }

    rs.close();
    stmt.close();


    writer.close();
    stream.close();

    conn.close();
  }
}


---

javac -classpath .;./denodo-vdp-jdbcdriver.jar a.java
java -classpath .;./denodo-vdp-jdbcdriver.jar a

コンパイルなしでも実行可能
java -classpath .;./denodo-vdp-jdbcdriver.jar a.java