// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   DAOUtil.java

package com.keyshop.pub.dao;

import com.keyshop.pub.util.ToolUtil;
import java.sql.*;
import java.util.ArrayList;
import javax.sql.DataSource;

// Referenced classes of package com.keyshop.pub.dao:
//            DAO

public class DAOUtil extends DAO
{

    public DAOUtil(DataSource ds)
    {
        super(ds);
    }

    public String[] getLineValues(String sql)
    {
        ArrayList list;
        Connection conn;
        PreparedStatement pstmt;
        ResultSet rs;
        String result[];
        list = new ArrayList();
        conn = null;
        pstmt = null;
        rs = null;
        result = (String[])null;
        SQLException e;
        String as[];
        try
        {
            conn = ds.getConnection();
            pstmt = conn.prepareStatement(sql);
            for(rs = pstmt.executeQuery(); rs.next(); list.add(rs.getString(1)));
            close(rs);
            close(pstmt);
            result = ToolUtil.ArrayToString(list);
            as = result;
        }
        finally
        {
            close(conn);
        }
        return as;
        e;
        close(rs);
        close(pstmt);
        rollback(conn);
        e.printStackTrace();
        return result;
    }

    public String getOneString(String sql)
    {
        Connection conn;
        PreparedStatement pstmt;
        ResultSet rs;
        String result;
        conn = null;
        pstmt = null;
        rs = null;
        result = null;
        SQLException e;
        String s;
        try
        {
            conn = ds.getConnection();
            pstmt = conn.prepareStatement(sql);
            rs = pstmt.executeQuery();
            if(rs.next())
                result = rs.getString(1);
            close(rs);
            close(pstmt);
            s = result;
        }
        finally
        {
            close(conn);
        }
        return s;
        e;
        close(rs);
        close(pstmt);
        rollback(conn);
        e.printStackTrace();
        return result;
    }

    public static void dbRollBack(Connection conn)
    {
        if(conn != null)
            try
            {
                conn.rollback();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
    }

    public static void dbClose(Connection conn)
    {
        if(conn != null)
            try
            {
                conn.close();
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }
    }
}
