在数据库Oracle中连接

时间:2018-02-22 12:13:07

标签: java android oracle

我正在创建一个连接到我的oracle数据库的类。但是,我必须从我的银行访问的信息是:用户,密码,主机,端口和服务名称,我正在尝试连接到银行并返回下一个错误:

java.sql.SQLException: Exceção de E/S: The Network Adapter could not establish the connection

类别:

private static final String DEFAULT_URL = "jdbc:oracle:thin:@//rachml-scan.redetendencia.com.br:1521:backofficeint.redetendencia.com.br";
//HOST:rachml-scan.redetendencia.com.br
//Port: 1521
//Service Name: backofficeint.redetendencia.com.br

private static final String DEFAULT_USERNAME = "";
private static final String DEFAULT_PASSWORD = "";

 public Connection getConnection() throws ClassNotFoundException, SQLException
    {
        Connection conn = null;
        try
        {
            Class.forName("oracle.jdbc.OracleDriver");
            conn = DriverManager.getConnection(DEFAULT_URL,DEFAULT_USERNAME,DEFAULT_PASSWORD);
        }
        catch (ClassNotFoundException erroClass) {
            System.out.println("Classe Driver JDBC não foi localizado, erro = "
                    + erroClass);
        }
        catch (SQLException erroSQL) {
            System.out.println("Erro de conexão com o Banco de dados, erro = "
                    + erroSQL);
        }
        return conn;
    }

有谁知道你的解决方案?

0 个答案:

没有答案