All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.yadickson.autoplsp.db.util.FindTableImpl Maven / Gradle / Ivy

Go to download

Maven plugin to generate Java classes from StoredProcedure and Functions in Database

There is a newer version: 1.8.20
Show newest version
/*
 * 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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy