通过Applet + JDBC 访问 数据库,在浏览器端是否必须安装JDBC Driver?谢谢!

bonhomme 2003-10-16 12:27:09
通过Applet + JDBC 访问 数据库,在浏览器端是否必须安装JDBC Driver?谢谢!
...全文
60 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lastdrop 2003-10-16
  • 打赏
  • 举报
回复
不会吧,在Applet中访问数据库,也太违反设计模式了吧?
hero1840 2003-10-16
  • 打赏
  • 举报
回复
必须安装JDBC Driver
java 实现连接sql server 20002007-12-16 13:28:00.0 第一种:通过ODBC连接数据库 JAVA语言的跨平台的工作能力(Write Once ,Run Anywhere)、优秀的图像处理能力(我相信现在没有那种语言可以超过JAVA在网络上的图形处理能力)、网络通信功能、通过JDBC数据库访问技术等等,让我们谁都不可否认JAVA语言是SUN公司对于计算机界的一个巨大的贡献。笔者可以描述这样一个场景:有一天你上网完全可以不用IE 或者NETSCAPE,上网就像是玩游戏,你可以获得游戏那么精美的图像和互动的感觉,如果你玩过UO,也许你就知道那种感觉了,但是JAVA做成的东西一定会超过UO的,因为不单单是游戏,也不是单单是浏览器,如果你愿意(要你有钱,有时间,有优秀的JAVA人才)你可以把所有的这一切用Java完全集成出来!!!我不是夸大JAVA的功能,大家可以访问一下http://www.simchina.net的那个社区程序,你就能找到一种感觉了:相信我没有说什么假话 。好了,不说废话了,现在我向你介绍JAVA的数据库访问技术----JDBC数据库访问技术(你可千万不要搞成ODBC了哟!)。 JDBC技术事实上是一种能通过JAVA语言访问任何结构化数据库的应用程序接口(API)(Sun这样说的,我也不知道是不是真的),而且现在的JDBC 3.0据Sun说也能访问Execel等电子表格程序! JDBC对于数据库访问有四种方式,我们这里只是介绍两种: 第一种是通过ODBC做为“桥”(Bridge)对数据库访问,第二种是直接对数据库访问。 我们先来看看第一种JDBC<-->ODBC访问的流程: JDBC Driver Mannager->JDBC<->ODBC桥->ODBC->数据库客户机驱动库->数据库服务器->返回查询结果,在这种访问中值的我们注意的是虽然JAVA是"Write Once ,Run Anywhere",但是如果通过这种访问的话,需要客户必须设置ODBC和有相应的数据库客户机的驱动,当你看了下面的另外一个流程的时候或许你会想:明明下一种更方面,为什么还要有这个东西的产生!呵呵,因为,未必所有的数据库服务器提供商都提供下面的JDBC驱动程序(给JDBC访问提供相应的接口),所以就有了JDBC<->ODBC Bridge。 接着再让我们来看看第二种访问流程: JDBC Driver Mannager->局部JDBC驱动->客户数据库->数据库服务器->返回查询结果,这种访问事实上是转换JDBC调用为相应的数据库(Oracle, Sybase, Informix, DB2, 和其他的数据库数据库管理系统)的客户API调用(这么说,不知道大家能不能懂,说简单点就好像ASP不是通过DSN对数据库访问而是通过OLEDB访问,说道这里我还是不知道大家能不能明白我的意思。哎呀,不要扔鸡蛋嘛!),这种方式的访问需要相应的数据库提供商提供相应的JDBC驱动程序,但是有一种好处,可以独立于odbc用于可以随处可Run的客户浏览器中的Applet程序。 我们下面将给大家一个通过JDBC-ODBC桥数据库访问的实例,但是在看下面的事例前我想问大家一次:JDK1.3装了吗?数据库驱动装了吗(我使用的是SQLserver)?你该没有使用Linux吧?虽然java支持Linux,但是老兄我可没有使用Linux哟(这同JAVA的Write Once ,Run Anywhere没有关系),由于使用了运行于Win下面的ODBC,我建议你看看这篇东西http://www.aspcn.com/showarticle.asp?id=112,否则你要是有了问题,出不了结果那岂不是要怪我(不过欲加之罪,何患无吃... ...),冤枉呀! 哎呀,说了这么多的废话,还是让我们来看看到底JDBC的调用吧!既然我们是通过odbc访问数据库,所以这个odbc是跑不了的,我们先来设置你的odbc:打开你的odbc数据源->选择系统dsn(Click加新的dsn-)->接下来输入选择数据库类型、输入dsn名:、选择服务器、连接数据库的方式、输入数据库的登陆用户和密码->测试连接,如果测试成功的话,那么你的dsn就建立好了,我的dsn名为Sqlserver.使用的是sqlserver7.0,以 “sa”登陆,密码为空。这些东西都是后面要用道的! 好了下面让我们来看程序代码: (该代码已经通过运行) //########################################################### //代码开始 //########################################################### import java.sql.*; //加载java数据连接包,java基本所有的数据库的调用的都在这个东西里面 public class InsertCoffees { public static void main(String args[]) { String url = "jdbc:odbc:sqlserver"; //取得连接的url名,注意sqlserver是dsn名 Connection con; //实例化一个Connection对象 Statement stmt; String query = "select * from col_link"; //选择所有的Col_link表中的数据输出 try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //加载jdbc-odbc桥驱动 } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); //加载jdbc-odbc桥错误 System.err.println(e.getMessage()); //其他错误 } try { con = DriverManager.getConnection(url, "sa", ""); //数据库连接 stmt = con.createStatement(); //Create 一个声明 stmt.executeUpdate("CREATE TABLE col_link (sitename varchar (20) NULL ,siteurl varchar (50) NULL) "); //执行了一个sql语句生成了一个表col_link的表 stmt.executeUpdate("insert into col_link values('ASP中华网','http://www.aspcn.com')"); stmt.executeUpdate("insert into col_link values('永远到底有多远','http://xuankong.com')"); //执行一个insert into语句 stmt.executeUpdate("update col_link set siteurl='http://www.aspcn.com/xuankong/xuankongt.jpg' where siteurl='http://xuankong.com'"); //执行一个update语句,更新数据库 ResultSet rs = stmt.executeQuery(query); //返回一个结果集 System.out.println("Col_link表中的数据如下(原始数据)"); //下面的语句使用了一个while循环打印出了col_link表中的所有的数据 System.out.println("站点名 "+" "+"站点地址"); System.out.println("---------------"+" "+"----------------"); while (rs.next()) { String s = rs.getString("sitename"); String f = rs.getString("siteurl"); //取得数据库中的数据 System.out.println(s + " " + f); /*String t = rs.getString(1); String l = rs.getString(2); System.out.println(t + " " + l);*/ /*jdbc提供了两种方法识别字段,一种是使用getXXX(注意这里的getXXX表示取不同类型字段的不同的方法)获得字段名, 第二种*是通过字段索引,在这里我把第二种方法注释了*/ /*你可以访问这个连接获得getxxx的用法:http://java.sun.com/docs/books/tutorial/jdbc/basics/_retrievingTable.html*/ } stmt.close(); con.close(); //上面的语句关闭声明和连接 } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); //显示数据库连接错误或者查询错误 } } } //########################################################### //代码结束 //########################################################### 在上面这个程序中我想你展示了如何使用JDBC-ODBC连接数据库,使用SQL语句生成一个表,使用SELECT、INSERT 、UPDATE语句取的、插入和更新一个表中的数据,如何通过字段名和字段索引访问数据库中的东东!我希望你能从上面的代码真正的学习到一些东西! 发挥你的想象力,设想一下JAVA到底,比如说可以通过数据库做一个不需要GUI(图形用户界面)的聊天室,呵呵,感觉起来就像在DOS环境下打字的聊天室!哈哈! 最后需要说的是笔者的调试上面程序的环境:WIN2000 , JDK1.3,MS SQLSERVER编辑软件:EDITPLUS 2.01a(这最后的东西可不是废话,虽然早就了一些专业的JAVA开发工具,但是笔者建议JAVA初学者使用文本软件开发JAVA程序) 第二种:直接用jdbc访问数据库 (1) 该实例已经运行通过 jsp连接Sql Server7.0/2000数据库 testsqlserver.jsp如下: <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs"; //pubs为你的数据库的 String user="sa"; String password=""; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from test"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getString(1);%> 您的第二个字段内容为:<%=rs.getString(2);%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> (2)java访问sqlserver服务器 第一步:安装jdbc 点击SQL Server for JDBC驱动程序安装程序setup.exe(可以到微软网站下载 http://msdn.microsoft.com/library/default.asp?rul=/downloads/list/sqlserver.asp下载) 第二步:设置系统变量classpath 假设SQL Server for JDBC 驱动程序安装在d:\jdbc\,则classpath应该设置如下: classpath:=.;…;d:\jdbc\lib; d:\jdbc\lib\mssqlserver.jar; d:\jdbc\lib\msutil.jar; d:\jdbc\lib\msbase.jar; 注意:设置时要在最前面的点号和分号 第三步:编辑java程序并且运行 实例1如下: //import com.microsoft.*; //注意:在java与sql server 连接时不需要这个包,其他书上说这个包是必需的,这个问题有待进一步讨论 import java.sql.*; import java.net.URL; class insert { public static void main(String[] args) { String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind"; String query="select * from categories"; String query1="insert categories values(10,'Hanbao','Sweet')"; String query2="insert categories values(11,'Naicha','Coffee taste')"; try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection(url,"sa","739555"); Statement stmt=con.createStatement(); stmt.executeUpdate(query1); stmt.executeUpdate(query2); stmt.close(); con.close(); } catch(SQLException ex) { } catch(java.lang.Exception ex) { ex.printStackTrace(); } } } 实例2如下: //import com.microsoft.*; //注意:在java与sql server 连接时不需要这个包,其他书上说这个包是必需的,这个问题有待进一步讨论 import java.sql.*; import java.net.URL; class java2sqlserver { public static void main(String[] args) { String url="jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=739555;DatabaseName=northwind"; String query="Select * From Categories"; try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); //DriverManager.setLogStream(System.out); Connection con=DriverManager.getConnection(url); checkForWarning(con.getWarnings()); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(query); dispResultSet(rs); rs.close(); stmt.close(); con.close(); } catch(SQLException ex) { System.out.println(ex.toString()+"----SQLException caught----"); while(ex!=null) { System.out.print("SQLState:"+ex.getSQLState()); System.out.print("Message:"+ex.getMessage()); System.out.print("Vendor:"+ex.getErrorCode()); ex=ex.getNextException(); System.out.println(""); } } catch(java.lang.Exception ex) { ex.printStackTrace(); } } private static boolean checkForWarning(SQLWarning warn) { boolean rc=false; if(warn!=null) { System.out.println("----Warning----"); rc=true; while(warn!=null) { System.out.print("SQLState:"+warn.getSQLState()); System.out.print("Message:"+warn.getMessage()); System.out.print("Vendor:"+warn.getErrorCode()); System.out.println(""); warn=warn.getNextWarning(); } } return rc; } private static void dispResultSet(ResultSet rs) throws SQLException { int i; ResultSetMetaData rsmd=rs.getMetaData(); int numCols=rsmd.getColumnCount(); for(i=1;i<=numCols;i++) { if(i>1) System.out.print(", "); System.out.print(rsmd.getColumnLabel(i)); } System.out.println(""); boolean more=rs.next(); while(more) { for(i=1;i
快逸报表使用 在网上找个很多资料,也按着资料去尝试了多次,最终都以失败告终,也发现大部分文章都是拷贝粘贴来的,真不知道那些作者怎么想的,为什么不亲身测试后再贴到自己博客里呢,好了,废话少说,经过那么多次失败,最终亲测成功,特别整理发表,为那些刚接触快逸报表的同胞们省去不必要浪费的时间. 一. 下载并安装快逸报表软件工具 下载安装不需要过多赘述,跟安装日常软件没什么区别,值得提到的是必须安装好环境, 先安装 JDK,还有Tomcat 相关的配置步骤网上很多资料,相信不会难倒读者.笔者使用快逸报表版本为4.2.20,JDK1.5,Tomcat 6.0. 二. 报表设计 (1)关于授权 打开报表设计器,如果提示授权的话,你可以到安装目录下找到,笔者安装在了C盘, 所以目录如下C:\ProgramFiles\quieeReport\webapps\quiee\WEB-INF\classes 可以看到相关的授权. (2)配置数据源 打开设计器之后, 安装后打开报表设计器,选择配置-数据源-新建-关系数据库,开始配置数据源,笔者用的是mysql,以mysql举例: 其中关键位置如下: 数据源名称要记住,因为在部署的时候,配置数据库时名字要和这保持一致.数据库类型选择相应的类型,数据源URL默认不是本机,需要修改,当然如果在其他机器上需要填写相应的IP地址,后面填写相应的数据库名字.下面填写数据用户名和密码.完成之后回到数据源窗口,选择刚创建的数据源,点击连接,数据源变色说明连接成功。.关闭窗口. (3)配置数据集创建报表 选择文件-新建报表,打开新建报表向导,填写数据源,下一步 注意数据源的名字也要保持一致,点击 下一步,按着提示进行下一步就可以, 最后点击生成网格报表,报表就生成了. 报表的表头可以修改为中文 完成之后,启动快逸报表的服务,将报表保存发布. 四个图标左边第三个是进行发布的,点击会提示进行保存报表,按提示进行保存.之后可以点击IE图标进行预览. 三. 在J2EE中部署快逸报表 在已有的 J2EE 项目中使用刚才创建的报表,需要如下步骤: (1) 导入 jar 包和相关文件 (a)将快逸报表安装目录\quieeReport\webapps\quiee\WEB-INF\lib中的 jar 包导入项目,并且导入所需要的mysql驱动包. (b)将\quieeReport\webapps\quiee\WEB-INF 目录下的 reportConfig.xml,runqianReport4.tld,runqianReportLog.properties 复制到项目的 WEB-INF 目录 (c)将\quieeReport\webapps\quiee 目录下的 j2re-1_4_1-windows-i586-i.exe,Myerror.jsp,myInputError.jsp, runqianReport4Applet.jar 和 images 目录(用于工具按 钮的图片可自选)复制到项目的 WebRoot 目录下。 (2) 修改web.xml文件 在 web.xml 文件中增加如下内容: SetContextServlet com.runqian.util.webutil.SetContextServlet 2 reportServlet com.runqian.report4.view.ReportServlet      configFile /WEB-INF/reportConfig.xml 1 reportServlet /reportServlet (3) 创建jsp文件 可以直接使用\quieeReport\webapps\quiee\reportJsp目录下的 showReport.jsp和 toolbar.jsp 文件。其中 showReport.jsp 用于显示报表,toolbar.jsp 用于显示工具按钮。 (4) 在项目中导入报表文件 在上面发布报表的路径下找到报表文件,将生成的.raq 报表文件导入项目。 (5) 添加授权文件 复制quieeReport\webapps\quiee\WEB-INF\classes目录下的授权文件,根据使用的操作系统进行选择, 到项目的 WebRoot 目录, 可能需要修改 reportConfig.xml 文件中的部分内容. 如果你用的不是window系统,更改成与您对应的授权的文件.特别注意的是”/”反斜杠符号 ,拷贝过来的文件里原本是没有的 (6) 修改reportConfig.xml文件 在其中添加如下配置内容,主要用于数据库的连接,需要主要的地方是name参数,需要跟报表文件的数据源名称一致. <!-- 配置快逸加载数据时候的datasource --> <jdbc-ds-configs> <jdbc-ds-config> mysql mysql jdbc:mysql://localhost:3306/test <driver-class>com.mysql.jdbc.Driverdriver-class> root 123 gbk gbk jdbc-ds-config> jdbc-ds-configs> 注意的地方: 这个地方一定要和制作报表时候的数据源名字一致, (7) 访问报表 发布上述 J2EE 项目,启动 tomcat,访问报表的 url 地址 为: 项目名称/reportJsp/showReport.jsp?raq=/报表名称.raq 就可以看到我之前做的报表,这个时候很多人会发现出现找不到报表配置文件的错误,而且这个问题也困扰了我很久,网上找了资料,按其操作并没有解决,经过又查找资料,终于找到问题根源,在于jar包的问题,其中一个很重要的jar包---webutil.jar,快逸报表自身带的jar是不能用的,本人所用版本这个jar包为3.6kb,替换成一个网上找打一个新的4.05kb大小的webutil.jar后,问题解决了.
大工 15 春《Java 程序设计》在线作业 3 单选题 判断题 一、单选题(共 10 道试题,共 50 分。 ) 1. 下列协议中不属于应用层协议的是( ) 。 A. DNS B. ICMP C. Telnet D. SMTP ----------------- 选择:B 2. 下列不属于 TCP/IP 协议族体系结构层的是( ) 。 A. 应用层 B. 会话层 C. 网络层 D. 网络接口层 ----------------- 选择:B 3. 下列完整性,不属于关系型数据库三类完整性规则的是( ) 。 A. 实体完整性 B. 数据完整性 C. 参照完整性 D. 用户定义完整性 ----------------- 选择:B 4. 下列哪个类是 Applet 类的直接父类( ) 。 A. Component 类 B. Container 类 C. Frame 类 D. Panel 类 ----------------- 选择:D 5. A. 8 大工15年春《Java-程序设计》在线作业三100分答案全文共3页,当前为第1页。B. 14 大工15年春《Java-程序设计》在线作业三100分答案全文共3页,当前为第1页。 C. 16 D. 22 ----------------- 选择:B 6. 下列关于 Java 类的叙述正确的是( ) 。 A. Applet 可以独立运行 B. Applet 不能容纳其他组件 C. Panel 类是 Applet 类的子类 D. JApplet 类是 Applet 类的子类 ----------------- 选择:D 7. 关于流的描述,下列错误的是( ) 。 A. 流是一组字节集合 B 类 IPv4 地址最多可用( )位来划分子网。 B. 流的基本操作有读操作和写操作 C. 流使数据传输操作独立于相关设备 D. 流无方向性 ----------------- 选择:D 8. 下列接口,不属于 JDBC 驱动程序必须实现的主要接口的是( ) 。 A. Driver B. Connection C. List D. ResultSet ----------------- 选择:C 9. 下列应用层协议,哪一项是 UDP 协议所支持的( ) 。 A. HTTP 协议 B. FTP 协议 C. SNMP 协议 D. SMTP 协议 ----------------- 选择:C 10. 下列关于 TCP Socket 通信原理描述,错误的是( ) 。 A. IP 协议是网络层的核心协议 B. TCP 和 UDP 协议都属于传输层协议 C. TCP 协议和 IP 协议都是面向连接的协议 D. UDP 协议和 IP 协议都是无连接的协议 ----------------- 选择:C 大工 15 春《Java 程序设计》在线作业 3 单选题 判断题 二、判断题(共 10 道试题,共 50 分。 ) 1. TCP 和 UDP 协议都是面向连接的协议。 A. 错误 B. 正确 ----------------- 选择:A 2. JDBC 和 ODBC 数据源都需要手工配置。 A. 错误 B. 正确 ----------------- 选择:A 大工15年春《Java-程序设计》在线作业三100分答案全文共3页,当前为第2页。 大工15年春《Java-程序设计》在线作业三100分答案全文共3页,当前为第2页。 3. 文件是一种存储在外部存储介质上的信息的集合。 A. 错误 B. 正确 ----------------- 选择:B 4. 流的概念是文件系统组织和管理文件的基本单位。 A. 错误 B. 正确 ----------------- 选择:A 5.SQL Server 数据库和 MySQL 数据库都是 C/S 结构的关系型数据库。 A. 错误 B. 正确 ----------------- 选择:B 6. Java 提供 ServerSocket 类和 Socket 类实现 TCP Socket 通信。ServerSocket 类提供进行通 信的 Socket 对象。 A. 错误 B. 正确 ----------------- 选择:A 7. Java 编程语言支持多文档界面技术。 A. 错误 B. 正确 ----------------- 选择:B 8. RandomAccessFile 类对文件可以进行既读又写的操作。 A. 错误 B. 正确 ----------------- 选择:B 9. 文件的存取方式通常有顺序存取、随机存取和索引存取三种方式。 A. 错误 B. 正确 ----------------- 选择:B 10. Reader 类和 Writer 类是字符输入/输出流的非抽象类。 A
Java Platform Standard Edition 7 Documentation What's New Documentation Release Notes Tutorials and Training The Java Tutorials Java Training More Information Java SE 7 Names and Versions Java SE White Papers Documentation Accessibility Specifications Installation Instructions Supported Systems Configurations Java SE 7 and JDK 7 Compatibility JDK 7 Adoption Guide Troubleshooting Java SE About Test / Sample Applications and Code Resources Oracle Java SE Advanced and Oracle Java SE Suite Open JDK Bugs Database Downloads Java SE Downloads Community Forums Blogs User Groups Wikis Newsletters Events Other Technologies Java EE Java ME Java FX GlassFish NetBeans Oracle has two products that implement Java Platform Standard Edition (Java SE) 7: Java SE Development Kit (JDK) 7 and Java SE Runtime Environment (JRE) 7. JDK 7 is a superset of JRE 7, and contains everything that is in JRE 7, plus tools such as the compilers and debuggers necessary for developing applets and applications. JRE 7 provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language. The following conceptual diagram illustrates Java component technologies: JDK Java Language Java Language ` Tools & Tool APIs java javac javadoc jar javap JPDA JConsole Java VisualVM Java DB Security Int'l RMI IDL Deploy Monitoring Troubleshoot Scripting JVM TI JRE RIAs Java Web Start Applet / Java Plug-in User Interface Toolkits AWT Swing Java 2D Accessibility Drag n Drop Input Methods Image I/O Print Service Sound Java SE API Integration Libraries IDL JDBC JNDI RMI RMI-IIOP Scripting Other Base Libraries Beans Int'l Support Input/Output JMX JNI Math Networking Override Mechanism Security Serialization Extension Mechanism XML JAXP lang and util Base Libraries lang and util Collections Concurrency Utilities JAR Logging Management Preferences API Ref Objects Reflection Regular Expressions Versioning Zip Instrumentation Java Virtual Machine Java HotSpot Client and Server VM Description of Java Conceptual Diagram What's New in Documentation Documentation is regularly updated to provide developers with in-depth information about new features in the Java platform. Some recent updates include: Swing The JLayer class has been added, which is a flexible and powerful decorator for Swing components; see How to Decorate Components with JLayer. The Nimbus Look and Feel has been moved from the com.sun.java.swing package to the javax.swing package; see the javax.swing.plaf.nimbus package. Mixing Heavyweight and Lightweight Components is easier to accomplish. Windows with transparency and non-rectangular shape are supported; see How to Create Translucent and Shaped Windows An HSV tab has been added to the JColorChooser class. Java I/O The java.nio.file package and its related package, java.nio.file.attribute, provide comprehensive support for file I/O and for accessing the file system; see File I/O (featuring NIO.2). NIO stands for non-blocking I/O. The directory /sample/nio/chatserver/ contains samples that demonstrate the new APIs contained in the java.nio.file package. The directory /demo/nio/zipfs/ contains samples that demonstrate the NIO.2 NFS (Network File System) file system. Networking The URLClassLoader.close method has been added; see Closing a URLClassLoader. The Sockets Direct Protocol (SDP) provides access to high performance network connections; see Understanding the Sockets Direct Protocol. Security A new native provider has been added that provides several ECC-based algorithms (ECDSA/ECDH); see Sun PKCS#11 Provider's Supported Algorithms in Java PKCS#11 Reference Guide. Weak cryptographic algorithms can now be disabled; see Appendix D: Disabling Cryptographic Algorithms in Java PKI Programmer's Guide and Disabled Cryptographic Algorithms in Java Secure Socket Extension (JSSE) Reference Guide. Various enhancements related to SSL/TLS have been added to Java Secure Socket Extension. Collections The TransferQueue interface has been added, which is a refinement of the BlockingQueue interface. The class LinkedTransferQueue implements the TransferQueue interface. Concurrency The fork/join framework, which is based on the ForkJoinPool class, is an implementation of the Executor interface. It is designed to efficiently run a large number of tasks using a pool of worker threads. A work-stealing technique is used to keep all the worker threads busy, to take full advantage of multiple processors. See Fork/Join in The Java Tutorials. The directory /sample/forkjoin/ contains samples that demonstrate the fork/join framework. The ThreadLocalRandom class eliminates contention among threads using pseudo-random numbers; see Concurrent Random Numbers. The Phaser class is a new synchronization barrier, similar to CyclicBarrier. Rich Internet Applications (RIA) and Deployment The window of a dragged applet can be decorated with a default or custom title; see Requesting and Customizing Applet Decoration in Draggable Applets. The following enhancements have been made to the syntax of JNLP files; see JNLP File Syntax: The os attribute in the information and resources elements can now contain specific versions of Windows, such as Windows Vista or Windows 7. Applications can use the install attribute in the shortcut element to specify their desire to be installed. Installed applications are not removed when the Java Web Start cache is cleared, but can be explicitly removed using the Java Control Panel. Java Web Start applications can be deployed without specifying the codebase attribute; see Deploying Without Codebase A JNLP file can be embedded into an HTML page; see Embedding JNLP File in Applet Tag. You can check the status variable of the applet while it is loading to determine if the applet is ready to handle requests from JavaScript code; see Handling Initialization Status With Event Handlers. You now have control of the window decoration style and title of an applet launched from a shortcut or dragged out of the browser; see Requesting and Customizing Applet Decoration in Developing Draggable Applets. Java 2D A new XRender-based Java 2D rendering pipeline is supported for modern X11-based desktops, offering improved graphics performance; see the xrender flag in System Properties for Java 2D Technology. The JDK now enumerates and displays installed OpenType/CFF fonts through methods such as GraphicsEnvironment.getAvailableFontFamilyNames; these fonts are also recognized by the Font.createFont method. See Selecting a Font. The TextLayout class supports Tibetan script. libfontconfig, a font configuration API, is used to select fonts to use for the logical fonts for some implementations of Linux; see Fontconfig. Java XML This release contains Java API for XML Processing (JAXP) 1.4.5, supports Java Architecture for XML Binding (JAXB) 2.2.3, and supports Java API for XML Web Services (JAX-WS) 2.2.4. Internationalization Unicode 6.0.0 is supported; see Unicode in The Java Tutorials. The directory /demo/jfc/Font2DTest/ contains samples that demonstrate Java support for Unicode 6.0. Java SE 7 can accommodate new currencies that are identified by their ISO 4217 codes; see the Currency class. java.lang Package Potential deadlocks were eliminated for multithreaded, non-hierarchically delegating custom class loaders; see Multithreaded Custom Class Loaders in Java SE 7. Java Programming Language The following enhancements have been added to the Java language: Binary Literals Underscores in Numeric Literals Strings in switch Statements Type Inference for Generic Instance Creation Improved Compiler Warnings and Errors When Using Non-Reifiable Formal Parameters with Varargs Methods The try-with-resources Statement Catching Multiple Exception Types and Rethrowing Exceptions with Improved Type Checking Java Virtual Machine Java Virtual Machine Support for Non-Java Languages: Java SE 7 introduces a new JVM instruction that simplifies the implementation of dynamically typed programming languages on the JVM. Garbage-First Collector is a server-style garbage collector that replaces the Concurrent Mark-Sweep Collector (CMS). Java HotSpot Virtual Machine Performance Enhancements JDBC 4.1 JDBC 4.1 introduces the following features: The ability to use a try-with-resources statement to automatically close resources of type Connection, ResultSet, and Statement; see Closing Connections in Processing SQL Statements. RowSet 1.1: The introduction of the RowSetFactory interface and the RowSetProvider class, which enable you to create all types of row sets supported by your JDBC driver; see Using the RowSetFactory Interface in Using JdbcRowSet Objects.

81,091

社区成员

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

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