📄 mainframe.java
字号:
JOptionPane.showMessageDialog(this, "数据分析已经完成,请确认", "完成提示", 1);
jButton2.setEnabled(true);
totallength = updateLines;
}
if (pressed.equals(s2)) {
JOptionPane.showMessageDialog(this, "数据导入已经完成,请确认", "完成提示", 1);
jButton3.setEnabled(true);
totallength = 0;
}
jButton5.setEnabled(false);
isPause = false;
thread = null;
}
catch(Exception ex)
{
outputException(ex);
br = null;
if(pressed.equals("jButton2"))
jButton2.setEnabled(true);
if(pressed.equals("jButton3"))
jButton3.setEnabled(true);
jButton5.setEnabled(false);
isPause = false;
thread = null;
}
}
private void procBank(String s, String s1, String s2, String s3, ArrayList arraylist)
{
s2 = fixedJustLength(s2, 70, "R").trim();
s2 = formatName(replaceAll(s2, "'", "''"));
s3 = fixedJustLength(s3, 70, "R").trim();
s3 = formatName(replaceAll(s3, "'", "''"));
String s4 = fixedJustLength(s2 + "\r\n" + s3, 140, "R").trim();
String[] tableRow;
DefaultTableModel defaulttablemodel = (DefaultTableModel) jTable1.getModel();
if (s.equals("FID")) {
if(arraylist.indexOf(s1) > -1){
deleteLines++;
tablepos++;
tableRow = new String[]{String.valueOf(tablepos), s1, s2, s2, s3, s3, s4, "delete"};
defaulttablemodel.addRow(tableRow);
}
//String deleteSql = "delete from party where bic = '" + s1 + "'";
//System.out.println("deleteSql is:"+deleteSql);
} else {
tableRow = new String[8];
updateLines++;
tablepos++;
tableRow[0] = String.valueOf(tablepos);
tableRow[1] = s1;
tableRow[2] = s2;
tableRow[3] = s2;
tableRow[4] = s3;
tableRow[5] = s3;
tableRow[6] = s4;
if (arraylist.indexOf(s1) > -1) {
tableRow[7] = "update";
//String updateSql = "update party set cn_add = '" + s3 + "',cn_name = '" + s2 + "',eng_name = '" + s2 + "',eng_add = '" + s3 + "'" + ",namadr = '" + s4 + "' where bic = '" + s1 + "'";
//System.out.println("updateSql is:"+updateSql);
} else {
tableRow[7] = "insert";
//String insertSql = "insert into party(pty_id,pty_type,eng_name,eng_add,cn_name,cn_add,bic,namadr) values('" + s1 + "','B','" + s2 + "','" + s3 + "','" + s2 + "','" + s3 + "','" + s1 + "','" + s4 + "')";
//System.out.println("insertSql is:"+ insertSql );
}
defaulttablemodel.addRow(tableRow);
}
}
private void procBank2(String s, String s1, String s2, String s3, ArrayList arraylist, Statement statement) throws SQLException
{
String s4;
s2 = fixedJustLength(s2, 70, "R").trim();
s2 = formatName(replaceAll(s2, "'", "''"));
s3 = fixedJustLength(s3, 70, "R").trim();
s3 = formatName(replaceAll(s3, "'", "''"));
s4 = fixedJustLength(s2 + "\r\n" + s3, 140, "R").trim();
String[] tableRow;
DefaultTableModel defaulttablemodel = (DefaultTableModel) jTable1.getModel();
if (s.equals("FID")) {
if(arraylist.indexOf(s1) > -1){
deleteLines++;
tablepos++;
String s6 = "delete from " + (String) fieldNames.get(FIELDNAMES[7]) + " where " + (String) fieldNames.get(FIELDNAMES[0]) + " = '" + s1 + "'";
//System.out.println("deleteSql is:"+s6);
statement.executeUpdate(s6);
tableRow = new String[]{String.valueOf(tablepos), s1, s2, s2, s3, s3, s4, "delete"};
defaulttablemodel.addRow(tableRow);
}
} else {
String s7;
tableRow = new String[8];
updateLines++;
tablepos++;
tableRow[0] = String.valueOf(tablepos);
tableRow[1] = s1;
tableRow[2] = s2;
tableRow[3] = s2;
tableRow[4] = s3;
tableRow[5] = s3;
tableRow[6] = s4;
if (arraylist.indexOf(s1) > -1) {
s7 = "update " + (String) fieldNames.get(FIELDNAMES[7]) + " set " + (String) fieldNames.get(FIELDNAMES[3]) + " = '" + s3 + "'," + (String) fieldNames.get(FIELDNAMES[1]) + " = '" + s2 + "'," + (String) fieldNames.get(FIELDNAMES[2]) + " = '" + s2 + "'," + (String) fieldNames.get(FIELDNAMES[4]) + " = '" + s3 + "'" + "," + (String) fieldNames.get(FIELDNAMES[5]) + " = '" + s4 + "' where " + (String) fieldNames.get(FIELDNAMES[0]) + " = '" + s1 + "'";
tableRow[7] = "update";
} else {
tableRow[7] = "insert";
s7 = "insert into " + (String) fieldNames.get(FIELDNAMES[7]) + "(" + (String) fieldNames.get(FIELDNAMES[8]) + "," + (String) fieldNames.get(FIELDNAMES[6]) + "," + (String) fieldNames.get(FIELDNAMES[2]) + "," + (String) fieldNames.get(FIELDNAMES[4]) + "," + (String) fieldNames.get(FIELDNAMES[1]) + "," + (String) fieldNames.get(FIELDNAMES[3]) + "," + (String) fieldNames.get(FIELDNAMES[0]) + "," + (String) fieldNames.get(FIELDNAMES[5]) + ") values('" + s1 + "','B','" + s2 + "','" + s3 + "','" + s2 + "','" + s3 + "','" + s1 + "','" + s4 + "')";
}
//System.out.println("updateSql is:"+s7);
statement.executeUpdate(s7);
defaulttablemodel.addRow(tableRow);
}
}
public String formatName(String s)
{
ArrayList arraylist = splitStringByKey(s, " ", new ArrayList());
String s1 = "";
for(int i = 0; i < arraylist.size(); i++)
s1 = s1 + (String)arraylist.get(i) + " ";
return s1.trim();
}
public Connection getConnection(String s, String s1, String s2, String s3) throws ClassNotFoundException, SQLException
{
Class.forName(s);
Connection connection = DriverManager.getConnection(s1, s2, s3);
return connection;
}
public void setPressed(String s)
{
pressed = s;
}
public ArrayList splitStringByKey(String s, String s1, ArrayList arraylist)
{
if(s == null)
return arraylist;
StringTokenizer stringtokenizer = new StringTokenizer(s, s1);
do
{
if(!stringtokenizer.hasMoreTokens())
break;
String s2 = stringtokenizer.nextToken();
if(s2.length() > 0)
arraylist.add(s2);
} while(true);
return arraylist;
}
public String replaceAll(String s, String s1, String s2)
{
ArrayList arraylist = new ArrayList();
if(s == null || s.trim().equals(""))
return "";
StringTokenizer stringtokenizer = new StringTokenizer(s, s1);
do
{
if(!stringtokenizer.hasMoreTokens())
break;
String s3 = stringtokenizer.nextToken();
if(s3.length() > 0)
arraylist.add(s3);
} while(true);
s = (String)arraylist.get(0);
for(int i = 1; i < arraylist.size(); i++)
s = s + s2 + (String)arraylist.get(i);
return s;
}
public String fixedJustLength(String s, int i, String s1)
{
String s2 = s;
if(s.equals(""))
{
for(int j = 0; j < i; j++)
s = s + " ";
return s;
}
byte abyte0[] = s.getBytes();
int k = s.getBytes().length;
if(i == k)
return s;
if(i < k)
{
byte abyte1[] = new byte[i];
for(int i1 = 0; i1 < i; i1++)
abyte1[i1] = abyte0[i1];
String s3 = new String(abyte1);
if(!s3.trim().equals(""))
return s3;
i--;
abyte1 = new byte[i];
for(int l1 = 0; l1 < i; l1++)
abyte1[l1] = abyte0[l1];
return new String(abyte1);
}
int l = i - k;
if(s1.equals("R"))
{
for(int j1 = 0; j1 < l; j1++)
s2 = s2 + " ";
}
if(s1.equals("L"))
{
for(int k1 = 0; k1 < l; k1++)
s2 = " " + s2;
}
return s2;
}
private void outputException(Exception ex)
{
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(byteArrayStream);
ex.printStackTrace(printStream);
JOptionPane.showMessageDialog(this, new String(byteArrayStream.toByteArray()).trim(), "出错提示", 0);
try{
printStream.close();
byteArrayStream.close();
}catch(IOException ioe)
{
byteArrayStream = null;
printStream = null;
}
}
public static void main(String args[])
{
EventQueue.invokeLater(new Runnable() {
public void run()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception ex)
{
}
MainFrame mainFrame = new MainFrame("数据导入工具");
int frameWidth = 840;
int frameHeight = 680;
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
GraphicsConfiguration graphicsConfiguration = graphicsDevice.getDefaultConfiguration();
Rectangle bounds = graphicsConfiguration.getBounds();
mainFrame.setLocation((bounds.width - frameWidth) / 2, (bounds.height - frameHeight) / 2);
//System.out.println("frameWidth is:" + frameWidth + "frameHeight is:" + frameHeight);
mainFrame.setSize(frameWidth, frameHeight);
mainFrame.setVisible(true);
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -