MyBatis - Insert with TypeHandler - java.lang.ClassNotFoundException - insert

Mapper.xml
<insert id = "insertVacation" parameterType = "Vacation">
INSERT INTO ferias (audit_dt, audit_usuario, audit_st_ope,
feri_cfun_cd_mat, feri_fepa_ano, feri_sq, feri_dt_inicio, feri_dt_fim,
feri_fsfr_cd, feri_st_pag, feri_ds_obs, feri_st_ad13sal, feri_dt_pagref,
feri_st_autorizado, fepa_st_recebe_adferias, feri_fl_periodo_ativo,
feri_dt_programacao, feri_dt_autorizacao, feri_tp_programacao,
feri_fl_adiantamento_durante, feri_fl_13_durante )
VALUES (#{auditDate, typeHandler="br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"}, #{auditUser}, #{auditStatus}, #{userCode},
#{currentYear}, #{sequencial}, #{initialPeriod}, #{finalPeriod},
#{status}, #{paymentStatus}, #{note}, #{advance13th}, #{paymentDate},
#{statusAuthorized}, #{additional}, #{activePeriod}, #{scheduleDate},
#{authorizationDate}, #{typeProgramming}, #{advanceVacation},
#{advance13thVacation} )
</insert>
mybatis-config.xml
<typeHandlers>
<typeHandler javaType="org.joda.time.DateTime" jdbcType="DATE" handler="br.gov.df.terracap.grh.util.DateTimeTypeHandler"/>
<typeHandler javaType="org.joda.time.LocalDateTime" jdbcType="TIMESTAMP" handler="br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"/>
</typeHandlers>
Error when test the Insert
### Error updating database. Cause:
org.apache.ibatis.builder.BuilderException: Error resolving class .
Cause: org.apache.ibatis.type.TypeException: Could not resolve type
alias '"br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"'.
Cause: java.lang.ClassNotFoundException: Cannot find class:
"br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler" ### Cause:
org.apache.ibatis.builder.BuilderException: Error resolving class .
Cause: org.apache.ibatis.type.TypeException: Could not resolve type
alias '"br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"'.
Cause: java.lang.ClassNotFoundException: Cannot find class:
"br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"
org.apache.ibatis.exceptions.PersistenceException

VALUES (#{auditDate, typeHandler="br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler"}
Correct:
VALUES (#{auditDate,
typeHandler=br.gov.df.terracap.grh.util.LocalDateTimeTypeHandler}
*without quotes

Related

Aggregate query in Presto on Redshift's view failing with error org.postgresql.util.PSQLException: ERROR: transaction is read-only

When querying from presto on to redshift views with aggregate query we are getting org.postgresql.util.PSQLException: ERROR: transaction is read-only exception
We have a view
select count(col1) from redshift.public.my_view
in our redshift which we are trying to access from presto and below is the exception full stacktrace
com.facebook.presto.spi.PrestoException: ERROR: transaction is read-only
Detail:
at com.facebook.presto.plugin.jdbc.JdbcRecordCursor.handleSqlException(JdbcRecordCursor.java:236)
at com.facebook.presto.plugin.jdbc.JdbcRecordCursor.<init>(JdbcRecordCursor.java:95)
at com.facebook.presto.plugin.jdbc.JdbcRecordSet.cursor(JdbcRecordSet.java:59)
at com.facebook.presto.spi.RecordPageSource.<init>(RecordPageSource.java:37)
at com.facebook.presto.split.RecordPageSourceProvider.createPageSource(RecordPageSourceProvider.java:42)
at com.facebook.presto.split.PageSourceManager.createPageSource(PageSourceManager.java:56)
at com.facebook.presto.operator.TableScanOperator.getOutput(TableScanOperator.java:239)
at com.facebook.presto.operator.Driver.processInternal(Driver.java:379)
at com.facebook.presto.operator.Driver.lambda$processFor$8(Driver.java:283)
at com.facebook.presto.operator.Driver.tryWithLock(Driver.java:675)
at com.facebook.presto.operator.Driver.processFor(Driver.java:276)
at com.facebook.presto.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:1077)
at com.facebook.presto.execution.executor.PrioritizedSplitRunner.process(PrioritizedSplitRunner.java:162)
at com.facebook.presto.execution.executor.TaskExecutor$TaskRunner.run(TaskExecutor.java:483)
at com.facebook.presto.$gen.Presto_0_219____20190520_105106_1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.postgresql.util.PSQLException: ERROR: transaction is read-only
Detail:
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:561)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:419)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:304)
at com.facebook.presto.plugin.jdbc.JdbcRecordCursor.<init>(JdbcRecordCursor.java:92)
... 16 more
select count(mycol) from redshift.public.my_view
actual results we need to get count from the view

Spring JPA Oracle SUBSTRING

I'm using a custom #Query with Spring JPA like this:
#Query(value = "select ua from USER_ACCOUNT ua where SUBSTRING(ssn, -4, 4) = :ssn and last_nm = :lastName and birth_dt = :dateOfBirth")
UserAccount findByLastFourOfSSNAndLastNameAndDateOfBirth(#Param("ssn") String lastFourOfSSN, #Param("lastName") String lastName, #Param("dateOfBirth") Date dateOfBirth);
It works without any problems when I run it locally, but as soon as I deploy it out to the development environment I get:
[2017-12-19T23:02:59,048] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper SQL Error: 904, SQLState: 42000
[2017-12-19T23:02:59,048] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper ORA-00904: "SUBSTRING": invalid identifier
[2017-12-19T23:02:59,049] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[User Store] Servlet.service() for servlet [User Store] in context with path [] threw exception [org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
java.sql.SQLSyntaxErrorException: ORA-00904: "SUBSTRING": invalid identifier
The development environment is pretty much identical to my local. Same database, same version of Tomcat. Am I just missing something obvious here?
EDIT: SQL being generated:
select useraccoun0_.GUID as GUID1_5_, useraccoun0_.CREATED_BY as CREATED_BY2_5_, useraccoun0_.CREATED_DT as CREATED_DT3_5_, useraccoun0_.DB_NOTE as DB_NOTE4_5_, useraccoun0_.LAST_CHANGED_BY as LAST_CHANGED_BY5_5_, useraccoun0_.LAST_CHANGED_DT as LAST_CHANGED_DT6_5_, useraccoun0_.ACCOUNT_RECOVERY_EMAIL as ACCOUNT_RECOVERY_E7_5_, useraccoun0_.ACCOUNT_RECOVERY_PHONE as ACCOUNT_RECOVERY_P8_5_, useraccoun0_.BIRTH_DT as BIRTH_DT9_5_, useraccoun0_.DISABLED_IND as DISABLED_IND10_5_, useraccoun0_.DISABLED_DT as DISABLED_DT11_5_, useraccoun0_.DISABLED_REASON as DISABLED_REASON12_5_, useraccoun0_.email as email13_5_, useraccoun0_.FAILED_LOGIN_CNT as FAILED_LOGIN_CNT14_5_, useraccoun0_.FAILED_PASSWORD_RESET_DT as FAILED_PASSWORD_R15_5_, useraccoun0_.FIRST_NM as FIRST_NM16_5_, useraccoun0_.LAST_FAILED_LOGIN_DT as LAST_FAILED_LOGIN17_5_, useraccoun0_.LAST_LOGIN_DT as LAST_LOGIN_DT18_5_, useraccoun0_.LAST_NM as LAST_NM19_5_, useraccoun0_.LOCKED_IND as LOCKED_IND20_5_, useraccoun0_.LOCKED_CNT as LOCKED_CNT21_5_, useraccoun0_.LOCKED_DT as LOCKED_DT22_5_, useraccoun0_.USER_PASSWORD as USER_PASSWORD23_5_, useraccoun0_.PASSWORD_CHANGED_DT as PASSWORD_CHANGED_24_5_, useraccoun0_.PHONE_NBR as PHONE_NBR25_5_, useraccoun0_.REQUIRE_PASSWORD_RESET_IND as REQUIRE_PASSWORD_26_5_, useraccoun0_.SSN as SSN27_5_, useraccoun0_.USER_NM as USER_NM28_5_ from USER_ACCOUNT useraccoun0_ where substr(useraccoun0_.SSN, -4, 4)=? and last_nm=? and birth_dt=?

Using H2 Debug Console occurred exception

I have seted -DIGNITE_H2_DEBUG_CONSOLE in JVM parameters.
Then local H2 console started.
but exception occurred:
General error: "java.lang.UnsupportedOperationException"; SQL statement:
SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=? [50000-191] HY000/50000
org.h2.jdbc.JdbcSQLException: General error: "java.lang.UnsupportedOperationException"; SQL statement:
SELECT UPPER(VALUE) FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=? [50000-191]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:295)
at org.h2.command.Command.executeQuery(Command.java:213)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:110)
at org.h2.bnf.context.DbContents.readContents(DbContents.java:136)
...
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsupportedOperationException
at org.apache.ignite.internal.processors.query.h2.opt.GridH2Row.setKey(GridH2Row.java:101)
at org.h2.table.MetaTable.add(MetaTable.java:1982)
at org.h2.table.MetaTable.generateRows(MetaTable.java:940)
at org.h2.index.MetaIndex.find(MetaIndex.java:50)
at org.h2.index.BaseIndex.find(BaseIndex.java:132)
at org.h2.index.IndexCursor.find(IndexCursor.java:169)
at org.h2.table.TableFilter.next(TableFilter.java:460)
at org.h2.command.dml.Select.queryFlat(Select.java:541)
...
at org.h2.command.CommandContainer.query(CommandContainer.java:110)
at org.h2.command.Command.executeQuery(Command.java:201)
... 8 more
This is a known issue: https://issues.apache.org/jira/browse/IGNITE-3685
It is fixed in upcoming Apache Ignite 1.8.

org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception unexpected element (uri:"", local:"html")

The other I spent 3 hours trying to fix the following error and I couldn't find the answer here, so now that I've found the answer I've decided to share it with you.
I'm working with Java 6, Spring MVC, JAXB and while I was creating a new webservice, I got this error:
Caused by: org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"html"). Expected elements are <undisclosed>
at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:879)
at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:755)
at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:732)
... 29 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"html"). Expected elements are
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:556)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:199)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:194)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:71)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:962)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:399)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:380)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:101)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:195)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:120)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:103)
at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:751)
... 31 more
The error was i forgot to add #ResponseBody in the response type, in the signature of the method

Intermittent JDBC error two-task conversion routine

I am intermittently getting the following jdbc error with my oracle db (in remote linux machine)
java.sql.SQLException: ORA-03120: two-task conversion routine: integer overflow
The query that mostly breaks(not the only one!) looks like this, note that I am using Groovy Sql
String insertScript =
"""
INSERT INTO data_table (invoke_id , trans_type , trans_from ,
trans_to , serv_type ,msg_type , man_id , recip_id ,
trx_id , part_id , msg_orig_time , create_time ,
action_code , num_ranges , use_trx_id, due_date,owner,route,lsa,
cl_id,hl_id,requ_type,lnp_type,use_invoke_id)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
"""
def params = [invokeId,transType,transFrom,transTo,servType,msgType,man,recip,portId,owner,
now,now,"W",1,trxId,dueDate,owner," ", "LSA","CCH"," ","Basic","lspp",invokeId]
sql.execute insertScript, params
What I do not understand is why my queries work some time and not other times. Generally it will happen during the first run and only rarely appear in subsequent runs.
[UPDATE] I am getting this error sometimes on application startup also, when spring tries to load its context. I am using spring and dbcp for the connection pooling.
Caused by: org.apache.commons.dbcp.SQLNestedException: Error preloading the connection pool
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1238)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
... 46 more
Caused by: java.sql.SQLException: ORA-03120: two-task conversion routine: integer overflow
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:131)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:204)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:406)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:799)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:368)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1059)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1235)
... 49 more

Resources