Code for bulk insertion of values from file to database the error is
"Syntax error: Encountered "load" at line 1, column 1.
package Rdbms;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class jdbcaddfromfile {
private static final String DB_DRIVER = "org.apache.derby.jdbc.ClientDriver";
private static final String DB_CONNECTION = "jdbc:derby://localhost:1527/Oracle;create=true;";
private static final String DB_USER = "Android";
private static final String DB_PASSWORD = "java";
public static void main(String[] argv) {
try {
insertRecordIntoTable();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
private static void insertRecordIntoTable() throws SQLException {
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String insertTableSQL = "load data infile 'c:/temp/some_data.txt' \n" +
"replace \n" +
"into table GOOD \n" +
"columns terminated by '\\t' \n" +
"ignore 1 lines";;
try {
dbConnection = getDBConnection();
preparedStatement = dbConnection.prepareStatement(insertTableSQL);
preparedStatement.executeUpdate();
System.out.println("Record is inserted into GOOD table!");
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (dbConnection != null) {
dbConnection.close();
}
}
}
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
try {
dbConnection = DriverManager.getConnection(
DB_CONNECTION, DB_USER,DB_PASSWORD);
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return dbConnection;
}
private static java.sql.Timestamp getCurrentTimeStamp() {
java.util.Date today = new java.util.Date();
return new java.sql.Timestamp(today.getTime());
}
}
package Rdbms;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class jdbcaddfromfile {
private static final String DB_DRIVER = "org.apache.derby.jdbc.ClientDriver";
private static final String DB_CONNECTION = "jdbc:derby://localhost:1527/Oracle;create=true;";
private static final String DB_USER = "Android";
private static final String DB_PASSWORD = "java";
public static void main(String[] argv) {
try {
insertRecordIntoTable();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
private static void insertRecordIntoTable() throws SQLException {
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String insertTableSQL = "load data infile 'c:/temp/some_data.txt' \n" +
"replace \n" +
"into table GOOD \n" +
"columns terminated by '\\t' \n" +
"ignore 1 lines";;
try {
dbConnection = getDBConnection();
preparedStatement = dbConnection.prepareStatement(insertTableSQL);
preparedStatement.executeUpdate();
System.out.println("Record is inserted into GOOD table!");
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (dbConnection != null) {
dbConnection.close();
}
}
}
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
try {
dbConnection = DriverManager.getConnection(
DB_CONNECTION, DB_USER,DB_PASSWORD);
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return dbConnection;
}
private static java.sql.Timestamp getCurrentTimeStamp() {
java.util.Date today = new java.util.Date();
return new java.sql.Timestamp(today.getTime());
}
}
"
package Rdbms;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class jdbcaddfromfile {
private static final String DB_DRIVER = "org.apache.derby.jdbc.ClientDriver";
private static final String DB_CONNECTION = "jdbc:derby://localhost:1527/Oracle;create=true;";
private static final String DB_USER = "Android";
private static final String DB_PASSWORD = "java";
public static void main(String[] argv) {
try {
insertRecordIntoTable();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
private static void insertRecordIntoTable() throws SQLException {
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String insertTableSQL = "load data infile 'c:/temp/some_data.txt' \n" +
"replace \n" +
"into table GOOD \n" +
"columns terminated by '\\t' \n" +
"ignore 1 lines";;
try {
dbConnection = getDBConnection();
preparedStatement = dbConnection.prepareStatement(insertTableSQL);
preparedStatement.executeUpdate();
System.out.println("Record is inserted into GOOD table!");
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (dbConnection != null) {
dbConnection.close();
}
}
}
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
try {
dbConnection = DriverManager.getConnection(
DB_CONNECTION, DB_USER,DB_PASSWORD);
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return dbConnection;
}
private static java.sql.Timestamp getCurrentTimeStamp() {
java.util.Date today = new java.util.Date();
return new java.sql.Timestamp(today.getTime());
}
}