Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > jdbc3.0自动增长类型取值方案
【标  题】:jdbc3.0自动增长类型取值方案
【关键字】:jdbc3.0
【来  源】:http://www.blogjava.net/zhaijianhui/archive/2006/05/19/46952.html

jdbc3.0自动增长类型取值方案

Your Ad Here ?MySQL Connector/J下载地址
http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.1.12.zip/
主要新增功能是:
The driver now also supports "streaming" result sets, which allows users to retrieve large numbers of rows without using a large memory buffer. With newly added large-packet protocol support, the driver can send rows and BLOBs up to 2 gigabytes in size.

New features from the JDBC-3.0 API in the latest production version of MySQL Connector/J include getGeneratedKeys which allows users to retrieve auto-increment fields in a non-database-specific way. Auto-increment fields now work with object-relational mapping tools, as well as Enterprise Java Beans (EJB) servers with Container Managed Persistence (CMP) that support JDBC-3.0.

The development version is being refactored to support new features in conjunction with version 4.1 of the MySQL database server, including server-side prepared statements and improved handling of multiple simultaneous character sets, including Unicode in the UCS2 and UTF8 encodings.

Retrieval of Auto Generated Keys:
主要针对自动增长类型的数据取值的问题:
比如我们插入一条数据:
像原来jdbc2.0时我们这样干的:
Int rowcount = stmt.executeUpdate (
"insert into LocalGeniusList (name) values ('Karen')"); // insert row
// now get the disk address – rowid – for the newly inserted row
ResultSet rs = stmt.executeQuery (

"select rowid from LocalGeniusList where name = 'Karen'");
jdbc3.0时我们可以在插入一条记录时同时得到行数,
还可以访问到自动增长的数据如:
Int rowcount = stmt.executeUpdate (
"insert into LocalGeniusList (name) values ('Karen'),
Statement.RETURN_GENERATED_KEYS); // insert row AND return key
ResultSet rs = stmt.getGeneratedKeys (); // key is automatically available
而有些数据库不支持自动增长类型的数据,jdbc3.0也给出相应的支持:
// insert the row and specify that you want the employee ID returned as the key Int rowcount = stmt.executeUpdate ( "insert into LocalGeniusList (name) values ('Karen'), "employeeID");
ResultSet rs = stmt.getGeneratedKeys (); // Karen's employeeID value is now available
要想了解更多的jdbc3.0可以参考下面的网站:
http://www.datadirect.com/developer/jdbc/topics/jdbc30/index.ssp
http://www-128.ibm.com/developerworks/java/library/j-jdbcnew/
http://www.onjava.com/pub/a/onjava/synd/2001/08/21/jdbc.html?page=3
jdbc4.0参考网站
http://www.theserverside.com/news/thread.tss?thread_id=34465
http://weblogs.java.net/blog/lancea/archive/2006/05/jdbc_40_sqlxml.html
http://java.sys-con.com/read/111252.htm
下载jdbc4.0规范
http://192.18.108.135/ECom/EComTicketServlet/BEGIN747810F695946413098EEF45230B1F12/-2147483648/1488530847/1/686798/686786/1488530847/2ts+/westCoastFSEND/jdbc-4.0-pr-spec-oth-JSpec/jdbc-4.0-pr-spec-oth-JSpec:2/jdbc4.0-pd-spec.pdf
cookie技术与欺骗:【上一篇】
eclipse3.1下试用画图插件:【下一篇】
【相关文章】
  • JDBC3.0研究(转载)
  • 【随机文章】
  • 修改数据库中裸设备名
  • 2.6.13 .config
  • 如何枚举本地的连接
  • WIN2000进程问题
  • duelist crackme 2 破解(上)
  • 用PB编写邮件应用程序
  • 实验:编写一个微型shell(2)
  • 内核配置浅析
  • Flash趣味游戏制作:猜数字
  • pttys是什么?
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.