/// add your custom import statements here
import java.sql.*;


public class DBAcesso  
{
	public DBAcesso(Connection conn,Statement sta,String campos,String tabelas)
	{
		con=conn;
		st=sta;
	
	}
	public static void main(String[] args) 
	{
	   	Connection conn=null;
		Statement sta=null;
		try 
		{
			Class.forName("oracle.jdbc.driver.OracleDriver" );
			conn = DriverManager.getConnection(  "jdbc:oracle:thin:@172.20.0.29:1521:orcl", "Armazem", "Armazem" );
			sta = conn.createStatement();
		} catch (Exception e) 
		{
			System.out.println(e);
		}

		DBAcesso db = new DBAcesso(conn,sta,"campos","tabela");
		System.out.println(db.getTotalLinhas());
    }


    public int getTotalLinhas()
    {
		int nTot;
		try 
		{
			Statement lst = con.createStatement();
		    ResultSet lrs = lst.executeQuery( "select count(*) nRec from Armazem " ) ;
		    lrs.next();
		    nTot = lrs.getInt(1) ;
		    lrs.close();
		    lst.close();
		} catch (Exception e) 
		{ 
			nTot = 0; 
		}
	    return nTot;
    }


    public boolean proximo()
    {   
		boolean bRet = false;
		try 
		{
			bRet = rs.next(); 
		} catch (Exception e) {} 
        return bRet;
    }


    public java.lang.String getString( int col )
    {
		String sRet="";
		try 
		{
			sRet = rs.getString(col); 
		} catch (Exception e) {} 
        return sRet;
    }


    public void PrimeiroRegistro()
    {
		try 
		{
        	rs = st.executeQuery( "select DSC_ARMAZ from Armazem") ;		  
			rs.next(); 
		} catch (Exception e) {} 
    }


    public void fecha()
    {
		try 
		{
			rs.close();
			st.close();
			con.close();
		} catch (Exception e) {} 

    }

	Connection con;
	Statement st;
	ResultSet rs;
	boolean bfirst;

}

