Access データベース (.mdb) で「コメント」という名前の列の値を取得しようとすると、次のエラーが表示されます。
Offence: copying data
ERROR - Offence TABLE
java.sql.SQLSyntaxErrorException: ORA-00904: "Comment": invalid identifier
これは私のコードです:
public static void copyOffenceTable()
{
PreparedStatement updateOffenceTypeTable = null;
//Set up "insert" string
String insertString = "INSERT INTO Offence "
+ "(id, OffenceName, status, OffenceSuburb, OffenceDate, FirstName, LastName, \"Comment\", OffenderAddress, OffenderSuburb, OffenderPostcode, OffenderState, OffenderEmail, LicenceNumber, DOB, StaffIssuerID, OffenderPhone) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String MSAccessQuery = "SELECT * FROM Offence";
try
{
//create a query object for MSAccess
dbmsMSAccess.DBMSStatement = dbmsMSAccess.DBMSConnection.createStatement();
//Query the MSAccess database for extraction
dbmsMSAccess.DBMSResultSet = dbmsMSAccess.DBMSStatement.executeQuery(MSAccessQuery);
//make query object for Oracle
dbmsOracle.DBMSOracleStatement = dbmsOracle.DBMSOracleConnection.createStatement();
dbmsOracle.DBMSOracleStatement.execute("TRUNCATE TABLE Offence");
dbmsOracle.DBMSOracleConnection.setAutoCommit(false);
updateOffenceTypeTable = dbmsOracle.DBMSOracleConnection.prepareStatement(insertString);
System.out.println("Offence: copying data");
while(dbmsMSAccess.DBMSResultSet.next())
{
updateOffenceTypeTable.setInt(1, dbmsMSAccess.DBMSResultSet.getInt("id") );
updateOffenceTypeTable.setString(2, dbmsMSAccess.DBMSResultSet.getString("OffenceName") );
updateOffenceTypeTable.setString(3, dbmsMSAccess.DBMSResultSet.getString("Status") );
updateOffenceTypeTable.setString(4, dbmsMSAccess.DBMSResultSet.getString("OffenceSuburb") );
updateOffenceTypeTable.setDate(5, dbmsMSAccess.DBMSResultSet.getDate("OffenceDate") );
updateOffenceTypeTable.setString(6, dbmsMSAccess.DBMSResultSet.getString("FirstName") );
updateOffenceTypeTable.setString(7, dbmsMSAccess.DBMSResultSet.getString("LastName") );
updateOffenceTypeTable.setString(8, dbmsMSAccess.DBMSResultSet.getString("COMMENT") );
updateOffenceTypeTable.setString(9, dbmsMSAccess.DBMSResultSet.getString("OffenderAddress") );
updateOffenceTypeTable.setString(10, dbmsMSAccess.DBMSResultSet.getString("OffenderSuburb") );
updateOffenceTypeTable.setInt(11, dbmsMSAccess.DBMSResultSet.getInt("OffenderPostcode") );
updateOffenceTypeTable.setString(12, dbmsMSAccess.DBMSResultSet.getString("OffenderState") );
updateOffenceTypeTable.setString(13, dbmsMSAccess.DBMSResultSet.getString("OffenderEmail") );
updateOffenceTypeTable.setInt(14, dbmsMSAccess.DBMSResultSet.getInt("LicenceNumber") );
updateOffenceTypeTable.setDate(15, dbmsMSAccess.DBMSResultSet.getDate("DOB") );
updateOffenceTypeTable.setInt(16, dbmsMSAccess.DBMSResultSet.getInt("StaffIssuerID") );
updateOffenceTypeTable.setInt(17, dbmsMSAccess.DBMSResultSet.getInt("OffenderPhone") );
updateOffenceTypeTable.executeUpdate();
}
System.out.println("Offence: ACCESS DATA COPIED TO ORACLE\n");
}
catch(Exception X)
{
System.out.println("ERROR - Offence TABLE");
X.printStackTrace();
}
}
jdbcを介してキーワードでもある列を参照する方法はありますか?
アポストロフィと引用符の間に「コメント」を入れてみました。
助言がありますか?
EDIT:値は、おそらく同一のテーブルを持つOracleデータベースに配置されています。