I have a VDB containing a view with a UUID column with this definition
<vdb name="_GENERATED_users_info" version="6">
<import-vdb name="_INTERNAL_internal" version="1"/>
<model name="GEN_view" type="VIRTUAL">
<metadata type="DDL">
<![CDATA[ CREATE VIEW "_view_workflow_data" ("uuid" VARCHAR, "email" VARCHAR) OPTIONS (UPDATABLE 'true') AS SELECT "public"."security_users_info"."uuid" AS "uuid", "public"."security_users_info"."email" AS "email" FROM "public"."security_users_info" ]]></metadata>
</model>
</vdb>
Column security_users_info.uuid is of type UUID.
When I try to execute a query
SELECT "uuid", "email" FROM "_view_workflow_data" WHERE ("uuid" IN (?''718e52dd-058a-4306-9213-c999181163c7') AND 1 = 1)
I get an error org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = character varying. The error doesn't come from the query I sent but from a query generated by TEIID executed on the physical table
TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0."uuid" AS varchar), g_0."email" FROM "public"."security_users_info" AS g_0 WHERE g_0."uuid" = ?]
I tried to convert the column in the view definition to varchar like this CONVERT("public"."security_users_info"."uuid", VARCHAR) AS "uuid" but I get the same error.
The failing query works fine directly in postgresql as it implicitly converts the uuid text into a uuid type.
I'm aware of the section about UID types in http://teiid.github.io/teiid-documents/master/content/reference/as_jdbc-translators.html but as the implicit conversion seems to work when I execute the query directly in postgresql, I would expect that section not to apply in this situation.
I'm using TEIID 16 with postgresql 9.5 and postgres JDBC driver 42.2.
Am I doing something in a wrong way or is this not supposed to work?
Whole stacktrace:
ERROR# - org.jooq.exception.DataAccessException: SQL [select "uuid", "email" from "_view_workflow_data" where ("uuid" in (?) and 1 = 1)]; TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0."uuid" AS varchar), g_0."email" FROM "public"."security_users_info" AS g_0 WHERE g_0."uuid" = ?] (c.m.w.c.d.DataObjectVerticle#?)org.jooq.exception.DataAccessException: SQL [select "uuid", "email" from "_view_workflow_data" where ("uuid" in (?) and 1 = 1)]; TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0."uuid" AS varchar), g_0."email" FROM "public"."security_users_info" AS g_0 WHERE g_0."uuid" = ?]
at org.jooq_3.13.0-SNAPSHOT.DEFAULT.debug(Unknown Source)
at org.jooq.impl.Tools.translate(Tools.java:2717)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:382)
at com.mathesio.workflow.core.dataObject.DataObjectService.lambda$select$16(DataObjectService.java:365)
at com.mathesio.teiid.Connections.ConnectionManager.lambda$getConnectionJOOQ$0(ConnectionManager.java:187)
at org.jooq.impl.DefaultDSLContext$3.run(DefaultDSLContext.java:609)
at org.jooq.impl.DefaultDSLContext$3.run(DefaultDSLContext.java:606)
at org.jooq.impl.DefaultDSLContext.lambda$transactionResult0$0(DefaultDSLContext.java:537)
at org.jooq.impl.Tools$12$1.block(Tools.java:4847)
at java.base/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3128)
at org.jooq.impl.Tools$12.get(Tools.java:4844)
at org.jooq.impl.DefaultDSLContext.transactionResult0(DefaultDSLContext.java:589)
at org.jooq.impl.DefaultDSLContext.transactionResult(DefaultDSLContext.java:506)
at org.jooq.impl.DefaultDSLContext.transaction(DefaultDSLContext.java:606)
at com.mathesio.teiid.Connections.ConnectionManager.lambda$getConnectionJOOQ$1(ConnectionManager.java:186)
at com.mathesio.workflow.core.database.transaction.TransactionJPA.lambda$new$42(TransactionJPA.java:1813)
at com.mathesio.workflow.core.database.transaction.TransactionJPA.lambda$new$19(TransactionJPA.java:388)
at com.mathesio.workflow.core.database.transaction.TransactionJPA.runCore(TransactionJPA.java:993)
at com.mathesio.workflow.core.database.transaction.TransactionJPA.lambda$run$25(TransactionJPA.java:1306)
at com.mathesio.workflow.core.database.transaction.TransactionJPA$1.call(TransactionJPA.java:755)
at com.mathesio.workflow.core.database.transaction.TransactionJPA$1.call(TransactionJPA.java:738)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at com.mathesio.workflow.core.database.transaction.PriorityFuture.run(PriorityFuture.java:58)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.teiid.jdbc.TeiidSQLException: TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0."uuid" AS varchar), g_0."email" FROM "public"."security_users_info" AS g_0 WHERE g_0."uuid" = ?]
at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:131)
at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:67)
at org.teiid.jdbc.StatementImpl.postReceiveResults(StatementImpl.java:783)
at org.teiid.jdbc.StatementImpl.access$100(StatementImpl.java:62)
at org.teiid.jdbc.StatementImpl$2.onCompletion(StatementImpl.java:581)
at org.teiid.client.util.ResultsFuture.done(ResultsFuture.java:131)
at org.teiid.client.util.ResultsFuture.access$200(ResultsFuture.java:36)
at org.teiid.client.util.ResultsFuture$1.receiveResults(ResultsFuture.java:75)
at org.teiid.net.socket.SocketServerInstanceImpl.receivedMessage(SocketServerInstanceImpl.java:281)
at org.teiid.net.socket.SocketServerInstanceImpl.read(SocketServerInstanceImpl.java:333)
at org.teiid.net.socket.SocketServerInstanceImpl$RemoteInvocationHandler$1.get(SocketServerInstanceImpl.java:423)
at org.teiid.jdbc.StatementImpl.executeSql(StatementImpl.java:590)
at org.teiid.jdbc.PreparedStatementImpl.execute(PreparedStatementImpl.java:240)
at org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:209)
at org.jooq.impl.Tools.executeStatementAndGetFirstResultSet(Tools.java:3935)
at org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:294)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:368)
... 23 common frames omitted
Caused by: org.teiid.core.TeiidProcessingException: TEIID30504 Remote org.teiid.core.TeiidProcessingException: TEIID30504 _SOURCE_7772c4bdad42f2468b3ecdc71d89634bd9b80ff2ca87900862ab740105049694: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0."uuid" AS varchar), g_0."email" FROM "public"."security_users_info" AS g_0 WHERE g_0."uuid" = ?]
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.exceptionOccurred(DataTierTupleSource.java:397)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.nextTuple(DataTierTupleSource.java:157)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.relational.AccessNode.nextBatchDirect(AccessNode.java:401)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.relational.RelationalNode.nextBatch(RelationalNode.java:277)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.relational.RelationalPlan.nextBatch(RelationalPlan.java:139)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.QueryProcessor.nextBatchDirect(QueryProcessor.java:147)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.QueryProcessor.nextBatch(QueryProcessor.java:110)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.BatchCollector.collectTuples(BatchCollector.java:160)
at org.jboss.teiid#16.0.0//org.teiid.query.processor.BatchCollector.collectTuples(BatchCollector.java:142)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.RequestWorkItem.processMore(RequestWorkItem.java:491)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.RequestWorkItem.process(RequestWorkItem.java:361)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.AbstractWorkItem.run(AbstractWorkItem.java:43)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.RequestWorkItem.run(RequestWorkItem.java:284)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:283)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:124)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.ThreadReuseExecutor$2.run(ThreadReuseExecutor.java:212)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.teiid.translator.TranslatorException: 0 Remote org.teiid.translator.jdbc.JDBCExecutionException: 0 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: ['718e52dd-058a-4306-9213-c999181163c7'] SQL: SELECT cast(g_0."uuid" AS varchar), g_0."email" FROM "public"."security_users_info" AS g_0 WHERE g_0."uuid" = ?]
at org.jboss.teiid.translator.jdbc#16.0.0//org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:127)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:405)
at jdk.internal.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:228)
at org.jboss.teiid#16.0.0//com.sun.proxy.$Proxy45.execute(Unknown Source)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:302)
at org.jboss.teiid#16.0.0//org.teiid.dqp.internal.process.DataTierTupleSource.nextTuple(DataTierTupleSource.java:138)
... 17 common frames omitted
Caused by: java.sql.SQLException: Remote org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 109
at org.postgresql#42.2.2//org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
at org.postgresql#42.2.2//org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
at org.postgresql#42.2.2//org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
at org.postgresql#42.2.2//org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql#42.2.2//org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql#42.2.2//org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
at org.postgresql#42.2.2//org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118)
at org.jboss.ironjacamar.jdbcadapters#1.4.20.Final//org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
at org.jboss.teiid.translator.jdbc#16.0.0//org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:119)
... 25 common frames omitted
Related
Following is the script I wrote:
var df2 = spark.read.parquet("<file_path>")
df2.write.format("iceberg").save(<destination_path>)
When I ran the script I am getting the following error:
RuntimeException: Failed to get table info from metastore gs://dremio-qa/flatten.listofstructwithnulls30_iceberg
Caused by: MetaException: Exception thrown when executing query : SELECT DISTINCT 'org.apache.hadoop.hive.metastore.model.MTable' AS NUCLEUS_TYPE,A0.CREATE_TIME,A0.LAST_ACCESS_TIME,A0.OWNER,A0.RETENTION,A0.IS_REWRITE_ENABLED,A0.TBL_NAME,A0.TBL_TYPE,A0.TBL_ID FROM TBLS A0 LEFT OUTER JOIN DBS B0 ON A0.DB_ID = B0.DB_ID WHERE A0.TBL_NAME = ? AND B0.`NAME` = ?
Caused by: JDOException: Exception thrown when executing query : SELECT DISTINCT 'org.apache.hadoop.hive.metastore.model.MTable' AS NUCLEUS_TYPE,A0.CREATE_TIME,A0.LAST_ACCESS_TIME,A0.OWNER,A0.RETENTION,A0.IS_REWRITE_ENABLED,A0.TBL_NAME,A0.TBL_TYPE,A0.TBL_ID FROM TBLS A0 LEFT OUTER JOIN DBS B0 ON A0.DB_ID = B0.DB_ID WHERE A0.TBL_NAME = ? AND B0.`NAME` = ?
Caused by: SQLSyntaxErrorException: (conn=65340) Unknown column 'A0.IS_REWRITE_ENABLED' in 'field list'
Caused by: MariaDbSqlException: Unknown column 'A0.IS_REWRITE_ENABLED' in 'field list'
Caused by: SQLException: Unknown column 'A0.IS_REWRITE_ENABLED' in 'field list'
data.write
.format("iceberg")
.mode("append")
.save("db.table")
You should user db.table insteand of '<destination_path>'
I am using Quill with Doobie and PostgreSQL (org.tpolecat.doobie-quill artifact with version 0.13.1).
This code
case class SomeRecord(id: Int, order: Int, name: String)
val record = SomeRecord(0, 0, "test")
run(
quote(
querySchema[SomeRecord]("some_table")
).insert(lift(record))
)
Will end up in error message in runtime:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "order"
Position: 46
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:130)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at doobie.free.KleisliInterpreter$PreparedStatementInterpreter.$anonfun$executeUpdate$5(kleisliinterpreter.scala:955)
at doobie.free.KleisliInterpreter$PreparedStatementInterpreter.$anonfun$executeUpdate$5$adapted(kleisliinterpreter.scala:955)
at doobie.free.KleisliInterpreter.$anonfun$primitive$2(kleisliinterpreter.scala:109)
It seems that Quill does not escape keyword-like column names, so "order" (and other keywords) columns in it's query will always fail. See Escaping keyword-like column names in Postgres . The workaround is to rename the column in table (and corresponding case classes).
I'd like to know if i need to return value after first INSERT then pass it to next INSERT or i can just use this kind of code
<insert id="CreateUser" parameterType="com.portale.model.UserObject">
INSERT INTO users(user_org, user_login, user_pass, locked)
VALUES (#{organization},#{username},#{password},#{locked})
INSERT INTO users_details(details_id, nome, cognome)
VALUES ((SELECT users.user_id FROM users WHERE user_login = #{username}),#{nome},#{cognome})
</insert>
This code give me an error
### Error updating database. Cause: org.postgresql.util.PSQLException: ОШИБКА: ошибка синтаксиса (примерное положение: "INSERT") Позиция: 87
### The error may exist in file [D:\Users\Eclipse and VM\Tomcat\apache-tomcat- 8.5.53\wtpwebapps\com.portale\WEB-INF\classes\com\portale\mapper\UserMapper.xml]
### The error may involve com.portale.mapper.UserMapper.CreateUser-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO users(user_org, user_login, user_pass, locked) VALUES (?,?,?,?) INSERT INTO users_details(details_id, nome, cognome) VALUES ((SELECT users.user_id FROM users WHERE user_login = ?),?,?)
### Cause: org.postgresql.util.PSQLException: ОШИБКА: ошибка синтаксиса (примерное положение: "INSERT") Позиция: 87;
bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ОШИБКА: ошибка синтаксиса (примерное положение: "INSERT") Позиция: 87!!!! Exception cause!!!! org.postgresql.util.PSQLException: ОШИБКА: ошибка синтаксиса (примерное положение: "INSERT") Позиция: 87
But all parameters are passed in the code.
Can i use (SELECT...) with (INSERT) in MyBatis ? Is this an wrong way to do it or a issue by passing parameters?
The issue was a simple ";" missing.
After first query (INSERT) of course sql need to know that the next INSERT is a new query so after writing the first one you need to put an ";"
<insert id="CreateUser" parameterType="com.portale.model.UserObject">
INSERT INTO users(user_org, user_login, user_pass, locked)
VALUES (#{organization},#{username},#{password},#{locked});
INSERT INTO users_details(details_id, nome, cognome)
VALUES ((SELECT users.user_id FROM users WHERE user_login = #{username}),#{nome},#{cognome})
</insert>
I'm writing some SQL for a report (this is my first time actually writing SQL so don't slam my syntax too much, lol) and the subquery seems to be failing. I'm not sure why because the report compiles just fine and I can get it into Jaspersoft Studio before it errors out when trying to preview it. Am I even doing the subquery correctly?
Thanks in advance.
SELECT
PERSON.LAST_NAME,
ACCOUNT.ACCOUNT_NUMBER,
SHARE_ESCROW.ID,
LOAN.PAYMENT_DUE_DATE,
LN_IMPOUND_ANALYSIS.CUSHION_AMOUNT,
LN_IMPOUND_ANALYSIS.NEXT_P_AND_I_AMOUNT,
LOAN.IMPOUND_AMOUNT,
LN_IMPOUND_ANALYSIS.NEXT_IMPOUND_AMOUNT,
SHARE_ESCROW.BALANCE,
SHARE_ESCROW.DESCRIPTION,
SHARE_ESCROW.CLOSE_DATE,
i.LTV,
CASE LOAN.PAYMENT_METHOD
WHEN 'T' THEN 'Automated Transfer'
WHEN 'A' THEN 'ACH'
WHEN 'C' THEN 'Cash'
END AS PAYMENT_METHOD
FROM
CORE.ACCOUNT AS ACCOUNT INNER JOIN CORE.LOAN AS LOAN ON ACCOUNT.SERIAL = LOAN.PARENT_SERIAL INNER JOIN
CORE.LN_IMPOUND_ANALYSIS AS LN_IMPOUND_ANALYSIS ON LOAN.SERIAL = LN_IMPOUND_ANALYSIS.PARENT_SERIAL INNER JOIN
CORE.SHARE AS SHARE_ESCROW ON ACCOUNT.SERIAL = SHARE_ESCROW.PARENT_SERIAL INNER JOIN
CORE.PERSON AS PERSON ON PERSON.SERIAL = ACCOUNT.PRIMARY_PERSON_SERIAL,
(SELECT
CASE COLLATERAL.AMOUNT
WHEN 0 THEN 0
WHEN NULL THEN 0
ELSE LOAN.BALANCE / COLLATERAL.AMOUNT
END AS LTV
FROM
CORE.COLLATERAL AS COLLATERAL INNER JOIN LOAN ON LOAN.SERIAL = COLLATERAL.PARENT_SERIAL
) i
WHERE
SHARE_ESCROW.DESCRIPTION = 'Escrow Share' AND
SHARE_ESCROW.CLOSE_DATE IS NULL AND
i.LTV != 0
Edit:
Here's the error:
net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error executing SQL statement for : Escrow32Analysis324532WIP_TableDataset_1579697577915_289752
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:466)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:441)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:333)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error executing SQL statement for : Escrow32Analysis324532WIP_TableDataset_1579697577915_289752
at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:809)
at net.sf.jasperreports.components.table.fill.FillTableSubreport.prepareSubreport(FillTableSubreport.java:156)
at net.sf.jasperreports.components.table.fill.FillTable.prepare(FillTable.java:400)
at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:151)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:332)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummaryNoLastFooterSamePage(JRVerticalFiller.java:1102)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillSummary(JRVerticalFiller.java:1065)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:329)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:159)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:963)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.JRException: Error executing SQL statement for : Escrow32Analysis324532WIP_TableDataset_1579697577915_289752
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:240)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1114)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:691)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1314)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:931)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:873)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:665)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:203)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
... 1 more
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=CMURPHY.LOAN, DRIVER=4.13.127
at com.ibm.db2.jcc.am.id.a(id.java:677)
at com.ibm.db2.jcc.am.id.a(id.java:60)
at com.ibm.db2.jcc.am.id.a(id.java:127)
at com.ibm.db2.jcc.am.no.c(no.java:2653)
at com.ibm.db2.jcc.am.no.d(no.java:2641)
at com.ibm.db2.jcc.am.no.a(no.java:2090)
at com.ibm.db2.jcc.am.oo.a(oo.java:7671)
at com.ibm.db2.jcc.t4.cb.h(cb.java:141)
at com.ibm.db2.jcc.t4.cb.b(cb.java:41)
at com.ibm.db2.jcc.t4.q.a(q.java:32)
at com.ibm.db2.jcc.t4.sb.i(sb.java:135)
at com.ibm.db2.jcc.am.no.ib(no.java:2059)
at com.ibm.db2.jcc.am.oo.sc(oo.java:3559)
at com.ibm.db2.jcc.am.oo.b(oo.java:4348)
at com.ibm.db2.jcc.am.oo.fc(oo.java:743)
at com.ibm.db2.jcc.am.oo.executeQuery(oo.java:713)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:233)
... 11 more
The message you see in the log:
DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=CMURPHY.LOAN
means that the object (in your case a table) LOAN in the schema CMURPHY cannot be found (SQLCODE -204). As others have mentioned in comments, the only table reference in your query that is missing the explicit schema is this:
FROM
CORE.COLLATERAL AS COLLATERAL INNER JOIN LOAN ON LOAN.SERIAL ...
---------------------------------------------^^^^
so the database server by default looks for that table in the default schema, the one matching your user ID (CMURPHY). Apparently it's not there.
Add the explicit schema name to the table reference:
FROM
CORE.COLLATERAL AS COLLATERAL INNER JOIN CORE.LOAN AS LOAN ON LOAN.SERIAL ...
I want to let the persistence provider (EclipseLink 2.5.0) automatically create the tables in the, already existing, database by using the persistence unit property "javax.persistence.schema-generation.create-script-source" and a valid SQL-DDL-script.
persistence.xml:
<property name="javax.persistence.schema-generation.create-script-source" value="data/ddl.sql"/>
ddl.sql:
USE myDatabase;
CREATE TABLE MyTable (
id INTEGER NOT NULL AUTO_INCREMENT,
myColumn VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE = utf8_bin;
But I got the following error:
[EL Warning]: 2014-02-12 13:31:44.778--ServerSession(768298666)--Thread(Thread[main,5,main])--Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Error Code: 1064
Call: CREATE TABLE MyTable (
Query: DataModifyQuery(sql="CREATE TABLE MyTable (")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:895)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:957)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:630)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1995)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:271)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:251)
at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:85)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3207)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1797)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1779)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1730)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeNonSelectingCall(AbstractSession.java:1499)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeNonSelectingSQL(AbstractSession.java:1517)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeSourceScriptToDatabase(EntityManagerSetupImpl.java:4065)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:3910)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.writeDDL(EntityManagerSetupImpl.java:3783)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:724)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:140)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at nl.tent.competent.data.access.Main.main(Main.java:22)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:885)
... 29 more
It seems that the carriage return line feed (newline) is the problem. And if I change the SQL-DDL-script, so that one SQL-statement only takes one line, everything is working fine.
adjusted ddl.sql:
USE myDatabase;
CREATE TABLE MyTable (id INTEGER NOT NULL AUTO_INCREMENT, myColumn VARCHAR(255) NOT NULL, PRIMARY KEY (id) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 DEFAULT COLLATE = utf8_bin;
But I don't want to reformat my SQL-DDL-script for readability. Please help!
If someone still faces this problem, it can be solved by adding following parameter (found here):
<property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />