Weblogic CLOB column storing JSON - Error ORA-02290 - json

We are trying to save JSON string to the database column defined as CLOB. We get the below error:
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02290: check constraint (MYSCHEMA.MY_JSON_CHK) violated
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:466)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:407)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1113)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:546)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:269)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:603)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:234)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:55)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1006)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1316)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:5010)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:5136)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1519)
at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:170)
Version: Weblogic 12.2.1.2
Attempted two data types at application ORM layer for this column
java.sql.Clob & oracle.jbo.domain.ClobDomain
Direct update via SQL works good
Enabled & Disabled wrapping of datatype in weblogic
JDBC datasource.

I attempted to switch my EO (ORM) attribute from oracle.jbo.ClobDomain back to a plain String and this worked.

Related

azure data flow I cant pass json string to the sink

I'm using azure data factory to transform data, I have a derived column to process images.
iif(isNull(column1_images),
iif(isNull(column2_images),
iif(isNull(images),'N/A',toString(images))
,concat(toString(column12_images),' ','(',column2_type,')')),
concat(toString(column1_images),' ','(',column1_type,')'))
when I click on refresh buton I can see the result :
but when I pass this column to the sink I'M GETTING THIS ERROR :
Conversion from StringType to ArrayType(StructType(StructField(url,StringType,true)),false) not defined
can you tell me what is the problem please ?
The error you are getting because there is no Schema designed for the Sink. Hence, you need to use Derived column expression and create a JSON schema to convert the data. Check Building schemas using the expression builder.
You can also check this similar kind of thread for your reference.

Alternate solution to save as JSON datatype in postgres spring-boot + eclipselink

I am using eclipselink 2.6 with spring-boot JPA for persistance in postgres.
I am persisting a List of objects as a JSON column in database.Acording to this solution: eclipselink + #convert(json) + postgres + list property
I am able to save the data in postgres.
When the column is null, I get this exception:
Caused by: org.postgresql.util.PSQLException: ERROR: column "sample_column" is of type json but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
I can solve this issue by this answer:
Writing to JSON column of Postgres database using Spring / JPA
Q1: Is there an alternate solution other than setting this property stringtype=unspecified int url spring.datasource.url=jdbc:postgresql://localhost:5432/dbnam‌​e?stringtype=unspeci‌​fied
Q2: If not, How can I set stringtype=unspecified in application.prooerties of spring-boot rather than embedding it in the spring.datasource.url
The answer is yes, but is implementation-specific.
For example, in Tomcat, this attribute is called connectionProperties, you would therefore write:
spring.datasource.tomcat.connection-properties: stringtype=unspecified
From the Spring-Boot documentation.
It is also possible to fine-tune implementation-specific settings using their respective prefix (spring.datasource.tomcat., spring.datasource.hikari., spring.datasource.dbcp.* and spring.datasource.dbcp2.*). Refer to the documentation of the connection pool implementation you are using for more details.
If you are using spring-boot 1.4.1 or above,
add a data.sql file in resources folder,
-- IN H2 database, create a column as 'OTHER' data type,
-- if H2 fails to create a column as 'JSON' data type.
CREATE DOMAIN IF NOT EXISTS JSON AS OTHER;
This .sql file will be executed during startup of your application and will create a column with data type others in table for the 'json' data type columns in H2 database.

The data types nvarchar(max) and ntext are incompatible in the equal to operator.

I am new to hibernate.
I have a scenario where i am using Xstream frame work to export the tables into XML format and importing another instance of DB tables, where i have my application with Hibernate & spring.
One instance where one column of a table is nvarchar(max) in the db.
while i am inserting into the table from xml, it is failinging giving below error.
Caused by:
java.sql.SQLException: The data types nvarchar(max) and ntext are incompatible in the equal to operator.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery (JtdsPreparedStatement.java:778)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery (WrappedPreparedStatement.java:342)
at org.hibernate.persister.entity.AbstractEntityPersister.getDatabaseSnapshot(AbstractEntityPersister.java:1021)
at org.hibernate.engine.StatefulPersistenceContext.getDatabaseSnapshot(StatefulPersistenceContext.java:246)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:189)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:512)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:80)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:772)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
I used the above mentioned provided solutions ...but none is of help for me.
i am using SQL 2008 server as DB and hibernate 3 jars.
It is working fine upto 4000 chars, but column exceeds it is not working.
and giving above exception
Please do advice how to solve this problem.

Conversion error between "DT_DBTIME2" and "DT_WSTR" for "ETAHour"

I have a SQL query that returns me a "time(0)". I load that into SSIS, and it gets automatically converted to a "DT_DBTIME2", which is okay. I can transform it to any other type without error using a data conversion data flow item.
My problem is that when I try to insert that value into a "time(0)" field of a table, it gives me the following error:
The OLE DB provider used by the OLE DB adapter cannot convert between
types "DT_DBTIME2" and "DT_WSTR" for "ETAHour".
When I mouse over the fields in the OLE DB Destination component, it clearly says that the source field is a DT_DBTIME2 and the destination field is a DT_DBTIME2. I really wonder where this conversion error comes from.
Make sure that you are specifying provider in connection string.
In my case I'm using MSSQL 2012 Enterprise. It works on local machine, but after updating connection string in dtsconfig in installer it fails with error above.
Setting OLE DB provider fixed issue, in my case:
Provider=SQLNCLI11.1
Had a similar issue after importing an existing SSIS project created a new connection string and after I switched had multiple errors.
Changing the OLE DB provider to SQL Server Native Client 11.0 solved issue which is the equivalent of setting SQLNCLI11.1
enter image description here

SSIS (2008R2) import from mssql to mysql failing due to a date column

I have an oledb connection to mssql and an ado.net destination (with odbc driver used) to mysql. The tables are exectly the same and all the columns are working bar one.
The error message received is:
[ADO NET Destination [325]] Error: An exception has occurred during data insertion, the message returned from the provider is: Unable to cast object of type 'System.DateTime' to type 'System.Char[]'.
I've seen similar questions on other data types but the resolution of changing to string does not work here. If I convert to string (has to be length 29 otherwise the conversion step fails) I get the following error message:
[ADO NET Destination [325]] Error: An exception has occurred during data insertion, the message returned from the provider is: ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.15]Incorrect datetime value: '2011-03-21 11:23:48.573000000' for column 'LastModificationDate' at row 1
Other potentially relevant details:
connection driver- {MySQL ODBC 5.1 Driver}
script run before dataflow - set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'
Other datetime columns are working
This column has a reasonably high proportion of nulls
mssql spec: [LastModificationDate] [datetime] NULL
mysql spec: LastModificationDate datetime NULL
Has anyone had experience with this issue and could provide some advice on resolving it?
Can you try converting it to string on sql server side in your query using:
convert(char(10),LastModificationDate,111)+' '+convert(char(8),LastModificationDate,108)
This works for me all the time.
I got the same big headache this week. I tried many ways. Thanks God, finnally, one of them worked. Hope it could help you a little bit.
For some columns with the data type of Int, datetime, decimal....,here, I identified as ColumnA, and I used it as datetime type.
1.in Data Flow Source, use SQL Command to retrieve data. Sth like select isnull(ColumnA,'1800-01-01') as ColumnA, C1, C2, ... Cn from Table
Make sure to use Isnull function for all columns with the datatype mentioned before.
2.Excute the SSIS pkg. It should work.
3.Go back to Control Flow, under the data flow task, add SQL Task control to replace the data back. I mean, update the ColumnA from '1800-01-01' to null again.
That works for me. In my situation, I cannot use ignore failure option. Because if I do, I will lose thousands rows of data.