Pessoal, tem como eu criar um dataset buscando informações de um banco de dados do Fluig? tabela PROCESS_OBSERVATION
Dataset=>
function createDataset(fields, constraints, sortFields) {
var newDataset = DatasetBuilder.newDataset();
log.info("QUERY: " + myQuery);
var dataSource = "/jdbc/dsHistoricoChamados";
var ic = new javax.naming.InitialContext();
var ds = ic.lookup(dataSource);
var created = false;
var myQuery = "select * from ML001459";
try {
var conn = ds.getConnection();
var stmt = conn.createStatement();
var rs = stmt.executeQuery(myQuery);
var columnCount = rs.getMetaData().getColumnCount();
while (rs.next()) {
if (!created) {
for (var i = 1; i <= columnCount; i++) {
newDataset.addColumn(rs.getMetaData().getColumnName(i));
}
created = true;
}
var Arr = new Array();
for (var i = 1; i <= columnCount; i++) {
var obj = rs.getObject(rs.getMetaData().getColumnName(i));
if (null != obj) {
Arr[i - 1] = rs.getObject(rs.getMetaData().getColumnName(i)).toString();
} else {
Arr[i - 1] = "null";
}
}
newDataset.addRow(Arr);
}
} catch (e) {
log.error("ERRO==============> " + e.message);
} finally {
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
}
return newDataset;
}
Domain.xml ==>
<datasource jta="false" jndi-name="java:/jdbc/dsHistoricoChamados" pool-name="dsHistoricoChamados" enabled="true" use-java-context="false">
<connection-url>jdbc:mysql://localhost:3306/minhabase</connection-url>
<driver>mysqlDriver</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>15</max-pool-size>
</pool>
<security>
<user-name>usuário do bd</user-name>
<password>senha</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>30000</blocking-timeout-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>