package cn.sist.database.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.File;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import cn.sist.database.work.OutputDao;
import cn.sist.jdbc.DBProperty;
import cn.sist.jdbc.DataBaseFactory;
import cn.sist.util.view.FrameUtil;
public class MainView extends JFrame {
/**
*
*/
private static final long serialVersionUID = 8631815254135444484L;
private JFileChooser jfc = new JFileChooser();
private OutputDao dao = new OutputDao();
private DBProperty dbp;
private File path;
private JLabel db_type_jl;
private JLabel db_port_jl;
private JLabel db_addr_jl;
private JLabel db_name_jl;
private JLabel out_path_jl;
private JLabel db_user_jl;
private JLabel db_pwd_jl;
private JLabel status_jl;
private JPanel main_pl;
private JPanel option_pl;
private JPanel btn_pl;
private JPanel status_pl;
private JComboBox db_type_jcb;
private JTextField db_port_jtf;
private JTextField db_addr_jtf;
private JTextField db_name_jtf;
private JTextField out_path_jtf;
private JTextField db_user_jtf;
private JPasswordField db_pwd_jtf;
private JButton submit_btn;
private JButton reset_btn;
protected JLabel getDb_name_jl() {
if (db_name_jl == null) {
db_name_jl = new JLabel("数据库名称:");
}
return db_name_jl;
}
protected JLabel getDb_port_jl() {
if (db_port_jl == null) {
db_port_jl = new JLabel("连接端口:");
}
return db_port_jl;
}
protected JLabel getDb_pwd_jl() {
if (db_pwd_jl == null) {
db_pwd_jl = new JLabel("密码:");
}
return db_pwd_jl;
}
protected JLabel getDb_type_jl() {
if (db_type_jl == null) {
db_type_jl = new JLabel("数据库类型:");
}
return db_type_jl;
}
protected JLabel getDb_user_jl() {
if (db_user_jl == null) {
db_user_jl = new JLabel("用户名:");
}
return db_user_jl;
}
protected JLabel getOut_path_jl() {
if (out_path_jl == null) {
out_path_jl = new JLabel("输出路径:");
}
return out_path_jl;
}
public JLabel getStatus_jl() {
if (status_jl == null) {
status_jl = new JLabel("完毕");
status_jl.setToolTipText("状态栏");
}
return status_jl;
}
protected JLabel getDb_addr_jl() {
if (db_addr_jl == null) {
db_addr_jl = new JLabel("连接地址:");
}
return db_addr_jl;
}
protected JTextField getDb_name_jtf() {
if (db_name_jtf == null) {
db_name_jtf = new JTextField(20);
db_name_jtf.setToolTipText("数据库名称");
}
return db_name_jtf;
}
protected JTextField getDb_port_jtf() {
if (db_port_jtf == null) {
db_port_jtf = new JTextField("1433", 20);
db_port_jtf.setToolTipText("TCP连接端口号(默认1433)");
}
return db_port_jtf;
}
protected JTextField getDb_addr_jtf() {
if (db_addr_jtf == null) {
db_addr_jtf = new JTextField("localhost", 20);
db_addr_jtf.setToolTipText("数据库连接地址(localhost||localhost\\\\实例名)");
}
return db_addr_jtf;
}
protected JTextField getDb_pwd_jtf() {
if (db_pwd_jtf == null) {
db_pwd_jtf = new JPasswordField(20);
db_pwd_jtf.setToolTipText("连接密码");
}
return db_pwd_jtf;
}
protected JComboBox getDb_type_jcb() {
if (db_type_jcb == null) {
String[] data = {DataBaseFactory.SQLSERVER,DataBaseFactory.SQL2005,DataBaseFactory.ORACLE,DataBaseFactory.MYSQL};
db_type_jcb = new JComboBox(data);
db_type_jcb.setSelectedIndex(0);
}
return db_type_jcb;
}
protected JTextField getDb_user_jtf() {
if (db_user_jtf == null) {
db_user_jtf = new JTextField("sa", 20);
db_user_jtf.setToolTipText("用户名(默认sa)");
}
return db_user_jtf;
}
/**
*
* @return JPanel 主面板
*/
protected JPanel getMain_pl() {
if (main_pl == null) {
main_pl = new JPanel();
main_pl.setLayout(new BorderLayout());
main_pl.add(getOption_pl(), BorderLayout.CENTER);
main_pl.add(new JPanel(), BorderLayout.WEST);
main_pl.add(new JPanel(), BorderLayout.EAST);
main_pl.add(getStatus_pl(), BorderLayout.NORTH);
main_pl.add(getBtn_pl(), BorderLayout.SOUTH);
}
return main_pl;
}
/**
* @return the option_pl 参数面板
*/
protected JPanel getOption_pl() {
if (option_pl == null) {
option_pl = new JPanel(new GridLayout(7, 2));
EtchedBorder eborder = new EtchedBorder(EtchedBorder.RAISED,
new Color(0, 128, 255), new Color(192, 192, 192));
option_pl.setBorder(eborder);
// option_pl.setSize(new Dimension(200,350));
option_pl.add(getDb_type_jl());
option_pl.add(getDb_type_jcb());
option_pl.add(getDb_port_jl());
option_pl.add(getDb_port_jtf());
option_pl.add(getDb_addr_jl());
option_pl.add(getDb_addr_jtf());
option_pl.add(getDb_name_jl());
option_pl.add(getDb_name_jtf());
option_pl.add(getOut_path_jl());
option_pl.add(getOut_path_jtf());
option_pl.add(getDb_user_jl());
option_pl.add(getDb_user_jtf());
option_pl.add(getDb_pwd_jl());
option_pl.add(getDb_pwd_jtf());
}
return option_pl;
}
/**
*
* @return JPanel 按钮面板
*/
protected JPanel getBtn_pl() {
if (btn_pl == null) {
btn_pl = new JPanel(new FlowLayout(FlowLayout.CENTER));
btn_pl.add(getSubmit_btn());
btn_pl.add(new JLabel(" "));
btn_pl.add(getReset_btn());
}
return btn_pl;
}
public JPanel getStatus_pl() {
if (status_pl == null) {
status_pl = new JPanel(new FlowLayout());
status_pl.add(getStatus_jl());
}
return status_pl;
}
protected JTextField getOut_path_jtf() {
if (out_path_jtf == null) {
out_path_jtf = new JTextField(20);
out_path_jtf.setEditable(false);
out_path_jtf.setToolTipText("输出路径(文件夹)");
out_path_jtf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = jfc.showOpenDialog(getMain_pl());
if (result == JFileChooser.APPROVE_OPTION) {
out_path_jtf.setText(jfc.getSelectedFile()
.getAbsolutePath());
}
}
});
out_path_jtf.addMouseListener(new MouseListenerAdapter() {
public void mouseClicked(MouseEvent e) {
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int result = jfc.showSaveDialog(getMain_pl());
if (result == JFileChooser.APPROVE_OPTION) {
out_path_jtf.setText(jfc.getSelectedFile()
.getAbsolutePath());
}
}
});
}
return out_path_jtf;
}
protected JButton getReset_btn() {
if (reset_btn == null) {
reset_btn = new JButton("重置");
reset_btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
reset();
}
});
}
return reset_btn;
}
protected JButton getSubmit_btn() {
if (submit_btn == null) {
submit_btn = new JButton("确定");
submit_btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
if (isValidate()) {
dbp = new DBProperty();
dbp.setType(getDb_type_jcb().getSelectedItem()
.toString().trim());
dbp.setName(getDb_name_jtf().getText().trim());
dbp.setPort(getDb_port_jtf().getText().trim());
dbp.setAddr(getDb_addr_jtf().getText().trim());
dbp.setUser(getDb_user_jtf().getText().trim());
dbp.setPwd(getDb_pwd_jtf().getText().trim());
path = new File(getOut_path
没有合适的资源?快使用搜索试试~ 我知道了~
Java数据库导出程序2.0版
共48个文件
class:19个
java:10个
properties:4个
需积分: 10 43 下载量 120 浏览量
2009-12-28
21:37:11
上传
评论
收藏 629KB RAR 举报
温馨提示
可以快速将SQL2000数据库里的所有数据导出为INSERT的SQL语句。由于Oracle有这个功能所以为添加。附全部程序源码,MYECLIPSE5.5版本运行cn.sist.database.swing.MainView
资源推荐
资源详情
资源评论
收起资源包目录
DataBaseOutput22.rar (48个子文件)
DataBaseOutput
.project 1016B
.settings
org.eclipse.jdt.ui.prefs 5KB
.mymetadata 315B
WebRoot
WEB-INF
web.xml 375B
lib
sqljdbc.jar 247KB
msbase.jar 280KB
mssqlserver.jar 66KB
msutil.jar 58KB
classes
cn
sist
jdbc
DataBase.class 507B
DataBaseImp.class 4KB
jdbcConfig.properties.bak 172B
jdbcConfig.properties 169B
DataBaseFactory.class 3KB
jdbcConfig_MSSQL.properties 174B
DBProperty.class 2KB
database
swing
MainView$1.class 1KB
MainView$4$2.class 2KB
MainView$4.class 2KB
MainView.class 10KB
MouseListenerAdapter.class 844B
MainView$2.class 1KB
MainView$4$1.class 1KB
MainView$3.class 778B
work
OutPutData.class 6KB
OutputDao.class 3KB
util
DBUtil.class 855B
util
view
FrameUtil.class 857B
MANIFEST.MF 226B
index.jsp 834B
META-INF
MANIFEST.MF 39B
.myeclipse
src
cn
sist
jdbc
DataBase.class 507B
DataBaseFactory.java 3KB
DataBaseImp.class 4KB
DataBaseImp.java 4KB
DBProperty.java 970B
jdbcConfig.properties.bak 172B
DataBase.java 701B
jdbcConfig.properties 169B
DataBaseFactory.class 1KB
jdbcConfig_MSSQL.properties 174B
database
swing
MouseListenerAdapter.java 405B
MainView.java 11KB
work
OutputDao.java 2KB
OutPutData.java 5KB
util
DBUtil.java 466B
util
view
FrameUtil.java 370B
MANIFEST.MF 226B
.classpath 563B
共 48 条
- 1
资源评论
快乐的2
- 粉丝: 85
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功