Swing—SQL测试工具编写

 

 

通过IO流进行文件的输入输出;

1) 点击确定,将SQL脚本(data.sql)读取并执行,然后结果返回到(out.txt)中去,

2)点击开始比对,把(out.txt)和(true.txt)进行比较,最后返回结果到(result.txt)中;

3)点击打开目录,可以打开相对路径;

输出结果同时显示在文本框中;

 

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package swingsql;

import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;



/**
 *06	
 * @author Highgo
 */
public class NewJFrame extends javax.swing.JFrame {


	// JDBC driver name and database URL
	static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";  
	static final String DB_URL = "jdbc:mysql://localhost:3306/samp_db?serverTimezone=GMT";

	//  Database credentials
	static String USER = "root";
	static String PASS = "zyl123";


	static final String FILE_PATH = "src/out.txt";
	static final String COMPARED_FILE_PATH = "src/true.txt";
	static final String RESULT_FILE_PATH = "src/result.txt";
	static final String DATA_SQL = "src/data.sql";
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Creates new form NewJFrame
	 */
	public NewJFrame() {
		initComponents();
		this.setTitle("SwingSQL测试");
		setLocationRelativeTo(null);
	}


	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	//   @SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
	private void initComponents() {

		text1User = new java.awt.TextField();
		text2Password = new java.awt.TextField();
		label1User = new java.awt.Label();
		label2Password = new java.awt.Label();
		textArea1 = new java.awt.TextArea();
		label3Start = new java.awt.Label();
		jButton1User = new javax.swing.JButton();
		jButton2Password = new javax.swing.JButton();
		jButton3Start = new javax.swing.JButton();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值