com.github.yadickson.autoplsp.db.util.FindTableImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autoplsp Show documentation
Show all versions of autoplsp Show documentation
Maven plugin to generate Java classes from StoredProcedure and Functions in Database
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.github.yadickson.autoplsp.db.util;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import com.github.yadickson.autoplsp.db.bean.TableBean;
import com.github.yadickson.autoplsp.handler.BusinessException;
/**
*
* @author Yadickson Soto
*/
public class FindTableImpl implements FindTable {
@Override
public List getTables(Connection connection, String sql) throws BusinessException {
List list = new ArrayList();
if (connection == null) {
return list;
}
QueryRunner run = new QueryRunner();
ResultSetHandler> h = new BeanListHandler(TableBean.class);
try {
list = run.query(connection, sql, h);
} catch (SQLException ex) {
throw new BusinessException("[FindTableImpl] Error find attributes", ex);
}
return list;
}
}