Boa tarde, eu estou tentando realizar uma conexão no postgreSQL, porém estou enfrentando um problema: segue abaixo o meu código.
[code]import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
-
@author matakura
*/
public class DaoConnectionFactory {private static final String DRIVER_POSTGREE = “org.postgresql.Driver”;
private static final String POSTGREE_PROTOCOL = “jdbc:postgresql://”;private DaoConnectionFactory()
{}
/**-
Returns a connection to the specified driver.
/
public static Connection getConnection(String serverIpNumber, String esquemaDeBanco ,String portNumber, String user, String passwd)
{
try
{
/*
* Loads the driver.
*/
DaoConnectionFactory.loadDriver(DRIVER_POSTGREE);/** * Creates and returns the connection. */ Connection connection = DriverManager.getConnection(POSTGREE_PROTOCOL + serverIpNumber + ":" + portNumber + "/" + esquemaDeBanco, user, passwd); return connection;
}
catch(NullPointerException nullPointerException)
{
nullPointerException.printStackTrace();
return null;
}
catch(SQLException sQLException)
{
sQLException.printStackTrace();
return null;
}
}
/**
- Loads the driver connection.
*/
private static void loadDriver(String urlClass)
{
try
{
Class.forName(urlClass);
}
catch(NullPointerException nullPointerException)
{
nullPointerException.printStackTrace();
}
catch(ClassNotFoundException classNotFoundException)
{
classNotFoundException.printStackTrace();
}
}
}
-
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
/**
*
-
@author matakura
*/
public class Misturador {private HashMap<Integer, Integer> input_to_output;
private HashMap<Integer, Integer> output_to_input;private Misturador()
{
try
{
Connection myConnection = DaoConnectionFactory.getConnection(“localhost”, “Criptografia”, “5432”, “root”, “6296455426”);Statement myStatement = myConnection.createStatement(); ResultSet myResultSet = myStatement.executeQuery("SELECT * FROM pessoa" ); while(myResultSet.next()) { System.out.println(myResultSet.getString(1)); } } catch(NullPointerException nullPointerException) { nullPointerException.printStackTrace(); } catch(SQLException sQLException) { sQLException.printStackTrace(); }
}
public static void main(String args[])
{
Misturador m = new Misturador();
}
}
[/code]
Quando eu executo o Misturador eu recebo a seguinte mensagem de erro:
org.postgresql.util.PSQLException: ERRO: relação “pessoa” não existe
Posição: 15
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at br.ufpa.misturador.Misturador.<init>(Misturador.java:32)
at br.ufpa.misturador.Misturador.main(Misturador.java:50)
Eu já adcionei a relação pessoa no banco de dados Criptografia. Eu não sei exatamente se o erro está no meu código ou se eu não estou adcionando corretamente essa relação pessoa que na minha opnião é a mesma coisa que uma tabela.
Eu estou utilizando pgAdmin III lá eu criei um Database chamado dentro Criptografia, depois criei no schemas um schema chamado elGamal e dentro dele criei a tabela pessoa, mas me é informado que a relação pessoa não existe quando eu executo o código. Se vocês puderem me ajuda eu agradeço.