SQL Server 2005 - Cannot rollback nested transaction - sql-server-2005

Sometimes I get the following from SQL Server 2005 when executing a stored procedure:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot roll back T1. No transaction or savepoint of that name was found.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyCallableStatement.executeUpdate(NewProxyCallableStatement.java:2160)
at com.sm.persistence.dao.TransactionRejectDAO.callSpMoveTransaction(TransactionRejectDAO.java:631)
... 6 more
Any ideas?
When the connection pooling mechanism attempts to close the prepared statement:
Nov 9, 2009 9:32:55 AM com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement close
WARNING: SQLServerPreparedStatementID:201 ( ConnectionID:139 TransactionID:0x1A00000039000000): Error (ignored) closing PreparedHandle:0
com.microsoft.sqlserver.jdbc.SQLServerException: The server failed to resume the transaction. Desc:390000001a.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$1PreparedHandleClose.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.closePreparedHandle(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.close(Unknown Source)
at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.synchronousDestroyStatement(GooGooStatementCache.java:413)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.closeAll(GooGooStatementCache.java:351)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeAllCachedStatements(NewPooledConnection.java:673)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:543)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Nov 9, 2009 9:32:55 AM com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement close
WARNING: SQLServerPreparedStatementID:186 ( ConnectionID:139 TransactionID:0x1A00000039000000): Error (ignored) closing PreparedHandle:0
The stored procedure contains a nested transaction T1 which I believe is unnecessary. Could that be the problem?
Thanks

The first error is due to the fact that you have a named nested transaction that you are trying to rollback to - naming a nested transaction (naming means typing something like "BEGIN TRANSACTION ", which in your case = T1) is allowed, but rolling back to a named nested transaction is not supported and results in an error.
See this topic for more information.

If you must rollback nested transaction, you can use SAVE Transaction.
see here

Related

"Incompatible data type in operation" Error when trying to format datetime

In ODI, I am fetching a field [datetime] from a table which is in MS SQL server.
The datetime from MS SQL is in this format: 2019-06-26 07:41:00.000.
I need to convert it to this format: 26-06-2019 10:41:00 i.e DD-MM-YYYY HH:MI:SS with hour incremented by 3, before writing it to a JSON file.
The corresponding field in JSON is VARCHAR(string).
But I am getting error: Caused By: java.sql.SQLSyntaxErrorException: incompatible data type in operation
I gave the following expressing in the ODI 12c mapping attribute expression editor:
TO_CHAR(TO_DATE(NVL(SUBSTR(L_MAILITM_EVENTS.EVENT_GMT_DT, 0, INSTR(L_MAILITM_EVENTS.EVENT_GMT_DT, '.')-1),
L_MAILITM_EVENTS.EVENT_GMT_DT ),'YYYY-MM-DD HH24:MI:SS')+ 3/24,
'DD-MM-YYYY HH24:MI:SS')
The entire error:
ODI-1228: Task Insert new lines-IKM XML Control Append- fails on the
target connection IPSEvents_Array_Json. Caused By:
java.sql.SQLSyntaxErrorException: incompatible data type in operation
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at
org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at
org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) at
org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source) at
com.sunopsis.jdbc.driver.xml.SnpsXmlStatementRedirector.execute(SnpsXmlStatementRedirector.java:77)
at
com.sunopsis.jdbc.driver.xml.SnpsXmlStatement.execute(SnpsXmlStatement.java:31)
at
oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:205)
at
oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:142)
at
oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:28)
at
oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:52)
at
oracle.odi.runtime.agent.execution.SessionTask.processTask(SessionTask.java:206)
at
oracle.odi.runtime.agent.execution.SessionTask.doExecuteTask(SessionTask.java:117)
at
oracle.odi.runtime.agent.execution.AbstractSessionTask.execute(AbstractSessionTask.java:886)
at
oracle.odi.runtime.agent.execution.SessionExecutor$SerialTrain.runTasks(SessionExecutor.java:2225)
at
oracle.odi.runtime.agent.execution.SessionExecutor.executeSession(SessionExecutor.java:610)
at
oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$1.doAction(TaskExecutorAgentRequestProcessor.java:718)
at
oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$1.doAction(TaskExecutorAgentRequestProcessor.java:611)
at
oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:203)
at
oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doProcessStartAgentTask(TaskExecutorAgentRequestProcessor.java:800)
at
oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$1400(StartSessRequestProcessor.java:74)
at
oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:702)
at
oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:180)
at
oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:108)
at java.lang.Thread.run(Thread.java:748) Caused by:
org.hsqldb.HsqlException: incompatible data type in operation at
org.hsqldb.error.Error.error(Unknown Source) at
org.hsqldb.error.Error.error(Unknown Source) at
org.hsqldb.FunctionSQL.resolveTypes(Unknown Source) at
org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionArithmetic.resolveTypes(Unknown Source) at
org.hsqldb.FunctionSQL.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionLogical.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionOp.resolveTypesForCaseWhen(Unknown Source) at
org.hsqldb.ExpressionOp.resolveTypes(Unknown Source) at
org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionArithmetic.resolveTypes(Unknown Source) at
org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at
org.hsqldb.QuerySpecification.resolveExpressionTypes(Unknown Source)
at org.hsqldb.QuerySpecification.resolveTypesPartOne(Unknown Source)
at org.hsqldb.RangeVariable.resolveRangeTable(Unknown Source) at
org.hsqldb.QuerySpecification.resolveRangeVariables(Unknown Source)
at org.hsqldb.QuerySpecification.resolveReferences(Unknown Source)
at org.hsqldb.QueryExpression.resolve(Unknown Source) at
org.hsqldb.ParserDML.compileInsertStatement(Unknown Source) at
org.hsqldb.ParserCommand.compilePart(Unknown Source) at
org.hsqldb.ParserCommand.compileStatements(Unknown Source) at
org.hsqldb.Session.executeDirectStatement(Unknown Source) at
org.hsqldb.Session.execute(Unknown Source) ... 22 more
Where am I going wrong?
As the target is a file, it is not an Oracle database doing the transformation but the internal HSQL database of ODI Studio or the ODI agent. The Oracle functions can not be used here but it can be replaced by HSQL functions. Here are the available functions : http://hsqldb.org/doc/guide/builtinfunctions-chapt.html.
Alternatively an expression could be added to the mapping right after the L_MAILITM_EVENTS datastore to do the transformation on the source database using MS SQL specific functions. This would change the SELECT statement executed on MS SQL to directly apply the functions. Make sure to change the execution location of the expression to the source.

Hsqldb not found sequence that I just created

I'm trying to put this simple code to work for create a sequence in a DDL SQL script:
CREATE SEQUENCE seq START WITH 1 INCREMENT BY 1;
INSERT INTO MyTable (id, perc, tablex_id, tabley_id) SELECT NEXT VALUE FOR seq, 0, t.id, cb.id FROM tablex t, tabley cb;
But I receive this error:
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: SEQ
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserDQL.readSequenceExpressionOrNull(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleValueExpressionPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesValueExpressionPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesFactor(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadAllTypesCommonValueExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadValueExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 31 more
Why Hqdlb can't found the sequence seq? I'm using Hsqldb 2.4.0.
You need to execute these SQL statements one by one.
When multiple SQL statements are submitted to the database as one statement, HSQLDB parses and compiles the complete text before executing the statements one by one. When the second statement is compiled, the first statement has not yet been executed and the sequence does not exist at this point.

"Unexpected Error occurred attempting to open an SQL connection." when opening InMemory DB using SQuirreL SQL Client 3.5.0

We have an event generation mechanism that generates & save the events in a flatfile (or say DB file to make it easy).
To view this event in DB we complete the run for generating the events & then we use "SQuirreL SQL Client 3.5.0".
When the size of this db file is small SQuirreL Client works fine. But when the size grows near to 20MB, it refuses to open the database & throws below exception -
Unexpected Error occurred attempting to open an SQL connection.
Below is the StackTrace for your reference:
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.sql.SQLException: Out of Memory
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:202)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: java.sql.SQLException: Out of Memory
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:171)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
... 5 more
Caused by: java.sql.SQLException: Out of Memory
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
... 7 more
Caused by: org.hsqldb.HsqlException: Out of Memory
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.persist.ScriptRunner.runScript(Unknown Source)
at org.hsqldb.persist.ScriptRunner.runScript(Unknown Source)
at org.hsqldb.persist.Log.processLog(Unknown Source)
at org.hsqldb.persist.Log.open(Unknown Source)
at org.hsqldb.persist.Logger.openPersistence(Unknown Source)
at org.hsqldb.Database.reopen(Unknown Source)
at org.hsqldb.Database.open(Unknown Source)
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
at org.hsqldb.DatabaseManager.newSession(Unknown Source)
... 12 more
Try increasing the memory allocated to SQuirreL. Open the script or batch file in a text editor and change the amount of memory allocated. Look for -Xmx256m and replace the 256 with a larger number.
On Windows the file is squirrel-sql.bat, on Linux it is squirrel-sql.sh

we are getting this error when we start our application + weblogic error

Caused by: java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver][SQLServer]INTEGER ?? ???????? ????????? ??? ?????????? ???????.
at weblogic.jdbc.sqlserverbase.dda4.b(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda4.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda3.b(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda3.a(Unknown Source)
at weblogic.jdbc.sqlserver.tds.ddr.v(Unknown Source)
at weblogic.jdbc.sqlserver.tds.ddr.a(Unknown Source)
at weblogic.jdbc.sqlserver.tds.ddq.a(Unknown Source)
at weblogic.jdbc.sqlserver.tds.ddr.a(Unknown Source)
at weblogic.jdbc.sqlserver.ddj.m(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddde.e(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddde.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb9.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddde.v(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddde.u(Unknown Source)
Can i Know what deos "weblogic.jdbc.sqlserver.xxx" error means ? and the caused by error, i have never seen INTEGER error.. any inputs would help.
Thanks,
Brij
As i see you use sql server as database.
Check if jdbc driver for MS sql server is in the classpath of the server.
Check how you defined your db datasoruce.

HSQLDB object name already exists

I'm trying to set up an HSQL database for testing, using version 2.2.9, Hibernate 3.6.9, and Spring 3.1.2. We had been using a local postgresql database but are making a switch for testing. I have 40-50 test classes with 200+ tests in total. Each test class works fine if run individually from eclipse. When I use Maven to compile and test everything I have test errors. At some point it seems to be trying to run my init.sql script again and create tables again. I'm getting this as my final cause:
Caused by: org.hsqldb.HsqlException: object name already exists: DUAL_ASSET_ASSETID_SEQ
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.SchemaObjectSet.checkAdd(Unknown Source)
at org.hsqldb.SchemaManager.checkSchemaObjectNotExists(Unknown Source)
at org.hsqldb.StatementSchema.setOrCheckObjectName(Unknown Source)
at org.hsqldb.StatementSchema.getResult(Unknown Source)
at org.hsqldb.StatementSchema.execute(Unknown Source)
at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source) ... 52 more
I tried using 'IF NOT EXISTS' when creating that table but when I go to create the sequence I'm getting the same error. So it's trying to do more than just that one table, and I can't use 'IF NOT EXISTS' on a CREATE SEQUENCE statement so I'm stuck there.
Is there any reason why my data seems to be loaded again? I'm also occasionally getting this error:
2012-10-16 10:55:48,489 [Thread-0] WARN
org.springframework.jdbc.datasource.embedded.HsqlEmbeddedDatabaseConfigurer:shutdown:46 - Could not shutdown embedded database java.sql.SQLException: Database lock acquisition failure: attempt to connect while db opening /closing
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at org.springframework.jdbc.datasource.SimpleDriverDataSource.getConnectionFromDriver(SimpleDriverDataSource.java:140)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
at org.springframework.jdbc.datasource.embedded.AbstractEmbeddedDatabaseConfigurer.shutdown(AbstractEmbeddedDatabaseConfigurer.java:40)
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.shutdownDatabase(EmbeddedDatabaseFactory.java:152)
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean.destroy(EmbeddedDatabaseFactoryBean.java:65)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:211)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1071)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1045)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:963) Caused by: org.hsqldb.HsqlException: Database lock acquisition failure: attempt to connect while db opening /closing at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
at org.hsqldb.DatabaseManager.newSession(Unknown Source) ... 16 more
The current version of HSQLDB allows CREATE SEQUENCE IF NOT EXISTS statements.
Alternatively for tests, you can simply drop the whole contents of the PUBLIC schema before creating any objects.
DROP SCHEMA PUBLIC CASCADE