quando tento executar a classe Testa Listagem recebo o erro abaixo: Exception in thread "main" java.lang.NullPointerException at org.hsqldb.DatabaseURL.parseURL(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source) at org.hsqldb.jdbc.pool.JDBCPooledDataSource.getPooledConnection(Unknown Source) at org.hsqldb.jdbc.JDBCPool.getConnection(Unknown Source) at br.com.raquelzinha.jdbc.ConnectionPool.getConnection(ConnectionPool.java:27) at br.com.raquelzinha.jdbc.TestaListagem.main(TestaListagem.java:15)
Código:
package br.com.raquelzinha.jdbc;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
public class TestaListagem {
public static void main(String[] args) throws SQLException{
ConnectionPool database = new ConnectionPool();
for(int i = 0; i<100; i++){
Connection connection = database.getConnection();
Statement statement = connection.createStatement();
boolean resultado = statement.execute("select * from Produto");
ResultSet resultSet = statement.getResultSet();
while (resultSet.next() == true)
{
int id = resultSet.getInt("id");
String nome = resultSet.getString("nome");
String descricao = resultSet.getString("descricao");
System.out.println(id);
System.out.println(nome);
System.out.println(descricao);
}
resultSet.close();
statement.close();
connection.close();
}
}
}