Abandoned H2 connection involving linked table - database-connection

I'm having trouble with an application using H2, seemingly due to database connections being left open. I'm trying to understand if it's H2 leaking the connection or me (I'm aware that it's more likely to be me).
The application has Component1, which creates an in-memory H2 database and starts a TCP server. The H2 database contains a few linked tables which connect to a separate Oracle database using its JNDI identifier. Component2 connects to this database using JDBC with URL jdbc:h2:tcp://127.0.1.1:5521/mem:db1;.
In the exception below I've highlighted where I'm getting confused. The trace seems to say that a query was issued by a TCP client (Component2) that required a query of a linked table, and that the query on the linked table is what left the connection open. I do not control how H2 connects to the linked table via JNDI, so I'm inclined to think this is not my fault. I've included a linked table definition below the exception to show how they are created.
Can someone please help me understand who - between me and H2 - is responsible for this abandoned connection, and why?
Exception
org.apache.tomcat.dbcp.dbcp.AbandonedTrace$AbandonedObjectException: DBCP object created 2019-12-10 05:46:16 by the following code was never closed:
at org.apache.tomcat.dbcp.dbcp.AbandonedTrace.setStackTrace(AbandonedTrace.java:139)
at org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:81)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:311)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:274)
at org.h2.table.TableLinkConnection.open(TableLinkConnection.java:89)
at org.h2.table.TableLinkConnection.open(TableLinkConnection.java:76)
at org.h2.engine.Database.getLinkConnection(Database.java:2708)
--> at org.h2.table.TableLink.connect(TableLink.java:96)
at org.h2.table.TableLink.execute(TableLink.java:535)
at org.h2.index.LinkedIndex.find(LinkedIndex.java:129)
at org.h2.index.BaseIndex.find(BaseIndex.java:132)
at org.h2.index.IndexCursor.find(IndexCursor.java:163)
at org.h2.table.TableFilter.next(TableFilter.java:475)
at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1882)
at org.h2.result.LazyResult.hasNext(LazyResult.java:101)
at org.h2.result.LazyResult.next(LazyResult.java:60)
at org.h2.command.dml.Select.queryFlat(Select.java:742)
at org.h2.command.dml.Select.queryWithoutCache(Select.java:884)
at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:151)
at org.h2.command.dml.Query.query(Query.java:435)
at org.h2.command.dml.Query.query(Query.java:397)
at org.h2.command.CommandContainer.query(CommandContainer.java:145)
at org.h2.command.Command.executeQuery(Command.java:202)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:335)
--> at org.h2.server.TcpServerThread.run(TcpServerThread.java:175)
at java.lang.Thread.run(Thread.java:745)
Linked Table
CREATE LINKED TABLE ora_table (
'javax.naming.InitialContext',
'java:comp/env/jdbc/oradb',
NULL,
NULL,
'(
SELECT field
FROM table
)'
)

Related

Java Web with Weblogic, DB Informix stored procedure data — impossible problem

I have Java Web on Weblogic; database is Informix.
The process is as follows:
User query data.
Create serial(only).
Using stored procedure with serial.
SP content like:
insert reporttable
select data from table1
insert reporttable
select data from table2
if(reporttable.count==0)
insert reporttable select 'NO DATA'
Query reporttable with serial.
Show on Web.
Important problem:
table1 has data count 10(data1,data2.......data10)
reporttable result data count 3(data1, data2, NO DATA) impossible
Important!!! The implementation does not process any exceptions.
When the problem occurs, any query on the data shows the same problem.
But when I restart Weblogic (using the same parameters), the query has no problem.
I have no idea to solve the problem; can you help?
I find the error reason.
Test : rename table name
sp use table1、table2、table3
unknown reason maybe abnormal connection
java.sql.SQLSyntaxErrorException: [FMWGEN][Informix JDBC Driver][Informix]The
specified table (table1) is not in the database.
Error message only trigger on first
Execute sp again,no error, and executeing neglect table1
weblogic restart jndi connection
Execute sp result normal

Can't connect to CFS node

I removed (or decommisioned, can't remember) a DSE analytics node (with IP 10.14.5.50) a couple of months ago. When I now try to execute a dse shark (CREATE TABLE ccc AS SELECT ...) query I now receiving:
15/01/22 13:23:17 ERROR parse.SharkSemanticAnalyzer: org.apache.hadoop.hive.ql.parse.SemanticException: 0:0 Error creating temporary folder on: cfs://10.14.5.50/user/hive/warehouse/mykeyspace.db. Error encountered near token 'TOK_TMP_FILE'
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1256)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1053)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:8342)
at shark.parse.SharkSemanticAnalyzer.analyzeInternal(SharkSemanticAnalyzer.scala:105)
at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:284)
at shark.SharkDriver.compile(SharkDriver.scala:215)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:342)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:977)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:888)
at shark.SharkCliDriver.processCmd(SharkCliDriver.scala:347)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413)
at shark.SharkCliDriver$.main(SharkCliDriver.scala:240)
at shark.SharkCliDriver.main(SharkCliDriver.scala)
Caused by: java.lang.RuntimeException: java.io.IOException: Error connecting to node 10.14.5.50:9160 with strategy STICKY.
at org.apache.hadoop.hive.ql.Context.getScratchDir(Context.java:216)
at org.apache.hadoop.hive.ql.Context.getExternalScratchDir(Context.java:270)
at org.apache.hadoop.hive.ql.Context.getExternalTmpFileURI(Context.java:363)
at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1253)
... 12 more
I guess the above error is due to my keyspace referring to the old node:
shark> DESCRIBE DATABASE mykeyspace;
OK
mykeyspace cfs://10.14.5.50/user/hive/warehouse/mykeyspace.db
Time taken: 0.997 seconds
Is there any way for me to fix this incorrect database path?
Tried (but failed) workaround to recreate the database: In cqlsh I created a keyspace thekeyspace and added a table thetable. I the opened up dse hive (and noticed that DESCRIBE DATABASE thekeyspace is giving me a correct cfs path). However, I am unable to drop the the database using DROP DATABASE thekeyspace.
Additional information:
I have no external tables in my keyspace.
Making the SELECT against the tables works.
Setting -hiveconf cassandra.host=WORKING_NODE_IP does not help.
The following commands return proper IP:s (ie. not X.X.X.50):
dsetool listjt
dsetool jobtracker
dsetool sparkmaster
I am getting the same error when I execute the query using dse hive.
No Shark variable is referring to X.X.X.50 when I execute set; in its REPL.
I am running DSE 4.5.
Stumbled across this page that says you need to TRUNCATE "HiveMetaStore"."MetaStore" (in cqlsh) after removing Hive nodes. That did the trick.

Orchard CMS installing error?

I tried to install orchard CMS the from source code. I opened it in VS 2012, and I m using Sql Server 2012.
I am geting the following error.
error text:
Setup failed: could not execute query
[ select rolerecord0_.Id as Id13_, rolerecord0_.Name as Name13_ from Test_Orchard_Roles_RoleRecord rolerecord0_ where rolerecord0_.Name=#p0 ]
Name:p1 - Value:Anonymous
[SQL: select rolerecord0_.Id as Id13_, rolerecord0_.Name as Name13_ from Test_Orchard_Roles_RoleRecord rolerecord0_ where rolerecord0_.Name=#p0]
I cant find any solution for this error. Where did I go wrong? How can I fix this error? When I choose built-in storage, it runs. Also, are there any disadvantages if I use the built-in one?
UPDATE (new error message)
Setup failed: could not execute query [ SELECT TOP (#p0) this_.Id as
Id17_2_, this_.Number as Number17_2_, this_.Published as
Published17_2_, this_.Latest as Latest17_2_, this_.Data as Data17_2_,
this_.ContentItemRecord_id as ContentI6_17_2_, contentite1_.Id as
Id16_0_, contentite1_.Data as Data16_0_, contentite1_.ContentType_id
as ContentT3_16_0_, contenttyp4_.Id as Id18_1_, contenttyp4_.Name as
Name18_1_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner
join Orchard_Framework_ContentItemRecord contentite1_ on
this_.ContentItemRecord_id=contentite1_.Id left outer join
Orchard_Framework_ContentTypeRecord contenttyp4_ on
contentite1_.ContentType_id=contenttyp4_.Id WHERE contentite1_.Id =
#p1 and this_.Published = #p2 ] Name:cp0 - Value:2 Name:cp1 -
Value:True [SQL: SELECT TOP (#p0) this_.Id as Id17_2_, this_.Number
as Number17_2_, this_.Published as Published17_2_, this_.Latest as
Latest17_2_, this_.Data as Data17_2_, this_.ContentItemRecord_id as
ContentI6_17_2_, contentite1_.Id as Id16_0_, contentite1_.Data as
Data16_0_, contentite1_.ContentType_id as ContentT3_16_0_,
contenttyp4_.Id as Id18_1_, contenttyp4_.Name as Name18_1_ FROM
Orchard_Framework_ContentItemVersionRecord this_ inner join
Orchard_Framework_ContentItemRecord contentite1_ on
this_.ContentItemRecord_id=contentite1_.Id left outer join
Orchard_Framework_ContentTypeRecord contenttyp4_ on
contentite1_.ContentType_id=contenttyp4_.Id WHERE contentite1_.Id =
#p1 and this_.Published = #p2]
Before creating SQL Server database, set collocation as Latin1_General_100_CI_AS
Do this, right click to Database note on SQL Server management Tool and click to New Database. When you see the New Database window, type the database name and click to Option tab left hand side on New Database windows.
You will see Collocation combobox top of the New Database window. Change default to Latin1_General_100_CI_AS. And then run Orchard setup again.
Set up a new application pool in your IIS manager and have it run as an account with permissions to query your sql server. Then assign your orchard website to use that application pool. Here is a screen shot of where to set the identity of the application pool, click the "Advanced Settings" link to get to this menu:
In the "Process Model" section - set the Identity to an account with SQL server permissions. Set "Load User Profile" = 'false'. This will prevent the pool from trying to retrieve the user profile when running the orchard website.
I find that usually when I get that error message, it's because the query being executed has a syntax error, or table/column names don't match. If you can halt execution where the exception is thrown, you can check the InnerException to see if that provides more info. If not, just copy the SQL from the message, fill in the parameters #p0, #p1, #p2 with values, and try to run it in whatever tool you use to manually query your database. It will often give you a more helpful error message.

Save and Load UTF-8 From Oracle 10g with iBatis

I'm making a web app that needs to load and save UTF-8 (Korean, specifically) characters from a DB. I've been given an account on the Oracle 10g server, but it saves VARCHAR2 type columns as ASCII7, with each UTF-8 character taking 2 VARCHAR2 slots.
I assumed that since iBatis is writing in the same way that it is reading, if I treat everything from input to output as UTF-8 I will have no problems, but any Korean characters I input come out garbled.
Is there a way to do this properly without messing up the (someone else's) DB?
Further information:
I've previously been able to load Korean strings using:
ResultSet rs = ps.executeQuery();
String koreanString = new String(rs.getBytes("colname"), "euc-kr");
And write Korean strings to db using:
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, new String(koreanString.getBytes("euc-kr"), "ISO-8859-1"));
Attempts to change the JDBC connection url result in this message:
Description
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
[ip]:myTablespace?useUnicode=true&characterEncoding=UTF-8
error dump
javax.servlet.ServletException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
[ip]:myTablespace?useUnicode=true&characterEncoding=UTF-8
at jeus.servlet.jsp2.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:859)
at jeus.servlet.jsp2.runtime.PageContextImpl.handlePageException(PageContextImpl.java:789)
at jeus_jspwork._jsp._500_managerAdmin_5fjsp._jspService(_500_managerAdmin_5fjsp.java:452)
at jeus.servlet.jsp2.runtime.HttpJspBase.service(HttpJspBase.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at jeus.servlet.jsp.JspServletWrapper.executeServlet(JspServletWrapper.java:147)
at jeus.servlet.servlets.JspServlet.execute(JspServlet.java:365)
at jeus.servlet.engine.HttpRequestProcessor.run(HttpRequestProcessor.java:284)
root cause
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
[ip]:myTablespace?useUnicode=true&characterEncoding=UTF-8
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.ibatis.common.jdbc.SimpleDataSource.popConnection(SimpleDataSource.java:580)
at com.ibatis.common.jdbc.SimpleDataSource.getConnection(SimpleDataSource.java:222)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.init(JdbcTransaction.java:48)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:89)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:120)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:82)
at [].admRole.getCount(admRole.java:44)
at jeus_jspwork._jsp._500_managerAdmin_5fjsp._jspService(_500_managerAdmin_5fjsp.java:145)
at jeus.servlet.jsp2.runtime.HttpJspBase.service(HttpJspBase.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at jeus.servlet.jsp.JspServletWrapper.executeServlet(JspServletWrapper.java:147)
at jeus.servlet.servlets.JspServlet.execute(JspServlet.java:365)
at jeus.servlet.engine.HttpRequestProcessor.run(HttpRequestProcessor.java:284)
As I stated in the question, strings are stored and retrieved correctly if they are re-encoded as EUC-KR before being turned into ISO-8859-1 (to save, or vice versa to retrieve).
I modified the two following classes:
com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap
com.ibatis.sqlmap.engine.mapping.result.ResultMap
In both cases, I took the Object[] array (parameters and columnValues), casted to String, and applied the encoding transformations.
I am not using oracle for quite a while, but I have some confidence that this is reason of your "listener does not currently know of SID given" error: Can I force JDBC Driver use UTF-8 Charset to encode?
I am a Chinese developer so the character encoding problem is pretty much the same(we are mostly using GBK character set here). As far as I can remember, "but it saves VARCHAR2 type columns as ASCII7" means that your oracle instance is a non-unicode installation?
The force use of string.getBytes(charset) above JDBC layer is really really bad in terms of maintenance and data interpretability(the string data is displayed as a mess to DBA; DBA can not use SQL to perform any string comparison on this column, etc). So my advice is try to contact your DBA and get the database working with unicode first, since Oracle is very capable of handling unicode data.

Multiple-step OLE DB operation generated errors [duplicate]

Dim NorthWindOledbConnection As String = "Provider=SQLOLEDB;DataSOurce=SARAN-PC\SQLEXPRESS;Integrated Security=ssp1;InitialCatalog=Sara"
Dim rs As New ADODB.Recordset()
rs.Open("select * from SecUserPassword", NorthWindOledbConnection, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic)
i tried to run this above code in visual studio 2008 - it shows the following error:
"Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done"
Firstly, don't use ADO in VB.NET. Use ADO.NET.
Other than that, create a proper Connection object instead of passing around a string.
And fix your connection string. It's SSPI, not SSP1. And it's Data Source, not DataSOurce. And it's Initial Catalog, not InitialCatalog.
You are using a very very very old way to access a Database that has been used with Visual Basic 6 and older.
Check to use ADO.NET instead of old ADO. For example you can use this code that is "similar" to the code you are using (but is not the best way to access the data on VS2008)
OleDbConnection con= New OleDbConnection( **Your Connection String** )
con.Open()
Dim command As OleDbCommand = New OleDbCommand("select * from SecUserPassword", con)
sqlCommand .CommandType = CommandType.Text
Dim reader As OleDbDataReader = TheCommand.ExecuteReader()
While reader.Read()
System.Console.Write(reader(** Your Table Field Name** ).ToString())
End While
con.Close()
To view how to create a correct connection String see the site http://www.connectionstrings.com/
If you want to access to an SQL Server database also you can use the SQLClient namespace instead the OleDb. For example System.Data.SqlClient.SqlConnection instead the OleDbConnection to provide better performance for SQL Server
The link below is an article that gives a great breakdown of the 6 scenarios this error message can occur:
Scenario 1 - Error occurs when trying to insert data into a database
Scenario 2 - Error occurs when trying to open an ADO connection
Scenario 3 - Error occurs inserting data into Access, where a fieldname has a space
Scenario 4 - Error occurs inserting data into Access, when using adLockBatchOptimistic
Scenario 5 - Error occurs inserting data into Access, when using Jet.OLEDB.3.51 or ODBC driver (not Jet.OLEDB.4.0)
Scenario 6 - Error occurs when using a Command object and Parameters
http://www.adopenstatic.com/faq/80040e21.asp
Hope it may help others that may be facing the same issue.

Resources