- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对使用 jtds 连接驱动程序非常陌生。我编写了一个应用程序,它读取大约 2500 个大型 xml,并进行 SQL 查询并针对 SQL 服务器运行。我发现当我达到一定数量的 xml 时,我的程序运行内存不足。我使用内存分析器在 eclipse 中检查了 phd 转储文件,发现 net.sourceforge.jtds.jdbc.cache.SimpleLRUCache 占用了大量内存。我连接到 SQL Server 一次并保持连接 Activity ,直到刷新所有查询。下面是我对服务器运行查询的代码。我不知道如何获取 net.sourceforge.jtds.jdbc.cache.SimpleLRUCache 类的句柄,因为它有一个明确的方法,我认为它可能会清除缓存。再说一遍,我对 jtds 驱动程序不是很了解。谁能帮我解决这个问题吗?
public boolean runQueries(String query){
if (getConn() != null && query != null) {
Statement statement = null;
try {
long start = System.currentTimeMillis();
try {
if(log.isLoggable(Level.FINEST)){
log.finest("Processing: "+query);
}
statement = getConn().createStatement();
statement.executeUpdate(query);
} catch (Exception e) {
if(log.isLoggable(Level.FINEST)){
log.log(Level.SEVERE, "Failed to process query: "
+ query, e);
}else{
String reportQuery = query.length() > MAX_CHARS_DISPLAY ? query.substring(0,MAX_CHARS_DISPLAY)+"..." : query;
log.log(Level.SEVERE, "Failed to process query: "
+ reportQuery , e);
}
}finally{
if(statement != null){
try {
statement.close();
} catch (SQLException e) {
log.log(Level.SEVERE,"Failed to close statement: ",e);
}
}
}
long end = System.currentTimeMillis();
return true;
}finally{
if(statement != null){
try {
statement.close();
} catch (SQLException e) {
log.log(Level.SEVERE,"Failed to close statement: ",e);
}
}
}
}
return false;
}
最佳答案
FAQ说明如何通过在 JDBC URL 中设置较低的 maxStatements 值来更改语句缓存的大小。如果您正在构建非常大的语句,您可能需要将该限制设置为远低于默认值 500。您还可能需要查看其中的一些其他内存设置。
关于java - net.sourceforge.jtds.jdbc.cache.SimpleLRUCache 导致内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10842809/
useBlobs=false 使用 XAPoolDataSource。 抛出异常,例如“调用 resultset.getObject() 时的标题描述” 我不知道问题是什么。 最佳答案 通用连接字符串
我基于this issue连接到SQL Server数据库。 driverClassName =“net.sourceforge.jtds.jdbc.Driver” 方言=“org.hibernate
我正在使用 JTDS 连接到 MS-SQL 2005。我使用 c3p0 作为数据库连接池,并使用 Spring 配置。 我在 Groovy 脚本中随机收到 SQLException:无效状态,Resu
我厌倦了用谷歌搜索这个错误。请帮我。我发现建议将 jtds-1.3.1.jar 添加到类路径或编辑您的 web.xml。 请告诉我该怎么做?我使用 Idea、Maven、Gwt,并希望连接到 MS S
我正在使用 JTDS 连接到 MS SQL Server。与数据库的连接没有问题,但是当我尝试执行语句时,出现数据库“java”不存在异常。 连接字符串: conn = DriverManager.g
我现在正在尝试决定使用哪个驱动程序来创建从我的 JavaEE 应用程序到 MS SqlServer 的数据源。 几年前,我对 JTDS 有了很好的体验, 和 SO answers表明 JTDS 是当时
当我直接从 SSMS 调用存储过程 (MSSQL 2008R2) 或从 JTDS 调用它时,我看到了不同的行为。 首先,请看这两个程序。 CREATE PROCEDURE [Template].[Un
使用 jtds 1.2.5 建立连接时出现此错误:“找不到消息属性 prop.sokeepalive 的消息资源” 起初,我使用的是 1.2.2 版本,但出现此错误消息。 “获取 jdbc 连接时出错
如何设置参数@p_ItemShelfList [file].[udtt_ItemShelfPair] READONLY与 一样正确 cs.setNull(3, Types.NULL); 当我尝试时,我
我有一个使用 JTDS 连接到 SQL Server 的应用程序。我需要更改数据库并希望在重新配置应用程序之前先测试连接字符串。我是一名 SQL Server DBA,而不是 Java 开发人员!这是
我需要使用 JTDS jdbc 驱动程序调用存储过程。 但是这个存储过程需要一个结构类型作为参数。Jtds CallableStatement 没有设置结构的方法,因此我尝试转换为 SQLServer
我已经离开 Java EE 有一段时间了,但我对所有这些东西都有一个基本的了解。 我在这里阅读 JTDS 文档: http://jtds.sourceforge.net/features.html 它
我的 sql 服务器实例名称是 MYPC\SQLEXPRESS,我正在尝试创建一个 jTDS 连接字符串以连接到数据库“博客”。任何人都可以帮我完成吗? 我正在尝试这样做: DriverManager
我们运行一个用 Java 编写的网站,该网站使用 JDBC 和 jTDS 来访问 SQL Server 数据库。 我们的数据库包含一个复杂的存储过程,通常需要 10 分钟才能运行。如果我们直接执行(例
我正在使用 JTDS 和 Java 连接到 Microsoft SQL 数据库。我能够完美连接到数据库。但是,当我运行下面的代码时,出现错误“找不到存储过程'get_queue_items'”。我尝试
这很奇怪,我正在连接到一个为 Windows 配置了集成身份验证的 SQL Server 2008 实例。我找到了一种通过在代码中执行此操作来绕过集成身份验证的方法: Connection con =
我正在尝试构建一个连接到我们的 SQL Server 的 Android 应用程序。我已经下载了 jTDS JDBC 驱动程序。我有一个 jar 文件,必须将其复制到我的应用程序的类路径中。但那是哪里
据我所知,jTDS 的正确连接字符串是: jdbc:jtds:://[:][/] 我认为问题出在服务器名称上。服务器名称格式如下 servername\adhoc 每当我尝试连接时抛出 SQLExce
情况 我有一个使用 jTDS 连接到 MSSQL 2008 数据库的 (Tomcat) Java Web 应用程序。此 Java 应用程序使用用户输入执行 99% 的 MSSQL 存储过程。 问题 j
我在 MS SQL Server 上有一个表,其中一列的数据类型为日期。我正在使用 jtds.jar 与数据库进行 JDBC 连接。我正在从 Connection 获取 DatabaseMetaDat
我是一名优秀的程序员,十分优秀!