// Coneccion a Base de datos Postgres
// Se debe Importar import java.sql.*;
Connection co;
Statement st;
ResultSet rs;
int ret1;
try {
co = DriverManager.getConnection("jdbc:postgresql://localhost:5432/mn", "Sistema", "sistema");
st = co.createStatement();
rs = st.executeQuery("SELECT count(*) as SumaTotal FROM Tabla ");
while (rs.next()) {
ret1 =rs.getInt("SumaTotal "); //se traspasa el valor a una variable
}
rs.close();
st.close();
} catch (SQLException ex) {
Logger.getLogger(Ventas.class.getName()).log(Level.SEVERE, null, ex);
}
|