`
100Air
  • 浏览: 118102 次
  • 性别: Icon_minigender_1
  • 来自: 海南
社区版块
存档分类
最新评论

从ms2000 转到2005 出现的错误:Microsoft][SQLServer 2000 Driver for JDBC]Underlying input

阅读更多
转载的地址:http://www.shamoxia.com/html/y2010/2249.html 

  最近针对一个比较老的数据库开发一个个性化论文推荐系统,由于系统比较陈旧,用的数据库的平台还是sqlserver2000,大家现在其实已经都用2005或者2008甚至更高的版本了,但是为了和系统兼容,我们也还是用2000系统吧。

但是在开发过程中,在进行数据导入的时候,经常遇到这种问题:

    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Underlying input stream returned zero bytes…..

经过搜索原因,是因为原来数据库中有些表中的有些text类型的字段为“”,不是null也不是NULL,就是“”,这就产成了问题,这个根据说明是jdbc 2000的一个bug,用到的jar包就是msbase.jar、mssqlserver.jar和msutil.jar,但是现在遇到这种bug,就不能用这种jdbc驱动了。

那我们就升级jdbc驱动吧,现在最新的是Microsoft SQL Server JDBC Driver 3.0,那我们就下载,用之。

    由于在互操作性方面的不懈努力,Microsoft 已发布新的 Java 数据库连接 (JDBC) 驱动程序。所有 SQL Server 用户都可以免费下载 SQL Server JDBC Driver 3.0,并可以从任何 Java 应用程序、应用程序服务器或支持 Java 的小程序访问 SQL Server 2008 R2、SQL Server 2008、SQL Server 2005 和 SQL Server 2000。这是一个 Type 4 JDBC 驱动程序,它通过 Java Platform Enterprise Edition 5 及更高版本中可用的标准 JDBC 应用程序编程接口 (API) 提供数据库连接。

下载,安装,会有一个默认的文件夹Microsoft SQL Server JDBC Driver 3.0,里面有sqljdbc_3.0,然后不断进入每层目录,会发现有两个jar文件:sqljdbc4.jar和sqljdbc.jar,根据你的开发平台的不同,要选择不同的jar,一个jar就足够了。

注意: sqljdbc4.jar 类库要求使用 6.0 或更高版本的 Java 运行时环境 (JRE)。

由于我们的开发平台是myeclipse6.5+jdk1.6+tomcat5.5(关于tomcat版本不兼容之小问题看此博文),用的compile是6.0,所以就得使用sqljdbc4.jar,不然会报错的,然后程序中链接数据库也需要修改了:

使用 sqljdbc.jar 类库时,应用程序必须首先按如下所示注册驱动程序:
查看源代码
打印帮助
1 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

加载驱动程序后,可通过使用连接 URL 和 DriverManager 类的 getConnection 方法来建立连接:
查看源代码
打印帮助
1 String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
2 "databaseName=AdventureWorks;user=MyUserName;password=*****;";
3 Connection con = DriverManager.getConnection(connectionUrl);

在 JDBC API 4.0 中,DriverManager.getConnection 方法得到了增强,可自动加载 JDBC Driver。因此,使用 sqljdbc4.jar 类库时,应用程序无需调用 Class.forName 方法来注册或加载驱动程序。

行了,应该可以使用了
分享到:
评论

相关推荐

    有关数据库连接的问题

    根据提供的信息,这里使用的是Microsoft JDBC Driver 4.1 for SQL Server (SQLJDBC4.jar)。首先需要下载并安装该驱动程序。如果已经下载了对应的jar包,还需要安装dll文件(`sqljdbc_auth.dll`),该文件主要用于...

    net.sourceforge.jtds.jdbc.Driver 找不到

    解决办法: 1.检查对应的数据库JAR包是否导入工程 2.检查.classpath文件里是否引入<classpathentry exported="true" kind="lib" path="C:/workspace/jtds-1.2.jar"/> 3.检查对应的JAR包是否导入Tomcat下的/common/...

    SQL Server 2012 Data Integration Recipes: Solutions for Integration Services PDF

    If you're looking for a resource to cover data integration and ETL across the gamut of Microsoft's SQL Server toolset, SQL Server 2012 Data Integration Recipes is the one book that will meet your ...

    Inside SQL Server 2005 Tools

    <br>Microsoft SQL Server 2005's high-powered management tools can dramatically <br>improve DBA productivity and effectiveness. Now there's a comprehensive guide <br>to SQL Server 2005's ...

    mysql 异常com.mysql.jdbc.CommunicationsException

    本次异常的具体描述为:“Communications link failure due to underlying exception: **BEGINNESTED EXCEPTION** java.io.EOFException STACK TRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully...

    Pro.SQL.Server.Always.On.Availability.Groups.1484220706.epub

    database administrators, and IT professionals who are tasked with architecting and deploying a high-availability and disaster recovery solution involving Microsoft SQL Server. This book is also for ...

    解决Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

    Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException The last packet successfully received from the server was 47,795,922 milliseconds ago. The last packet sent successfully to the server was...

    SQL server语言语法手册

    The book covers the latest version of the SQL standard, SQL-99, and includes two complete case studies, showing how to create and query the underlying database for a fully featured web site, and how ...

    hive_jdbc_2.6.5.1007.zip

    连接hive所需的数据库驱动: Hive JDBC Connector 2.6.5 for Cloudera... The driver achieves this by translating calls from the application into SQL and passing the SQL queries to the underlying Hive engine.

    Cloudera Hive JDBC 2.5.20.1060

    The Cloudera JDBC Driver for Hive enables your enterprise users to access Hadoop data through Business Intelligence (BI) applications with JDBC support. The driver achieves this by translating calls ...

    hibernate.properties

    #hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor ## The New Microsoft Driver #hibernate.connection.driver_class ...

    微软内部资料-SQL性能优化2

    In this module we will discuss Microsoft® SQL Server™ interaction with the operating system and methodology of troubleshooting server-based problems. At the end of this module, you will be able to:...

    JDBC 程序的常见错误及调试方法

    例如,MySQL数据库的URL格式可能是“jdbc:mysql://localhost:3306/数据库名”,而SQL Server的URL则可能是“jdbc:microsoft:sqlserver://服务器名:端口号; DatabaseName=数据库名”。因此,解决方法是仔细检查URL...

    OTL+代码+实例+帮助

    OTL 4.0 supports all versions of Oracle starting with 7.3 (natively via the corresponding version of the OCI), DB2 UDB LUW / zOS (natively via DB2 CLI), MS SQL Server 2005/2008 (natively via SNAC), ...

    微软内部资料-SQL性能优化5

    Without a useful index, Microsoft® SQL Server™ must search every row on every page in table to find the rows to return. With a multitable query, SQL Server must sometimes search a table multiple ...

    Pro SQL Server 2012 Relational Database Design and Implementation(Apress,2012)

    Grounded in best practices and a solid understanding of the underlying theory, Louis Davidson shows how to "get it right" in SQL Server database design and lay a solid groundwork for the future use ...

    微软内部资料-SQL性能优化3

    For more information about how to decode this value, see also… Inside SQL Server 2000, pages 803 and 806. Key Range Locking Key Range Locking To support SERIALIZABLE transaction semantics, ...

Global site tag (gtag.js) - Google Analytics