Java英汉电子字典课程设计源代码
Java编程语言外文翻译、英汉互译、中英对照

文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。
外文翻译原文及译文学院计算机学院专业计算机科学与技术班级学号姓名指导教师负责教师Java(programming language)Java is a general-purpose, concurrent, class-based, object-oriented computer program- -ming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to byte code (class file) that can run on any Java virtual machine(JVM) regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users. Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1991 and first released in 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath.Java is a set of several computer software products and specifications from Sun Microsystems (which has since merged with Oracle Corporation), that together provide a system for developing application software and deploying it in across-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones on the low end, to enterprise servers and supercomputers on the high end. While less common, Java appletsare sometimes used to provide improved and secure functions while browsing the World Wide Web on desktop computers.Writing in the Java programming language is the primary way to produce code that will be deployed as Java bytecode. There are, however, byte code compilers available forother languages such as Ada, JavaScript, Python, and Ruby. Several new languages have been designed to run natively on the Java Virtual Machine (JVM), such as Scala, Clojure and Groovy.Java syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective-C. Java eliminates certain low-level constructs such as pointers and has a very simple memory model where every object is allocated on the heap and all variables of object types are references. Memory management is handled through integrated automatic garbage collection performed by the JVM.An edition of the Java platform is the name for a bundle of related programs from Sun that allow for developing and running programs written in the Java programming language. The platform is not specific to any one processor or operating system, but rather an execution engine (called a virtual machine) and a compiler with a set of libraries that are implemented for various hardware and operating systems so that Java programs can run identically on all of them. The Java platform consists of several programs, each of which provides a portion of its overall capabilities. For example, the Java compiler, which converts Java source code into Java byte code (an intermediate language for the JVM), is provided as part of the Java Development Kit (JDK). The Java Runtime Environment(JRE), complementing the JVM with a just-in-time (JIT) compiler, converts intermediate byte code into native machine code on the fly. An extensive set of libraries are also part of the Java platform.The essential components in the platform are the Java language compiler, the libraries, and the runtime environment in which Java intermediate byte code "executes" according to the rules laid out in the virtual machine specification.In most modern operating systems (OSs), a large body of reusable code is provided to simplify the programmer's job. This code is typically provided as a set of dynamically loadable libraries that applications can call at runtime. Because the Java platform is not dependent on any specific operating system, applications cannot rely on any of the pre-existing OS libraries. Instead, the Java platform provides a comprehensive set of its own standard class libraries containing much of the same reusable functions commonly found in modern operating systems. Most of the system library is also written in Java. For instance, Swing library paints the user interface and handles the events itself, eliminatingmany subtle differences between how different platforms handle even similar components.The Java class libraries serve three purposes within the Java platform. First, like other standard code libraries, the Java libraries provide the programmer a well-known set of functions to perform common tasks, such as maintaining lists of items or performing complex string parsing. Second, the class libraries provide an abstract interface to tasks that would normally depend heavily on the hardware and operating system. Tasks such as network access and file access are often heavily intertwined with the distinctive implementations of each platform. The and java.io libraries implement an abstraction layer in native OS code, then provide a standard interface for the Java applications to perform those tasks. Finally, when some underlying platform does not support all of the features a Java application expects, the class libraries work to gracefully handle the absent components, either by emulation to provide a substitute, or at least by providing a consistent way to check for the presence of a specific feature.The success of Java and its write once, run anywhere concept has led to other similar efforts, notably the .NET Framework, appearing since 2002, which incorporates many of the successful aspects of Java. .NET in its complete form (Microsoft's implementation) is currently only fully available on Windows platforms, whereas Java is fully available on many platforms. .NET was built from the ground-up to support multiple programming languages, while the Java platform was initially built to support only the Java language, although many other languages have been made for JVM since..NET includes a Java-like language called Visual J# (formerly named J++) that is incompatible with the Java specification, and the associated class library mostly dates to the old JDK 1.1 version of the language. For these reasons, it is more a transitional language to switch from Java to the .NET platform, than a first class .NET language. Visual J# was discontinued with the release of Microsoft Visual Studio 2008. The existing version shipping with Visual Studio 2005will be supported until 2015 as per the product life-cycle strategy.In June and July 1994, after three days of brainstorming with John Gage, the Director of Science for Sun, Gosling, Joy, Naughton, Wayne Rosing, and Eric Schmidt, the team re-targeted the platform for the World Wide Web. They felt that with the advent of graphical web browsers like Mosaic, the Internet was on its way to evolving into the samehighly interactive medium that they had envisioned for cable TV. As a prototype, Naughton wrote a small browser, Web Runner (named after the movie Blade Runner), later renamed Hot Java.That year, the language was renamed Java after a trademark search revealed that Oak was used by Oak Technology. Although Java 1.0a was available for download in 1994, the first public release of Java was 1.0a2 with the Hot Java browser on May 23, 1995, announced by Gage at the Sun World conference. His announcement was accompanied by a surprise announcement by Marc Andreessen, Executive Vice President of Netscape Communications Corporation, that Netscape browsers would be including Java support. On January 9, 1996, the Java Soft group was formed by Sun Microsystems to develop the technology.Java编程语言Java是一种通用的,并发的,基于类的并且是面向对象的计算机编程语言,它是为实现尽可能地减少执行的依赖关系而特别设计的。
java课程设计英汉双语词典

java课程设计英汉双语词典一、教学目标本课程的教学目标是使学生掌握Java编程的基本技能,能够运用Java语言开发简单的英汉双语词典应用程序。
具体目标如下:1.知识目标:–理解Java语言的基本语法和结构。
–掌握面向对象编程的基本概念和方法。
–了解英汉双语词典的基本结构和实现方式。
2.技能目标:–能够使用Java语言编写简单的程序。
–能够运用面向对象编程的方法设计程序。
–能够独立完成英汉双语词典的编程实现。
3.情感态度价值观目标:–培养学生的编程兴趣和自信心。
–培养学生解决问题的能力和团队合作精神。
–培养学生对编程技术和计算机科学的热爱。
二、教学内容本课程的教学内容主要包括Java语言的基本语法和结构、面向对象编程的方法、英汉双语词典的基本结构和实现方式。
具体教学大纲如下:1.Java语言的基本语法和结构:–数据类型、变量和运算符。
–控制结构和函数。
–数组和字符串的操作。
2.面向对象编程的方法:–类的定义和创建。
–属性和方法的封装。
–继承和多态的应用。
3.英汉双语词典的基本结构和实现方式:–词典的数据结构和存储方式。
–词条的添加、删除和查找操作。
–词典的界面设计和用户交互。
三、教学方法本课程的教学方法主要包括讲授法、案例分析法和实验法。
具体方法如下:1.讲授法:通过讲解和演示的方式,向学生传授Java语言的基本语法和结构、面向对象编程的方法以及英汉双语词典的基本结构和实现方式。
2.案例分析法:通过分析具体的英汉双语词典案例,让学生理解和掌握词典的编程实现方法。
3.实验法:通过实验和实践的方式,让学生动手编写Java程序,培养学生的编程技能和解决问题的能力。
四、教学资源本课程的教学资源包括教材、参考书、多媒体资料和实验设备。
具体资源如下:1.教材:选用《Java编程基础》作为主教材,介绍Java语言的基本语法和结构、面向对象编程的方法。
2.参考书:推荐《Java核心技术》等参考书,供学生深入学习和参考。
java课程设计范例

java课程设计范例一、教学目标本节课的教学目标是让学习者掌握Java编程语言的基本语法、流程控制语句以及简单的数据结构。
通过本节课的学习,学生将能够:1.理解Java语言的基本语法,包括数据类型、变量、运算符等。
2.掌握Java的流程控制语句,包括条件语句、循环语句等。
3.熟悉Java的基本数据结构,包括数组、链表、栈和队列等。
4.能够运用Java语言编写简单的程序,实现基本的算法。
二、教学内容本节课的教学内容主要包括以下几个部分:1.Java语言的基本语法:介绍Java语言的数据类型、变量、运算符等基本语法规则。
2.流程控制语句:讲解条件语句、循环语句等流程控制语句的用法和意义。
3.基本数据结构:介绍Java中的数组、链表、栈和队列等基本数据结构及其应用。
4.编程实践:通过编写简单的Java程序,使学生能够将所学知识应用于实际问题的解决中。
三、教学方法为了达到本节课的教学目标,我们将采用以下几种教学方法:1.讲授法:通过讲解Java语言的基本语法、流程控制语句和基本数据结构,使学生能够理解和掌握相关知识。
2.案例分析法:通过分析具体的Java程序案例,使学生能够了解和掌握Java语言的应用方法。
3.实验法:让学生通过编写和运行Java程序,亲自体验和掌握Java语言的语法和编程技巧。
四、教学资源为了支持本节课的教学内容和教学方法的实施,我们将准备以下教学资源:1.教材:《Java编程语言》等与本节课内容相关的教材和参考书。
2.多媒体资料:通过PPT等多媒体形式,生动、形象地展示Java语言的基本语法、流程控制语句和基本数据结构。
3.实验设备:为学生提供必要的计算机和网络环境,让他们能够编写和运行Java程序。
五、教学评估为了全面、客观地评估学生的学习成果,我们将采用以下几种评估方式:1.平时表现:通过观察学生在课堂上的参与程度、提问回答等情况,评估他们的学习态度和理解能力。
2.作业:布置与课程内容相关的作业,评估学生对知识点的掌握程度和编程能力。
javaweb课程设计源码参考

javaweb课程设计源码参考JavaWeb课程设计源码参考一、引言JavaWeb课程设计是计算机科学与技术专业的一门重要课程。
在这门课程中,学生需要掌握JavaWeb开发的基本知识和技能,并通过实践来加深对所学知识的理解。
本文将为大家提供一些JavaWeb课程设计的源码参考,帮助学生更好地完成课程设计。
二、登录页面登录页面是JavaWeb课程设计中常见的一个功能模块。
下面是一个简单的登录页面源码参考:```java<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %><!DOCTYPE html><html><head><title>登录页面</title></head><body><form action="login" method="post"><label for="username">用户名:</label><input type="text" id="username" name="username"><br><br><label for="password">密码:</label><input type="password" id="password" name="password"><br><br><input type="submit" value="登录"></form></body></html>```三、登录功能实现登录功能是JavaWeb课程设计中的核心功能之一。
java课程设计.docx

java课程设计.docx一、教学目标本章节的教学目标分为三个部分:知识目标、技能目标和情感态度价值观目标。
知识目标:通过本章节的学习,学生需要掌握Java编程的基本语法、数据类型、控制结构、函数等基础知识。
技能目标:学生能够运用Java编程解决简单的实际问题,具备基本的编程能力。
情感态度价值观目标:培养学生对编程的兴趣和热情,提高学生解决问题的能力。
二、教学内容本章节的教学内容主要包括Java编程的基本语法、数据类型、控制结构、函数等基础知识。
具体包括以下内容:1.Java编程的基本语法和规则2.数据类型:整数类型、浮点类型、字符类型、布尔类型等3.控制结构:顺序结构、选择结构、循环结构等4.函数:定义和调用函数,传递参数,返回值等5.常用内置函数:数学函数、字符串函数等三、教学方法本章节的教学方法采用讲授法、案例分析法和实验法相结合的方式进行。
1.讲授法:通过讲解和示范,让学生掌握Java编程的基本语法和规则,以及数据类型、控制结构、函数等基础知识。
2.案例分析法:通过分析实际案例,让学生学会如何运用Java编程解决实际问题。
3.实验法:通过上机实验,让学生动手实践,巩固所学知识,提高编程能力。
四、教学资源本章节的教学资源包括教材、参考书、多媒体资料和实验设备等。
1.教材:选用权威、实用的Java编程教材,如《Java核心技术》等。
2.参考书:提供相关的Java编程参考书籍,如《Java编程思想》等。
3.多媒体资料:制作精美的PPT课件,提供Java编程相关的视频教程等。
4.实验设备:确保学生有足够的计算机设备进行上机实验。
五、教学评估本章节的教学评估主要包括平时表现、作业和考试三个部分,以全面、客观、公正地评估学生的学习成果。
1.平时表现:通过课堂参与、提问、讨论等方式,评估学生在课堂上的学习态度和表现。
2.作业:布置适量的作业,评估学生的知识掌握和运用能力。
3.考试:进行定期的考试,评估学生对章节知识的全面理解和掌握程度。
编程基础:Dictionaries and Sets

字典与集合 什么是字典(Dictionary)? v 一系列“键-值(key-value)”对 v 通过“键”查找对应的“值” v 类似纸质字典,通过单词索引表找到其相应的定义 n⏹ C++: m ap、Java: H ashTable o r H ashMap v 例如:电话本 姓名(键) 电话号码(值) John 86411234 Bob 86419453 Mike 86412387 …… …… 字典的使用 v 创建字典 n⏹ 使用 { } 创建字典 n⏹ 使用 : 指明 键:值 对 n⏹ m y_dict = {'John': 86411234, 'Bob': 86419453,'Mike': 86412387} n⏹ 键必须是不可变的且不重复,值可以是任意类型 v 访问字典 n⏹ 使用 [ ] 运算符,键作为索引 n⏹ print m y_dict['Bob'] n⏹ print m y_dict['Tom'] #WRONG! n⏹ 增加一个新的对 n⏹ my_dict['Tom'] = 86417639 字典运算符和方法 v len(my_dict) n⏹ 字典中键-值对的数量 v key i n m y_dict n⏹ 快速判断 k ey 是否为字典中的键:O(1) n⏹ 等价于 m y_dict.has_key(key) v for k ey i n m y_dict: n⏹ 枚举字典中的键,注:键是无序的 v 更多的方法 n⏹ my_dict.items() – 全部的键-值对 n⏹ my_dict.keys() – 全部的键 n⏹ my_dict.values() – 全部的值 n⏹ my_dict.clear() – 清空字典 v 读取一个字符串,计算每个字母出现的个数 v 方案一 n⏹ 生成 26 个变量,代表每个字母出现的个数 v 方案二 n⏹ 生成具有 26 个元素的列表,将每个字母转化为相应的索引值,如 a è→ 0,b è→ 1,… v 方案三 n⏹ 生成一个字典,字母做键,对应出现的次数做值 v 读取小说"emma.txt",打印前 10 个最常见单词 n⏹ 是否还能直观的将每个单词转化为相应的数字? 示例:翻转字典 v 生成一个新字典,其键为原字典的值,值为原字典的键 n⏹ 同一个值,可能对应多个键,需要用列表存储 集合(Set) v 集合 n⏹ 无序不重复元素(键)集 n⏹ 和字典类似,但是无“值” v 创建 n⏹ x = s et() n⏹ x = {key1, k ey2, …} v 添加和删除 n⏹ x.add('body') n⏹ x.remove('body') v 集合的运算符 运算符 含义 - 差集 & 交集 | 并集 != 不等于 == 等于 in 成员 for k ey i n s et 枚举 v 我爱北京天安门。
java字典表中编码生成规则

java字典表中编码生成规则在Java中,字典表编码生成规则通常由业务需求和系统设计决定。
字典表(或称为数据字典、代码表)中的编码是用来标识不同类型或类别的数据项的短字符串或数字。
以下是一些可能的字典表编码生成规则的示例:1. 顺序编号:按照顺序递增的数字,例如,以1开始,依次递增,可以是整数或字符串形式。
```javapublic class CodeGenerator {private static int counter = 0;public static String generateCode() {counter++;return String.format("CODE%04d", counter);}}```2. 前缀+ 日期+ 序号:结合当前日期和顺序递增的数字,可以确保唯一性。
```javaimport java.text.SimpleDateFormat;import java.util.Date;public class CodeGenerator {private static int counter = 0;public static String generateCode() {counter++;SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");String datePart = dateFormat.format(new Date());return "CODE" + datePart + String.format("%03d", counter);}}```3. 使用UUID:使用UUID(Universally Unique Identifier)来生成唯一的编码。
```javaimport java.util.UUID;public class CodeGenerator {public static String generateCode() {UUID uuid = UUID.randomUUID();return "CODE_" + uuid.toString().replace("-", "").substring(0, 10);}}```4. 基于业务规则的编码:根据业务规则构建编码,例如,商品分类编号可以由商品类型和品牌组合而成。
电子英汉词典课程设计

课程设计报告2020~2021学年第一学期课程可视化程序设计课程设计题目电子英汉词典院(系): 计算机学院(软件学院)姓名学号专业班级2019级计科2班指导教师2020年 12 月 31 日目录第一章绪论 (1)1.1 课题背景及意义 (1)1.2 开发环境及技术 (2)第二章概要设计 (2)2.1页面设计 (2)2.1.1 系统首页设计 (2)2.1.2 注册界面设计 (3)2.2 数据库设计 (4)2.2.1 数据库概念结构设计 (4)2 2.2数据库逻辑结构设计 (6)2.2.3 数据库物理结构设计 (7)第三章功能详细设计与实现 (8)3.1实现的全部功能表 (9)3.2功能1 (10)3.3功能2 (11)3.4功能3 (12)3.5功能4 (13)3.6功能5 (14)3.7功能6 (15)3.8功能7 (16)第四章检测及评价 (17)第五章结语 (23)第一章绪论当今时代是信息化时代,而信息的数字化也越来越被人们所重视,所以,数字化技术的重要性也逐渐体现了出来,主要体现在以下几个方面: 数字化是数字计算机的基础,数字化是软件技术的基础,是智能技术的基础,数字化是信息社会的技术基础,数字化是信息社会的经济基础。
词典作为一种为大众服务的工具书,已经渐渐退居二线了,进而出现了另一种查找方式更加简便,更加精确,词汇量更加丰富而且随身携带更加方便的工具,那就是电子英汉词典,应该说这是一个新旧交替的过程,电子英汉词典取代传统词典只是时间的问题。
所以说电子词典的发展前景是明朗的,电子英汉词典生产厂家也如同雨后春笋般崛起了。
电子英汉词典是一种将传统的印刷词典转成数码方式、进行快速查询的数字学习工具。
电子英汉词典以轻便易携、查询快捷、功能丰富等特点,成为21世纪学生学习生活、社会人士移动办公的掌上利器。
它不仅可实现英译汉、汉译英的基本翻译功能,还可以让用户根据自己的需要添加、修改、删除词库,形成自己的词库。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
用户需求分析:英汉词典作为一个常用的学习工具,是我们经常要使用的。
该系统能完成一个简单的电子词的功能。
该系统主要用于实现英汉互译的功能,系统拥有自己的数据库。
1.英译汉功能:我们可以先选择让系统进行英译汉功能,然后在查找框中输入想要查询的英文单词,系统将自动在数据库中查找匹配记录并给出相对应的汉语意思。
2.汉译英功能:我们可以在系统中选择汉译英功能,然后在查找框中输入想要查询的汉语意思,系统将自动在数据库中查找匹配记录并给出相对应的英文单词3.词汇的添加功能:用户可以添加词库没有的单词及其解释。
添加成功后该单词将在次库保存,以便下次查询。
4.词汇的修改功能;用户可以实现对词库中已有单词及其解释的修改。
修改后的结果将保存在词库中。
5.词汇的删除功能;用户可自行删除词库中已有的单词,同时次单词的解释也将被一同删除。
6.其他功能:此外,系统还具有帮助和关于等功能,用来辅助用户更方便简洁的使用电子词典。
package dianzicidian;import java.awt.*;import .*;import java.sql.*;import java.awt.event.*;import javax.swing.JOptionPane;import java.io.*;import sun.audio.*;class dzcd extends Frame implements ActionListener{MenuBar menubar=new MenuBar();//菜单Menu fileMenu,editMenu,helpMenu;MenuItem fileenglish,filechinese,exit,editAdd,editmod,editDel;TextField inputtext;TextArea txt;Label label1,label2;Button btn1,btnsound;Panel p,p1,p2,p3;dzcd(){super("电子词典");setBounds(200,300,350,400);setMenuBar(menubar);fileMenu=new Menu("文件");editMenu=new Menu("编辑");helpMenu=new Menu("帮助");fileenglish=new MenuItem("英汉词典");filechinese=new MenuItem("汉英词典");exit=new MenuItem("退出");editAdd=new MenuItem("添加词汇");editmod=new MenuItem("修改词汇");editDel=new MenuItem("删除词汇");menubar.add(fileMenu);menubar.add(editMenu);menubar.add(helpMenu);fileMenu.add(fileenglish);fileMenu.add(filechinese);fileMenu.addSeparator();fileMenu.add(exit);editMenu.add(editAdd);editMenu.add(editmod);editMenu.add(editDel);inputtext=new TextField("",10);txt=new TextArea(10,10);label1=new Label("输入要查询的英语单词:");label2=new Label("查询结果:");btn1=new Button("查询");btnsound=new Button("发音");p=new Panel(new BorderLayout());p2=new Panel(new FlowLayout(FlowLayout.LEFT,5,0));p2.add(label1);p2.add(inputtext);p2.add(btn1);p2.add(btnsound);add(p2,"North");p.add(label2,"North");p.add(txt,"Center");add(p,"Center");setVisible(true);setResizable(false);validate();fileenglish.addActionListener(this);filechinese.addActionListener(this);exit.addActionListener(this);editAdd.addActionListener(this);editmod.addActionListener(this);editDel.addActionListener(this);btn1.addActionListener(this);btnsound.addActionListener(this);addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});}public void actionPerformed(ActionEvent e){if(e.getSource()==fileenglish)//英汉(外观变化){label1.setText("输入要查询的英语单词:");label2.setText("查询结果:");txt.setText("");btn1.setLabel("查询");btnsound.setVisible(true);}else if(e.getSource()==filechinese)//汉英(外观变化){label1.setText("输入要查询的汉语词语:");label2.setText("查询结果:");txt.setText("");btn1.setLabel("查询");btnsound.setVisible(true);}else if(e.getSource()==exit)//退出{System.exit(0);}else if(e.getSource()==btn1){if(btn1.getLabel().equals("查询"))//实现查询功能(包括英汉或汉英){txt.setText(null);try{Listwords();}catch(SQLException ee){}}else if(btn1.getLabel().equals("提交"))//实现添加功能{try{addwords();}catch(SQLException ee){}}else if(btn1.getLabel().equals("更新"))//实现修改功能{try{modwords();}catch(SQLException ee){}}else if(btn1.getLabel().equals("删除"))//实现删除功能{try{delwords();}catch(SQLException ee){}}}else if(e.getSource()==editAdd)//添加(外观变化){label1.setText("输入新单词:");label2.setText("输入中文解释:");btn1.setLabel("提交");btnsound.setVisible(false);}else if(e.getSource()==editmod)//修改(外观变化){label1.setText("输入要修改的单词:");label2.setText("输入更新后的解释:");btn1.setLabel("更新");btnsound.setVisible(false);}else if(e.getSource()==editDel)//删除(外观变化){label1.setText("输入要删除的单词:");label2.setText("");btn1.setLabel("删除");btnsound.setVisible(false);}else if(e.getSource()==btnsound)//发音{if(inputtext.getText()!=null){try{InputStream is=getClass().getResource("sound//"+inputtext.getText().trim()+".wav").openStream();AudioPlayer.player.start(is);}catch(IOException e1){}}}}public void Listwords() throws SQLException//查询实现过程{Stringame,ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:words","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");cname=rs.getString("汉语");if(ename.equals(inputtext.getText())&&label1.getText().equals("输入要查询的英语单词:")){txt.append(cname);break;}else if(cname.equals(inputtext.getText())&&label1.getText().equals("输入要查询的汉语词语:")){txt.append(ename);break;}}Ex1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,"查无此单词!","警告",JOptionPane.WARNING_MESSAGE);}}public void addwords() throws SQLException//向数据库添加新词汇{Stringame,ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:words","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");cname=rs.getString("汉语");if(ename.equals(inputtext.getText())&&cname.equals(txt.getText())){JOptionPane.showMessageDialog(this,"此词汇已存在!","警告",JOptionPane.WARNING_MESSAGE);break;}}if(boo==false){Ex1Stmt.executeUpdate("INSERT INTO words (英语,汉语) VALUES ('"+inputtext.getText().trim()+"','"+txt.getText().trim()+"')");JOptionPane.showMessageDialog(this,"添加成功!","恭喜",JOptionPane.WARNING_MESSAGE);}Ex1Con.close();}public void modwords() throws SQLException//修改词库中记录{String ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:words","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");if(ename.equals(inputtext.getText())){Ex1Stmt.executeUpdate("UPDATE words SET 汉语='"+txt.getText().trim()+"' WHERE 英语='"+inputtext.getText().trim()+"'");JOptionPane.showMessageDialog(this,"记录修改成功!","恭喜",JOptionPane.WARNING_MESSAGE);break;}}Ex1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,"不存在此单词!","警告",JOptionPane.WARNING_MESSAGE);}}public void delwords() throws SQLException//删除词库中记录{SuppressWarnings("unused")Stringame,ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}ConnectionEx1Con=DriverManager.getConnection("jdbc:odbc:wordskechengsheji","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");cname=rs.getString("汉语");if(ename.equals(inputtext.getText())){Ex1Stmt.executeUpdate("DELETE FROM words WHERE 英语='"+inputtext.getText().trim()+"'");JOptionPane.showMessageDialog(this,"成功删除记录!","恭喜",JOptionPane.WARNING_MESSAGE);break;}}Ex1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,"不存在此单词!","警告",JOptionPane.WARNING_MESSAGE);}}public static void main(String args[]){new dzcd();}}。