Salve pessoal!
Consigo conectar ao banco normalmente quando utilizo uma conexão direta em uma jsp, exemplo:
[code]<%
try {
Properties props = new Properties();
props.put(“user”, “USUARIO”);
props.put(“password”, “SENHA”);
props.put(“SetBigStringTryClob”, “true”);
DriverManager.registerDriver(new OracleDriver());
Connection oConnect = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.3:1521:sid", props);
oConnect.setAutoCommit(true);
PreparedStatement sConnect = oConnect.prepareStatement("SELECT MAX(C000_COD) + 1 AS C000_COD FROM C000");
ResultSet rConnect = sConnect.executeQuery();
if (rConnect.next()) {
out.println("QUANTIDADE: " + rConnect.getInt("c000_cod"));
}
rConnect.close();
sConnect.close();
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
%>[/code]
Porém quando utilizo uma classe para instanciar a conexão, ocorre um erro:
[code]public class Conexao {
public static final String ABD_SERVIDOR = "jdbc:oracle:thin:@192.168.0.3:1521:sid";
public static final String ABD_USUARIO = "USUARIO";
public static final String ABD_SENHA = "SENHA";
private Connection objConexao = null;
public Connection getInstance() {
if (this.objConexao == null) {
try {
Properties props = new Properties();
props.put("user", ABD_USUARIO);
props.put("password", ABD_SENHA);
props.put("SetBigStringTryClob", "true");
DriverManager.registerDriver(new OracleDriver());
Connection oConnect = DriverManager.getConnection(ABD_SERVIDOR, props);
oConnect.setAutoCommit(true);
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return this.objConexao;
}
}[/code]
[quote]HTTP Status 503 - AutenticarAssociada: java.lang.RuntimeException: java.sql.SQLException: Exceção de E/S: The Network Adapter could not establish the connection
type Status report
message AutenticarAssociada: java.lang.RuntimeException: java.sql.SQLException: Exceção de E/S: The Network Adapter could not establish the connection
description The requested service (AutenticarAssociada: java.lang.RuntimeException: java.sql.SQLException: Exceção de E/S: The Network Adapter could not establish the connection) is not currently available.
Apache Tomcat/5.5.9[/quote]
Alguém sabe me dizer porque ocorre este erro e como corrigí-lo?
Utilizo a versão do oracle 10g.