java电子词典笔记代码 java英汉互译电子词典完整版含数据库( 二 )


}
}
/**
* 检测结果集是否为空
* @return true为存在记录
*/
public boolean next() {
boolean b = false;
try {
if (resultSet.next()) b = true;
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
/**
* 获得结果集中当前行columnLabel的记录
* @param columnLabel 当前行要查询的列名.
* @return 查询的列值
*/
public String getValue(String columnLabel) {
String value = https://www.04ip.com/post/null;
try {
if (resultSet != null) value = https://www.04ip.com/post/resultSet.getString(columnLabel);
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
/**
* 获得结果集中当前行columnIndex的记录
* @param columnIndex 当前行查询的列索引,第一列为1,第二列为2...
* @return 查询的列值
*/
public String getValue(int columnIndex) {
String value = https://www.04ip.com/post/null;
try {
if (resultSet != null) value = https://www.04ip.com/post/resultSet.getString(columnIndex);
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
/**
* 关闭连接对象
*/
public void closeConnection() {
try {
if (connection != null) connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 关闭数据库对象
*/
public void closeStatement() {
try {
if (statement != null) statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 关闭结果集
*/
public void closeResultSet() {
try {
if (resultSet != null) resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 关闭数据连接对象,数据库对象和数据结果集对象 。
*/
public void closeAll() {
closeResultSet();
closeStatement();
closeConnection();
}
/**
* 测试该类函数 。
* @param args
*/
public static void main(String[] args) {
Access db = new Access();
if (db.createConnection()) {
System.out.println("测试数据库连接成功.");
}
db.closeAll();
}
}
求一个用Java编写的简易笔记本代码 。跪求import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class MyNotepad implements ActionListener
{
private JFrame frame=new JFrame("新记事本");
private JTextArea jta=new JTextArea();
private String result="";
private boolean flag=true;
private File f;
private JButton jb=new JButton("开始");
private JTextField jtf=new JTextField(15);
private JTextField jt=new JTextField(15);
private JButton jbt=new JButton("替换为");
private JButton jba=new JButton("全部替换");
private Icon ic=new ImageIcon("D:\\java课堂笔记\\GUI\\11.gif");
private String value;
private int start=0;
private JFrame jf=new JFrame("查找");
private JFrame jfc=new JFrame("替换");
@Override
public void actionPerformed(ActionEvent e)
{
String comm=e.getActionCommand();
if("新建".equals(comm))
{
if(!(frame.getTitle().equals("新记事本")))
{
if(!flag)
{
write();
newNew();
}
else
{
JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");
int returnVal = jfc.showDialog(null,"保存为");
if(returnVal == JFileChooser.APPROVE_OPTION)
{//选择文件后再执行下面java电子词典笔记代码的语句,保证了程序java电子词典笔记代码的健壮性
f=jfc.getSelectedFile();