Java and acess

Forum destinado a Linguagem JAVA! Classes, orientação a objeto, conexão com banco, chamada de procedures, etc

Poston Wed, 15 Jun 2016 6:41 pm

good night, I'vê been trying to be counted the rows from a database table and that is returned to me to then give the volar a count in java.
My problem is that I insert the sql code and it didn't give me the value of the count of columns.

I'll leave here the code.

Code: Select all
            String query =
                    "SELECT COUNT(*) FROM Clientes=";
            System.out.println("query: " +query);
can someone help?

Poston Tue, 21 Jun 2016 5:13 pm

Brother, create a class like this:
Code: Select all
//Create a Statement class to execute the SQL statement
Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT COUNT(*) AS COUNT FROM

while( {
    System.out.println("The count is " + rs.getInt("COUNT"));

Location: Brasília

Adriano Alves
---Para cada problema dificil existe uma solução simples.----

Return to Java

Who is online

Users browsing this forum: No registered users and 1 guest