Oi bom dia!
Estou tentando criar uma conexão no banco oracle mas estou tendo dificuldades.
Quando tento conectar o log de erro abaixo aparece:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: offset 12, count 25966, length 8192 at java.base/java.lang.String.checkBoundsOffCount(Unknown Source) at java.base/java.lang.String.(Unknown Source) at oracle.net.ns.Packet.extractData(Packet.java:439) at oracle.net.ns.RefusePacket.(RefusePacket.java:72) at oracle.net.ns.NSProtocol.connect(NSProtocol.java:360) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:553) at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:254) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528) at java.sql/java.sql.DriverManager.getConnection(Unknown Source) at java.sql/java.sql.DriverManager.getConnection(Unknown Source) at br.com.caelum.jdbc.TestaConexao.main(TestaConexao.java:11)
Alguém teria alguma ideia de como resolver?
Código:
package br.com.caelum.jdbc;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
public class TestaConexao {
public static void main(String[] args) throws SQLException {
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@ip:porta/nomeDB"); System.out.println("Abrindo uma conexão"); connection.close();
}
}