I develop am webservice based on apache tomcat 6.0.26, apache cxf 2.2.7, spring 3.0, hibernate 3.3 and sybase sqlanywhere 11. im using the latest JDBC Driver from SYBASE jconn.jar Version 6.
The persistence layer is based on spring + hibernate dao, the connection is configured via a JNDI datasoure (META-INF directory).
It seems that, during longer times of inactivity, the connection from the webservice to the database is closed.
Exception: java.sql.SQLException: JZ0C0: Connection is already closed.
By default, SQL Anywhere will close an inactive connection after four hours. To change this, you can specify IdleTimeout=x (or Idle=x) in your connection string, where x is the number of minutes after which the connection will be closed (0=never). Alternatively, you can reset the default on the server using the -ti x switch - again, x is in minutes.
Related
I'm using Powershell v2.0, question is in the title. I'm having to use the old school ADOB.Connection (not the OLEDB provider) to open a Jet DB file (.mdb). The reason is simple, the ADODB.Connection exposes properties I need access to that the OLEDB provider doesn't.
I'm opening the DB via ADOB.Connection to query for some information, and then I'm trying to compact the DB using JRO.JetEngine. The issue is that I keep getting an error about the Jet DB being locked.
I'm explicitly calling Close on it, and setting the variable to $null, and still experiencing that issue. My best guess is that ADODB.Connection is using connection pooling, and so is not releasing the resources the way it should be.
According to http://support.microsoft.com/kb/191572, the call to close() should be enough, but it doesn't seem to be working.
Is there a way for me to explicitly specify no connection pooling when creating ADODB.Connection objects?
In the link you provided, it is said that calling to close returns the connection to the pool:
2.What statement returns the connection to the pool?
2.Conn.Close
You might need to destroy/dispose the ADODB.Connection object, so that it is removed from the pool, or, if you are using OLE DB as the provider, configure the OLEDB Services, as explained here:
Enabling OLE DB Resource.
Pooling Resource pooling can be enabled in
several ways:
For an ADO-based consumer, by keeping one open instance of a
Connection object for each unique user and using the OLEDB_SERVICES
connection string attribute to enable or disable pooling. By default,
ADO attempts to use pooling, but if you do not keep at least one
instance of a Connection object open for each user, there will not be
a persistent pool available to your application. (However, Microsoft
Transaction Server keeps pools persistent as long as the connections
in them have not been released and have not eventually timed out.)
I have fair amount of knowledge of Grails but I cannot find a way how to read data from a table from sql developers using Grails. How can I do this?
By default when you use run-app, the database is in-memory (the url is something like "jdbc:h2:mem:devDb"), so there's no way to connect to it from outside the JVM. If you change it to a "real" database you can connect to it from both Grails and another client.
To do this with H2, one option is to start a standalone server. This requires that you find the H2 jar - it will be under $HOME/.m2/repository or $HOME/.grails/ivy-cache. For example on my machine the command to start on port 9092 (the default) is
java -cp /home/burt/.m2/repository/com/h2database/h2/1.3.170/h2-1.3.170.jar org.h2.tools.Server -tcp -tcpPort 9092
Then change the url in grails-app/conf/DataSource to
url = 'jdbc:h2:tcp://localhost:9092/dbname'
where "dbname" is arbitrary - H2 supports creating multiple databases per server. You can then start Grails and it will connect to that server, and you can connect from another client too.
A simpler way to do this is to use H2's auto-server mode, e.g. with this url
url = 'jdbc:h2:./dbname;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9092'
it will start up an in-memory database but with a TCP socket on port 9092 that you can connect to externally. This avoids having to find the jar and explicitly start the database server.
See http://h2database.com/html/main.html for more configuration information.
You can also use a different server, e.g. a MySQL/PostgreSQL/Oracle/etc server.
But having said all this, there is a convenient database client already running that you can access. When you start Grails with run-app you can connect to http://localhost:8080/appname/dbconsole in a web browser and access your table information, do SQL queries, etc. This is an H2 feature, but it works with whatever database you use since it works with JDBC, so you can use it with MySQL or whatever. See http://grails.org/doc/latest/guide/conf.html#databaseConsole for more information on this.
Here is my situation. I have an application (Mirth Connect) running on the same server as SQL Anywhere 11. There is also another server on the same network running SQL Anywhere 11. I need to connect to both of them. They are both using the same SQL Anywhere "Server Name".
I need to use a JDBC connection to connect to either of them at any given moment. I can connect to the local instance just fine.
I tried to set up an ODBC connection to the remote server. When I test the connection it says it is all good. Then when I try to run a query I notice I am connected to the local server. It must be because both SQL Anywhere servers are using the same "Server Name".
How do I force the ODBC connection to connect to the Remote server?
Thank you!
You need to specify the IP address (and port, if not using the default) in the connection string. Your connection string must contain the LINKS parameter, with (at least) the following options:
LINKS=tcpip(HOST=<remote IP address>;PORT=<remote port>;DoBroadcast=None)
If the remote server is using the default port number, 2638, you don't need to specify the port number in the connection string. DoBroadcast=None tells the client library that it should make a direct connection to that host. The default (for version 11 and older) is to broadcast on the network looking for that server name, and whichever server responds first wins. Since there is a server on the local machine, it is very likely to respond first.
For version 12 and up, you can replace the entire LINKS parameter with the new HOST parameter:
HOST=<remote IP address>:<remote port>
which will have the same behaviour as the LINKS parameter above.
P.S. It is recommended that you give each server a unique server name, thus avoiding the need to hard-code the IP address of the host. Not to mention that you must be using some trickery to fool the second server into either (a) thinking its name is unique, or (b) not checking to see if it's unique, which it does by default. If you use unique server names, you don't need this extra stuff.
Disclaimer: I work for Sybase in SQL Anywhere engineering.
this is really two questions in one I guess.
We've developed a .Net app that accesses an Oracle database, and have noticed that after changing the user's Oracle password, the app continues to work for a short time with the old password in the connection string. Presumably this is something to do with the way existing connections are pooled?
When first investigating this we tried turning off pooling in the connection string, however the app wouldn't work, throwing the error "Unable to enlist in a distributed transaction" at the point it tries to open a connection. While we probably wouldn't want to turn off connection pooling in a production app, I'm curious as to why MSDTC seems to need it?
We are using Oracle 11g (11.1.2) and latest ODP.Net (11.2 I think).
Thanks in advance
Andy
Please see some of the finding below:
For Question One: (application still connected with old DB password)
If we connect the database with connection pooling option, connection pool manager would create and maintain the number of connection sessions when first calling the open or close of OracleConnection object. (number of this connection sessions depend on "min" & "max" pool size in connection string). In Oracle, I think you could check active session like:
SELECT s.inst_id,
s.sid,
s.serial#,
p.spid,
s.username,
s.program
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE s.type != 'BACKGROUND';
And according to Oracle doc, this connection pooling service will close the connection sessions after 3 minutes of in-active state. [ http://docs.oracle.com/html/E10927_01/featConnecting.htm ]
So the most possible reason could be, your application still
connected to the database by using this Pool and still connected for
a short time, even after you changed the database password.
There could be also one possibility of "Oracle Client Cache"
feature in ODP.net. But not quite sure, you can check at, [
http://www.oracle.com/technetwork/issue-archive/2008/08-jul/o48odpnet-098170.html ]
For Question Two: (why MSDTC needed)
If you are using nested Database connection in your code, it will be promoted to DTC. [ http://petermeinl.wordpress.com/2011/03/13/avoiding-unwanted-escalation-to-distributed-transactions/ ] Actually there was Oracle Service for Microsoft Transaction Server (OraMTS) act as among ODP.net, DTC, and Oracle Database.
But you didn't happend this problem (MSDTC) before disabled the connection pooling. It seems like your code is reusing the same connection out of undelining connection pool, and it might eliminate the need to promote DTC. There was similar question on StaffOverflow. [ Why isn't my transaction escalating to DTC? ]
This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Delphi Client-Server Application using Firebird 2.5 embedded connection error
I have got a lengthy question to ask. First of all Im still very new when it comes to Delphi programming and my experience has beem mostly developing small single user database applications using ADO and an Access database.
I need to take the transition now to a client server application and this is where the problem starts. I decided to use Firebird 2.5 embeded as my database, as it is open source, and it is can be used with the interbase components in Delphi and that multiple clients can access the database simultanously. So I followed the interbase tutorial in Delphi. I managed to connect the client to the server and see the data in the example (While both are running on my pc), but when i tried to move the client to another pc, keeping the server on mine and running it to see if I can connect to the server it gave me the following error.
Exception EIdSocketError in module clientDemo.exe at 0029DCAC. Socket Error # 10061 Connection refused.
I understand that this might be because the host is defined as localhost in the client. But here is my first question. In the TSQLConncetion you can set die hostname under Driver->Hostname. The thing I want to know is how do you do this at run time, as I cannot get the property when I try and make an edit box to allow the user to enter the value and then set it via code like for example:
SQLConncetion1.Driver.Hostname := edtHost.text;
The thing is there is not such property to set, so how do you set the hostname at run time?
Im using Delphi XE2
There is still a lot of questions to come especially when it comes to deployment, but I will take this piece by piece and I appreciate the advice.
That means that the server: port your program is trying to connect to
is refusing your connection. Could be a firewall related issue on
either your server or your own machine.
Try using telent to connect to the server. If that succeeds you know it a problem with your machine's configuration.
Check these links for more information :
How TO Fix Socket Error 10061 Connection Refused Easily
Problem Loading (python blocked by firewall)