크기가 너무 커서 (600KB) 텍스트 파일이 있습니다.이 파일을 읽고 코드 전체를 내 데이터베이스로 보내야합니다. :오류 : 데이터 소스가 연결 설정을 거부했습니다. "연결이 너무 많습니다."
private static void readBigFileAndSendToDB() throws Exception {
Scanner s = new Scanner(new FileReader("tf1.txt"));
while (s.hasNextLine()) {
String eachLine = s.nextLine(); // each Line
sendBigFileToDB(eachLine);
} // (end of file).
System.out.println("Sent big file to DB");
s.close();
}
private static void sendBigFileToDB(String line) {
Connection con = null;
PreparedStatement ps = null;
String query = "Insert into BigFile(text) values ('" + line + "')";
try {
if (line != null) {
con = DriverManager.getConnection(...);
ps = con.prepareStatement(query);
ps.execute();
}
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
하지만 난이 프로그램을 실행할 때,이 예외가되었습니다가 발생
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
당신은 완료되었습니다. –