Multithreaded LOAD DATA INFILE problem
Posted by: Eli Sherman
Date: February 03, 2005 03:01AM

We are doing a database initializtion unsing multithreaded code that uses LOAD DATA IN FILE via JDBC. From time to time we incoutered an error code 13 for one of the files being loaded with the following message:
Caused by: java.sql.SQLException: File 'C:\Version2.0.2-28-patched\data\temp\import1107179898596\sbv_vul_preconditions.txt' not found (Errcode: 13)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
at com.mysql.jdbc.Statement.execute(Statement.java:883)

This is the code used to load the file:
String dataFileName = getCSVFileName(dataDir, tableName);
File dataFile = new File(dataFileName);
if (dataFile.length() < 3L) {
logger.debug("Batch file '" + dataFileName + "' does not exist or is empty");
return;
}
if (File.separatorChar == '\\')
dataFileName = dataFileName.replace('\\', '/');
String t = "LOAD DATA INFILE \"" + dataFileName + "\" REPLACE INTO TABLE " + ((mt == null)?ModelTypeEnum.getCoreDBTableName(tableName):mt.getDBTableName(tableName)) ;
logger.debug("Importing csv file '" + dataFileName + "' using " + t);
Connection c = null ;
Statement s = null;
try {
c = DBConnection.getConnection(mt) ;
s = c.createStatement();
s.execute("ALTER TABLE " + tableName + " DISABLE KEYS") ;
s.execute("SET FOREIGN_KEY_CHECKS = 0") ;
s.execute("SET UNIQUE_CHECKS = 0") ;
s.execute("SET AUTOCOMMIT = 0") ;
s.execute(t);
s.execute("SET UNIQUE_CHECKS = 1") ;
s.execute("SET FOREIGN_KEY_CHECKS = 1") ;
s.execute("ALTER TABLE " + tableName + " ENABLE KEYS") ;
} catch (SQLException e) {
File f = new File(dataFileName);
boolean exists = f.exists() ;
SQLException e1 = new SQLException("Failed to import csv file '" + dataFileName + "' The file " + (exists?(" exists with size " + f.length()):" does not exist")) ;
e1.initCause(e) ;
throw e1 ;
} finally {
DBConnection.close(s, c);
}
}

AS you can see we are checking the existence of the file before the load and in case of an exception. Inspite the error code the file exists, the user has File premission infact the proccess manage to load the other tables.
Do any one incoutered this problem? Any thoughts?
Thanks

Options: ReplyQuote


Subject
Written By
Posted
Multithreaded LOAD DATA INFILE problem
February 03, 2005 03:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.