weblogic的jdbc中调用createStatement(int, int, int)出错?

dps12345 2003-08-22 01:59:05
连接池配置:
<JDBCConnectionPool DriverName="weblogic.jdbc.mssqlserver4.Driver"
InitialCapacity="10" MaxCapacity="100" Name="accountDBPool"
Properties="user=account;password=account" Targets="myserver" URL="jdbc:weblogic:mssqlserver4:account@localhost:1433"/>
<JDBCTxDataSource EnableTwoPhaseCommit="true" JNDIName="accountDS"
Name="account tx DataSource" PoolName="accountDBPool" Targets="myserver"/>

启动正常, 一般jdbc调用也正常, 只是调用createStatement(int, int, int)时出错, jsp程序:
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<html>
<head>
<title>
testwlsds
</title>
</head>
<body bgcolor="#ffffff">

<%
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
try {
Context initCtx = new InitialContext(p);
DataSource ds = (DataSource) initCtx.lookup("accountDS");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY,
ResultSet.CLOSE_CURSORS_AT_COMMIT);
ResultSet rs = stmt.executeQuery("select * from product");
rs.last();
out.println("product count = " + rs.getRow());
stmt.close();
conn.close();
} catch (Exception e) {
out.println(e.getMessage());
e.printStackTrace();
}
%>

</body>
</html>

运行后页面打出:
This JDBC 3.0 method is not implemented

好像是weblogic不支持JDBC3.0, 如何才能让它支持JDBC3.0?

然后我把jsp页面中
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY,
ResultSet.CLOSE_CURSORS_AT_COMMIT);
改成
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
结果出错:
java.sql.SQLException: This JDBC 2.0 method is not implemented
不会是连JDBC2.0也不支持吧?

后来我把sqlserver的驱动换了, 配置如下:
<JDBCConnectionPool
DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
InitialCapacity="10" MaxCapacity="100" Name="accountDBPool"
Properties="databasename=account;user=account;password=account"
Targets="myserver" URL="jdbc:microsoft:sqlserver://localhost:1433"/>
<JDBCTxDataSource EnableTwoPhaseCommit="true" JNDIName="accountDS"
Name="account tx DataSource" PoolName="accountDBPool" Targets="myserver"/>
结果页面打出:
[Microsoft][SQLServer JDBC Driver]Error reading data from static cursor cache.
log中报错:
java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Error reading data from static cursor cache.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseImplStaticCursorResultSet.cacheCurrentRow(Unknown Source)
at com.microsoft.jdbc.base.BaseImplStaticCursorResultSet.fetchAndCache(Unknown Source)
at com.microsoft.jdbc.base.BaseImplStaticCursorResultSet.fetch(Unknown Source)
at com.microsoft.jdbc.base.BaseImplStaticCursorResultSet.positionCursor(Unknown Source)
at com.microsoft.jdbc.base.BaseImplStaticCursorResultSet.postSetupInitialize(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.<init>(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonGetNextResultSet(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)
at weblogic.jdbc.pool.Statement.executeQuery(Statement.java:863)
at weblogic.jdbc.rmi.internal.StatementImpl.executeQuery(StatementImpl.java:81)
at weblogic.jdbc.rmi.SerialStatement.executeQuery(SerialStatement.java:83)
at jsp_servlet.__testwlsds._jspService(__testwlsds.java:111)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:945)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:332)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:376)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:20)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5366)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:721)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3043)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2468)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
我查了一下, 是rs.last()这句出错, 为什么?
是不是我的weblogic7.0需要安装sp? 还是weblogic7.0与我安装的jdk1.4.2不兼容?
请高手帮帮忙, 搞了一天了, 多谢了.
...全文
100 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dps12345 2003-08-22
  • 打赏
  • 举报
回复
求人不如求己啊, 从微软网站下载最新sqlserver for jdbc驱动, 问题解决

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧