OLá consigo acessar o manager do hsql mais so consigo conectar através do Hsql Database Engine In-Memory: jdbc:hsqldb:mem:.loja-virtual Dessa maneira consigo realizar todas as operações, foi assim também no curso de spring, o que pode estar acontecendo? no type server gera a exceção abaixo:
java.sql.sqltransientconnectionexception java.net.connectexception
Meu código abaixo não está mostrando os dados inseridos na tabela.
package br.com.caelum.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestaListagem {
public static void main(String[] args) throws SQLException {
Connection connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/loja-virtual", "SA", "");
Statement statement = connection.createStatement();
boolean resultado = statement.execute("select * from Produto");
ResultSet resultSet = statement.getResultSet();
while (resultSet.next()) {
int id = resultSet.getInt("id");
String nome = resultSet.getString("nome");
String descricao = resultSet.getString("descricao");
System.out.println("id=" + id + ", nome=" + nome + ", descricao=" + descricao);
}
resultSet.close();
statement.close();
connection.close();
}
}
Exception in thread "main" java.sql.SQLTransientConnectionException: java.net.ConnectException: Connection refused: connect at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCConnection.(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at br.com.caelum.jdbc.TestaListagem.main(TestaListagem.java:12) Caused by: org.hsqldb.HsqlException: java.net.ConnectException: Connection refused: connect at org.hsqldb.ClientConnection.openConnection(Unknown Source) at org.hsqldb.ClientConnection.initConnection(Unknown Source) at org.hsqldb.ClientConnection.(Unknown Source) ... 6 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.hsqldb.server.HsqlSocketFactory.createSocket(Unknown Source) ... 9 more