Pessoal, boa tarde.
Estou com um problema e já tentei de vairas formas resolver, mas sem sucesso.
Criei uma Classe Java para ler um arquivo csv e depois inserir os valores em um banco de dados oracle.
Quando executado o arquivo, ele insere alguns valores e depois apresenta o seguinte erro:
Conexao OK
Conexao OK
Conexao OK
Conexao OK
Exception in thread “main” java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:774)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:688)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at obama.Exercicios.Leitor1.main(Leitor1.java:56)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:271)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:317)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1438)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:518)
... 6 more
C:\Users\Ativo - Fabio\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
FALHA NA CONSTRUÇÃO (tempo total: 2 segundos)
#################################################################
Este é o código completo, se alguém já passou pelo mesmo problema, poderia dar uma luz da solução, desde já agradeço
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package obama.Exercicios;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Leitor1 {
String drive = "oracle.jdbc.driver.OracleDriver";
Connection conexao;
Statement statement;
ResultSet resultset;
public static void main(String[] args) throws ClassNotFoundException, SQLException {
try {
FileInputStream arquivo = new FileInputStream("C:\\Arquivos\\IMPFUNC.csv");
InputStreamReader input = new InputStreamReader(arquivo);
BufferedReader br = new BufferedReader(input);
String linha;
do {
linha = br.readLine();
if (linha != null) {
String[] campo = linha.split(";");
String mesref = campo[0];
String chave = campo[1];
String EmployeeID = campo[2];
String EmployeeFullName = campo[3];
String GivenName = campo[4];
String FamilyName = campo[5];
String EmployeeOrganization = campo[6];
String JobCode = campo[7];
String JobTitle = campo[8];
String DiscretionaryTitle = campo[9];
String Function = campo[10];
String SpecialityArea = campo[11];
String GlobalCareerLevel = campo[12];
String WorkLocation = campo[13];
Class.forName("oracle.jdbc.driver.OracleDriver");
try (Connection con = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:xe", "fabio", "Leticia1")) {
System.out.println("Conexao OK");
try (Statement st = con.createStatement()) {
ResultSet rs = st.executeQuery("INSERT into TB_FUNCORACLE ( MESREF ) VALUES ("+mesref+")");
//int rs = st.executeUpdate("INSERT into TB_FUNCORACLE ( MESREF ) VALUES ("+mesref+")");
st.close();
con.close();
}
}
}
} while (linha != null);
} catch (IOException e) {
System.out.println("Erro ao ler Arquivo");
}
}
}