微软Azure数据库和Glassfish [英] Microsoft Azure Database and Glassfish

查看:108
本文介绍了微软Azure数据库和Glassfish的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Glassfish 4.0.1上部署了一个j2ee Web应用程序,我希望与Windows Azure数据库一起使用。

应用程序使用JPA和eclipseLink。



如果我从glassfish界面ping它,它可以工作,所以我提供的属性可以。



如果应用程序在服务器启动后立即使用数据库,一切都很顺利(它可以检索/存储数据)

当应用程序在闲置一段时间后尝试使用数据库时,



如果我冲洗连接(来自glassfish管理员),它会重新开始工作,直到它闲置一段时间时间。

所以基本上,只要它执行数据库操作一切正常,但如果没有数据库操作一段时间,下一个数据库操作将导致例外。



我找到了解决方案,但我很难实现它。有人可以帮我吗?

以下是解决方案的链接
http://www.robblackwell.org.uk/2010/12/02/java-jdbc-to -sqlazure-connection-drop-workaround.html



或这里
https://msdn.microsoft.com/zh-cn/library/hh290696(v = sql.110).aspx <根据我的经验,解决这个问题的另一种方法是,你可以通过使用Java创建一个crontab监听器在Java Web应用程序上安排框架Cron4j或Quartz。 crontab监听器发送一个简单的查询(比如从t_XXX限制1中选择id),间隔小于1分钟以保持数据库连接处于活动状态。




按下Windows + R并运行regedit。检查注册表项KeepAliveTime,KeepAliveInterval和TcpMaxDataRetransmission是否存在于注册表树路径HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \Services\Tcpip\Parameters中。



如果路径中不存在,则需要以管理员身份打开cmd窗口,并将以下commonds复制到cmd窗口中以运行它们。

  REG ADD HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \Services\Tcpip\Parameters / v KeepAliveTime / t REG_DWORD / d 30000 
REG ADD HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \Services\Tcpip\Parameters / v KeepAliveInterval / t REG_DWORD / d 1000
REG ADD HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \Services\Tcpip\Parameters / v TcpMaxDataRetransmission / t REG_DWORD / d 10

然后,您可以在注册表中找到它们并测试问题。



最好的问候。


I have a j2ee web application deployed on glassfish 4.0.1 which I want to use with a Windows Azure Database.

The application uses JPA and eclipseLink.

If i ping it from the glassfish interface it works, so the properties I provide are ok.

If the application uses the database immediately after the server started, all goes well (it can retrieve/store data)

When the application tries to use the database after being idle for a while, I get an exception saying that the connection is closed.

If I flush the connection (from glassfish admin) it starts to work again, until it goes idle for a period of time.

So basically, as long as it executes database operations all works well, but if there are no database operations for a while, the next db operation will result in the exception.

I have found the solution but I am having a hard time implementing it. can someone help me please ?

Here is the link of the solution http://www.robblackwell.org.uk/2010/12/02/java-jdbc-to-sqlazure-connection-drop-workaround.html

or here https://msdn.microsoft.com/en-us/library/hh290696(v=sql.110).aspx

解决方案

Per my experience, the alternative way to solve this issue is that you can create a crontab listener by using Java Schedule framework "Cron4j" or "Quartz" on your Java Web application. The crontab listener send a simple query(like "select id from t_XXX limit 1") with an interval less than one minute to keep database connection alive.


Press "Windows+R" and Run "regedit" . Check the registry keys "KeepAliveTime", "KeepAliveInterval" and "TcpMaxDataRetransmission" whether they exist in the registry tree path "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters".

If not exist in the path, you need to open the cmd window as administrator, and copy the below commonds into the cmd window to run them.

REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v KeepAliveTime /t REG_DWORD /d 30000
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v KeepAliveInterval /t REG_DWORD /d 1000
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v TcpMaxDataRetransmission /t REG_DWORD /d 10

Then, you can find them in the regedit, and test the issue.

Best Regards.

这篇关于微软Azure数据库和Glassfish的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆