Differences

This shows you the differences between two versions of the page.

Link to this comparison view

72:custom_reports_accessing_data_collecting_data [2019/02/07 14:06]
ext-bkkr created
72:custom_reports_accessing_data_collecting_data [2019/03/06 19:21] (current)
ext-bkkr
Line 1: Line 1:
 ====== Collecting External Data ====== ====== Collecting External Data ======
 +
 +==== Connecting a JDBC Database via Stages Data Source ====
 +
 +The Java Database Connectivity (JDBC) API provides universal data access from the Java programming language. Using the JDBC 3.0 API, you can access virtually any data source, from relational databases to spreadsheets and flat files. JDBC technology also provides a common base on which tools and alternate interfaces can be built.
 +
 +With the following script in a Stages dataset you can access the Stages mysql database on your local PC running Stages.
 +
 +<​code>​
 +Class.forName("​org.gjt.mm.mysql.Driver"​);​
 +var url = "​jdbc:​mysql://​localhost/​pkit"​
 +con = DriverManager.getConnection( url, "​root",​ "​pass"​ );
 +stmt = con.createStatement(
 +ResultSet.TYPE_SCROLL_SENSITIVE,​ResultSet.CONCUR_READ_ONLY);​
 +srs = stmt.executeQuery("​SELECT artifact_id FROM artifact"​);​
 +while (srs.next()) {
 +dataset.setColumnValue("​id",​srs.getInt("​artifact_id"​));​
 +dataset.storeResultRow();​
 +}
 +srs.close();​
 +stmt.close();​
 +con.close();​
 +</​code>​
 +
 +The JDBC driver must be in the Stages classpath in
 +
 +[install directory]\projectkit\tomcat\webapps\pkit\WEBINF\ platform\plugins \org.eclipse.birt.report.data.oda.jdbc_x.y.z\drivers