I am getting "JdbcSQLSyntaxErrorException: Column "REAL" not found" exception on inserting a record in the H2 Db table from an Springboot project.
My query is:
INSERT INTO `bharatqr_provider_config` (`id`, `provider_name`, `provider_base_url`, `provider_username`, `provider_password`, `provider_key`, `status`, `created_by`, `created_time`, `lock_id`, `modified_by`, `modified_time`, `timezone`, `auto_check_status_enabled`, `upi_check_status_enabled`,`terminal_type`,`qr_type`) VALUES (1,'HDFC', 'http://localhost:6061','','','','ACTIVE','me','2017-12-06 15:23:42',1,'me', '2017-12-06 15:23:42','IST', 0, 1,"REAL","INTERNAL"), (2,'DUMMY','http://localhost:6061','me','me','me','ACTIVE','me', '2018-01-10 12:24:03',1,'me','2018-01-10 12:24:03', NULL, 0, 0,"NONE","INTERNAL");
From the exception It's saying that Column "REAL" not found", But "REAL" is not the column name it's a value which have to insert in the column terminal_type.
"REAL" and "INTERNAL" are not values, they are identifiers in every standard-compliant database system.
Character string literals in SQL are surrounded by single quotes, you need to write them as 'REAL' and 'INTERNAL'.
Related
I am using a SimpleJdbcInsert to insert rows into a PostgreSQL database. However, I get an the following error:
Caused by: org.postgresql.util.PSQLException: ERROR: INSERT has more
target columns than expressions.
org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [INSERT
INTO product (product_id,product_name,product_code,in_
stock,product_category) VALUES(?)]; SQL state [25P02]; error code [0];
ERROR: current transaction is aborted, commands ignored until end of
transaction block; nested exception is
org.postgresql.util.PSQLException: ERROR: current transaction is
aborted, commands ignored until end of transaction block
The number columns is exactly the same as the number of values I am trying to insert when I print out the MapSqlParameterSource object shown below:
Parameters Names ::
[
product_id,
product_name,
product_code,
in_ stock,
product_category
]
Parameters Values :: [{
product_id=1518,
product_name=Sofa,
product_code=150,
in_stock=true,
product_category=null,
}]
The product_id is the primary key and it is not null. Could the problem be because I am not using an auto-generated primary key? I still do not understand why that would be a problem.
The columns shown in the error message are precisely the same as the columns in the parameter list I'm printing. The values also tally with the number of columns as well, so I'm really baffled why PostgreSQL is giving this error. Please help!
I was able to solve it with a different solution to using Spring JDBC.
Am trying execute a sql query on oracle database and inserting the result into another table, for my trial am just performing a simple query as
SELECT 1 AS count
FROM dual
and trying to insert that into a single column table which has the name COUNT.
The content of the record on Nifi seems to be as follows
[
{
"COUNT" : "1"
}
]
but the logs keeps throwing the error
due to java.sql.SQLDataException:
None of the fields in the record map to the columns defined by
the schema_name.table_name table:
any ideas ?
I believe you get that same error message if your table name doesn't match. The Translate Field Names property only translates the fields (columns), not the table name. Try specifying the schema/table in uppercase to match what Oracle is expecting.
I am not sure if its the BizTalk error, thought I will check. I am trying to insert blank spaces in to the Oracle Table through the scripting functions
public string GetMXValue()
{
return " ";
}
So it returns 32 blank spaces to insert in to a field in Oracle Table. But we get an error
Send Port. Details:"Microsoft.ServiceModel.Channels.Common.TargetSystemException: ORA-01400: cannot insert NULL into ("DEVLAW"."GLTRANSREL"."MX_VALUE_02")
I am doing the right way to insert the blankspaces? I even tried using the String functiods and passed 32 blankspaces. Are black spaces treated as NULL in Oracle?
The field exists in the table
I got a column message with data_type = VARCHAR2. It already has some data stored. I want this column to be of type NCLOB. Code-Set for this column should be UTF-8.
I did the following:
added a column tempmessage to my table of type NCLOB
filled tempmessage with message
renamed message to message old (so that i don't use any data (until it works))
renamed tempmessage to message
Then i tried out my integration tests and i got the exception:
java.sql.BatchUpdateException: ORA-01400: Insert of NULL into ("BATCH_LOG"."MESSAGEOLD") not possible.
What have I done wrong?
The original column was defined as NOT NULL, when you renamed that to MESSAGEOLD, this constraint was kept. You need to remove the NOT NULL constraint from the MESSAGEOLD column:
ALTER TABLE foo MODIFY MESSAGEOLD NULL;
The problem is an existing Oracle table (that I cannot change) with mixed case column names, eg
create table BADTAB ( ID varchar(16) not null, "Name" varchar2(64),
constraint I_BADTAB_PK PRIMARY KEY(ID) );
When I try to do a DBUnit INSERT from an XML dataset it fails
Caused by: java.sql.SQLException: ORA-00904: "NAME": invalid identifier
When I enclose the column name in quotes it fails
<column>"Name"</column>
org.dbunit.dataset.NoSuchColumnException: BADTAB."NAME" - (Non-uppercase input column: "ReadingsPres") in ColumnNameToIndexes cache map.
Note that the map's column names are NOT case sensitive.
at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:117)
...
QUESTION:
How can I override DBUnit's column metadata to make it recognize the lowercase column name?
What classes do I override and how do I inject them into the DBUnit test run?
There have been some previous discussions around this org.dbunit.dataset.NoSuchTableException: Did not find table 'xxx' in schema 'null'
You should be able to set a database configuration property to cater for case-sensitive names:
DatabaseConfig config = databaseConnection.getConfig();
config.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, true);