三国武将查询系统 //Java 访问 数据库
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import java.awt.Color;
import java.sql.*;
import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.URL; public class start extends JFrame {
private String s=new String();
private JTextField input = new JTextField();
private JTextArea myJTextField = new JTextArea();
static Connection connection;
static Statement statement ;
private JScrollPane scrollBar;
private final JLabel lblNewLabel_1 = new JLabel("");
private final JButton btnNewButton_1 = new JButton("\u6309\u667A\u529B\u6392\u5E8F");
private final JButton button = new JButton("\u6309\u6B66\u529B\u6392\u5E8F");
public start()
{
setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\app\\Administrator\\oradata\\mysg\\\u56FE\u6807.png")); setBounds(80, 20, 1240, 700);
getContentPane().setLayout(null);
button.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u6309\u6B66\u529B\u6392\u5E8F.jpg"));
button.setFont(new Font("楷体", Font.PLAIN, 18));
button.setBounds(689, 10, 127, 41); getContentPane().add(button);
btnNewButton_1.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u6309\u667A\u529B\u6392\u5E8F.jpg"));
btnNewButton_1.setFont(new Font("楷体", Font.ITALIC, 18));
btnNewButton_1.setBounds(482, 10, 127, 41);
button.addActionListener(new orderlistener());
btnNewButton_1.addActionListener(new orderlistener2()); getContentPane().add(btnNewButton_1);
input.setBounds(147, 10, 226, 41);
getContentPane().add(input);
input.addActionListener(new inputlistener());
myJTextField.setForeground(new Color(255, 0, 0));
myJTextField.setFont(new Font("Monospaced", Font.PLAIN, 13));
myJTextField.setBackground(new Color(255, 255, 102));
myJTextField.setBounds(1, 1, 1000, 600);
getContentPane().add(myJTextField);
myJTextField.setOpaque(false); JLabel lblNewLabel = new JLabel("\u6B66\u5C06\uFF1A");
lblNewLabel.setFont(new Font("长城行楷体", Font.ITALIC, 28));
lblNewLabel.setBounds(33, 10, 112, 37);
getContentPane().add(lblNewLabel); scrollBar = new JScrollPane(myJTextField);
scrollBar.setBounds(10, 61, 1000, 600);
getContentPane().add(scrollBar); scrollBar.setOpaque(false);
scrollBar.getViewport().setOpaque(false); JButton btnNewButton = new JButton("BACK");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u8FD4\u56DE.jpg"));
btnNewButton.setFont(new Font("长城行楷体", Font.ITALIC, 22));
btnNewButton.setBounds(898, 13, 94, 30);
getContentPane().add(btnNewButton);
lblNewLabel_1.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u80CC\u666F.jpg")); lblNewLabel_1.setBounds(0, 0, 1240, 700);
getContentPane().add(lblNewLabel_1); btnNewButton.addActionListener(new backlistener());
myJTextField.append("姓"+"\t\t"+"字"+"\t\t"+"武力"+"\t\t"+"智力"+"\t\t"+"德行"+"\t\t"+"兵器"+"\t\t"+"招募地"+"\t\t"+"坐骑\n");
} class inputlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
myJTextField.setText("姓"+"\t\t"+"字"+"\t\t"+"武力"+"\t\t"+"智力"+"\t\t"+"德行"+"\t\t"+"兵器"+"\t\t"+"招募地"+"\t\t"+"坐骑\n");
try{
s=input.getText();
String temps=new String();
if(s.equals("all"))
{
temps="select * from v_hero ";
}
else
{
temps="select * from v_hero where 姓名='"+s+"'";
}
//System.out.println(temps);
ResultSet res=statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\t\t"+res.getString(5)+"\t"+res.getString(6)+"\t"+res.getString(7)+"\t"+res.getString(8)+"\n");
} }catch(SQLException ss )
{
myJTextField.append("error!");
}
}
}
class orderlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
myJTextField.setText("姓"+"\t\t"+"字"+"\t\t"+"武力"+"\t\t"+"智力"+"\t\t"+"德行"+"\t\t"+"兵器"+"\t\t"+"招募地"+"\t\t"+"坐骑\n");
try{ String temps=new String();
temps="select * from v_hero order by 武力 desc";
ResultSet res=statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\t\t"+res.getString(5)+"\t"+res.getString(6)+"\t"+res.getString(7)+"\t"+res.getString(8)+"\n");
}
}catch(SQLException ss )
{
myJTextField.append("error!");
}
}
}
class orderlistener2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
myJTextField.setText("姓"+"\t\t"+"字"+"\t\t"+"武力"+"\t\t"+"智力"+"\t\t"+"德行"+"\t\t"+"兵器"+"\t\t"+"招募地"+"\t\t"+"坐骑\n");
try{
String temps=new String();
temps="select * from v_hero order by 智力 desc";
ResultSet res=statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\t\t"+res.getString(5)+"\t"+res.getString(6)+"\t"+res.getString(7)+"\t"+res.getString(8)+"\n");
}
}catch(SQLException ss )
{
myJTextField.append("error!");
}
}
}
class backlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
start.this.setVisible(false);
Login f9=new Login();
f9.setVisible(true);
}
} public static void main(String[] args)
throws SQLException,ClassNotFoundException
{
//new music(); // System.out.println("ssss");
Class.forName("oracle.jdbc.driver.OracleDriver");
connection =DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:MYSG","scott","scott");
statement =connection.createStatement(); Login log=new Login();
log.setVisible(true);
new music().play(new File("F:\\cc.wav"));
//start one= new start(); //one.setVisible(true);
}
}
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton; import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Toolkit; public class Login extends JFrame {
private JPanel contentPane;
public Login()
{
setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\app\\Administrator\\oradata\\mysg\\\u56FE\u6807.png")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Three Kingdoms of heroes system");
setBounds(80, 20, 1240, 700);
contentPane = new JPanel();
contentPane.setBackground(new Color(240, 240, 240));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null); JButton btnNewButton = new JButton("New button");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\1308051010460_\u526F\u672C_\u526F\u672Cwww.jpg"));
btnNewButton.setBounds(46, 344, 240, 45);
contentPane.add(btnNewButton);
btnNewButton.addActionListener(new presslistener()); JButton btnNewButton_1 = new JButton("New button");
btnNewButton_1.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\1308051010460_\u526F\u672C_\u526F\u672C_\u526F\u672Cwwwg.jpg"));
btnNewButton_1.setBounds(46, 444, 240, 47);
contentPane.add(btnNewButton_1);
btnNewButton_1.addActionListener(new presslistener2()); JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\13126052172554n4gg4569www.png"));
lblNewLabel.setBounds(0, 0,1240, 700);
contentPane.add(lblNewLabel);
}
class presslistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Login.this.setVisible(false);
select f2=new select();
f2.setVisible(true); }
}
class presslistener2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Login.this.setVisible(false);
dba f3=new dba();
f3.setVisible(true);
}
}
}
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.Toolkit; public class select extends JFrame { private JPanel contentPane; public select() {
setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\app\\Administrator\\oradata\\mysg\\\u56FE\u6807.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 1240, 700);
setTitle("选择模式"); contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null); JButton btnNewButton = new JButton("New button");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u82F1\u96C41.jpg"));
btnNewButton.setBounds(49, 307, 180, 48);
contentPane.add(btnNewButton);
btnNewButton.addActionListener(new presslistener()); JButton btnNewButton_1 = new JButton("New button");
btnNewButton_1.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u8BF8\u4FAF1.jpg"));
btnNewButton_1.setBounds(49, 407, 180, 48);
contentPane.add(btnNewButton_1);
btnNewButton_1.addActionListener(new presslistener2()); JButton btnNewButton_2 = new JButton("New button");
btnNewButton_2.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u6218\u4E891.jpg"));
btnNewButton_2.setBounds(49, 507, 180, 48);
contentPane.add(btnNewButton_2);
btnNewButton_2.addActionListener(new presslistener3()); JLabel label = new JLabel("");
label.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\90e150338ea4ea55a65527cef1cddded_\u526F\u672C.jpg"));
label.setBounds(0, 0, 1240, 700);
contentPane.add(label); }
class presslistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
select.this.setVisible(false);
start f4=new start();
f4.setVisible(true);
}
}
class presslistener2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
select.this.setVisible(false);
country f5=new country();
f5.setVisible(true);
}
}
class presslistener3 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
select.this.setVisible(false);
war f6=new war();
f6.setVisible(true);
}
} }
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.ImageIcon;
import java.awt.Toolkit; public class country extends JFrame { private JPanel contentPane;
private String s=new String();
private String s2=new String();
private JTextField input = new JTextField();
private JTextField input2 = new JTextField();
private JTextArea myJTextField = new JTextArea();
private JScrollPane scrollBar;
private final JLabel label = new JLabel("\u6B66\u5C06\uFF1A");
private final JLabel label_1 = new JLabel("\u4E3B\u516C\uFF1A"); public country() {
setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\app\\Administrator\\oradata\\mysg\\\u56FE\u6807.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("武将从属查询");
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setBounds(80, 20, 1240, 700);
getContentPane().setLayout(null);
//myJTextField.setOpaque(false); input.setBounds(183, 10, 190, 41);
getContentPane().add(input);
input.addActionListener(new inputlistener()); input2.setBounds(480, 10, 205, 41);
getContentPane().add(input2);
input2.addActionListener(new inputlistener());
myJTextField.setForeground(new Color(255, 0, 0)); myJTextField.setFont(new Font("Monospaced", Font.PLAIN, 13));
myJTextField.setBackground(new Color(255, 245, 238));
myJTextField.setBounds(10, 61, 1000, 629);
getContentPane().add(myJTextField);
input.setBounds(147, 10, 226, 41); scrollBar = new JScrollPane(myJTextField);
scrollBar.setBounds(10, 61, 1000, 629);
getContentPane().add(scrollBar);
label.setFont(new Font("长城行楷体", Font.ITALIC, 28));
label.setBounds(42, 10, 95, 39); myJTextField.setOpaque(false);
scrollBar.setOpaque(false);
scrollBar.getViewport().setOpaque(false); contentPane.add(label);
label_1.setFont(new Font("长城行楷体", Font.ITALIC, 28));
label_1.setBounds(393, 12, 95, 39); contentPane.add(label_1); JButton btnNewButton = new JButton("BACK");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u8FD4\u56DE.jpg"));
btnNewButton.setForeground(new Color(255, 0, 0));
btnNewButton.setFont(new Font("长城行楷体", Font.ITALIC, 22));
btnNewButton.setBounds(1061, 21, 95, 30);
getContentPane().add(btnNewButton); JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u57CE\u5E02.jpg"));
lblNewLabel.setBounds(0, 0, 1240, 700);
contentPane.add(lblNewLabel);
btnNewButton.addActionListener(new backlistener());
} class inputlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{ try{
s=input.getText();
s2=input2.getText();
String temps=new String();
if(s2.equals("all"))
{
myJTextField.setText("主公名"+"\t\t"+"现役武将数"+"\t\t"+"兵力\n");
temps="select hname,num_of_hero,num_of_army from country,hero where country.ono=hero.hno";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+"\n");
}
}
else if(s.equals("all"))
{
myJTextField.setText("武将"+"\t\t "+"主公"+"\t\t "+"忠诚"+"\t\t "+"时期\n");
temps="select * from v_hero_owner";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\n");
}
}
else
{
myJTextField.setText("武将"+"\t\t "+"主公"+"\t\t "+"忠诚"+"\t\t "+"时期\n");
temps="select * from v_hero_owner where 武将='"+s+"' and 主公='"+s2+"'";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\n");
}
}
System.out.println(temps); }catch(SQLException ss )
{
myJTextField.append("error!");
}
}
}
class backlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
country.this.setVisible(false);
Login f9=new Login();
f9.setVisible(true);
}
}
}
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;
import java.awt.Toolkit; public class war extends JFrame { private JPanel contentPane;
private String s=new String();
private String s2=new String();
private JTextField input = new JTextField();
private JTextField input2 = new JTextField();
private JTextArea myJTextField = new JTextArea();
private JScrollPane scrollBar;
private final JLabel label = new JLabel("\u6B66\u5C06\uFF1A");
private final JLabel label_1 = new JLabel("\u6218\u4E89\uFF1A"); public war() {
setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\app\\Administrator\\oradata\\mysg\\\u56FE\u6807.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("战争战绩查询");
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setBounds(80, 20, 1240, 700);
getContentPane().setLayout(null); input.setBounds(183, 10, 190, 41);
getContentPane().add(input);
input.addActionListener(new inputlistener()); input2.setBounds(491, 10, 231, 41);
getContentPane().add(input2);
input2.addActionListener(new inputlistener());
myJTextField.setForeground(new Color(255, 0, 0)); myJTextField.setFont(new Font("Monospaced", Font.PLAIN, 13));
myJTextField.setBackground(Color.YELLOW);
myJTextField.setBounds(10, 61, 1000, 600);
getContentPane().add(myJTextField);
input.setBounds(147, 10, 226, 41); scrollBar = new JScrollPane(myJTextField);
scrollBar.setBounds(10, 61, 1000, 600);
getContentPane().add(scrollBar);
label.setFont(new Font("长城行楷体", Font.ITALIC, 27));
label.setBounds(35, 10, 91, 38); contentPane.add(label);
label_1.setFont(new Font("长城行楷体", Font.ITALIC, 27));
label_1.setBounds(386, 10, 91, 38); contentPane.add(label_1); myJTextField.setOpaque(false);
scrollBar.setOpaque(false);
scrollBar.getViewport().setOpaque(false); JButton btnNewButton = new JButton("BACK");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u8FD4\u56DE.jpg"));
btnNewButton.setFont(new Font("长城行楷体", Font.ITALIC, 22));
btnNewButton.setBounds(1102, 13, 91, 30);
getContentPane().add(btnNewButton); JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u6218\u4E89.jpg"));
lblNewLabel.setBounds(0, 0, 1240, 700);
contentPane.add(lblNewLabel);
btnNewButton.addActionListener(new backlistener());
}
class inputlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{ try{
s=input.getText();
s2=input2.getText();
String temps=new String();
if(s.equals("all"))
{
myJTextField.setText("武将名"+"\t\t\t"+"参加的战争"+"\t\t\t"+"主要战绩\n");
temps="select * from v_hero_war ";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+"\n");
}
}
else if(s2.equals("all"))
{
myJTextField.setText("战争名"+"\t\t "+"参战阵营"+"\t\t "+"战果"+"\t\t "+"战争地点"+"\t\t\t\t"+"时间\n");
temps="select * from war";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\t\t"+res.getString(5)+"\n");
}
}
else
{
myJTextField.setText("武将名"+"\t\t\t"+"参加的战争"+"\t\t\t"+"主要战绩\n");
temps="select * from v_hero_war where 武将='"+s+"' and 战争='"+s2+"'";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\n");
}
}
System.out.println(temps); }catch(SQLException ss )
{
myJTextField.append("error!");
}
}
}
class backlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
war.this.setVisible(false);
Login f9=new Login();
f9.setVisible(true);
}
}
}
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Font;
import java.awt.Color;
import java.awt.Toolkit; public class dba extends JFrame { private JPanel contentPane;
public dba() {
setIconImage(Toolkit.getDefaultToolkit().getImage("D:\\app\\Administrator\\oradata\\mysg\\\u56FE\u6807.png"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(80, 20, 1240, 700);
setTitle("欢迎管理");
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null); JButton btnNewButton = new JButton("\u589E\u52A0\u6B66\u5C06");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u589E\u52A0\u6B66\u5C06.jpg"));
btnNewButton.setForeground(new Color(255, 0, 0));
btnNewButton.setBackground(new Color(105, 105, 105));
btnNewButton.setFont(new Font("长城行楷体", Font.ITALIC, 28));
btnNewButton.setBounds(80, 81, 164, 42);
contentPane.add(btnNewButton);
btnNewButton.addActionListener(new addlistener()); JButton btnNewButton_1 = new JButton("\u5220\u9664\u6B66\u5C06");
btnNewButton_1.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u5220\u9664\u6B66\u5C06.jpg"));
btnNewButton_1.setForeground(new Color(255, 0, 0));
btnNewButton_1.setFont(new Font("长城行楷体", Font.ITALIC, 28));
btnNewButton_1.setBounds(973, 81, 164, 42);
contentPane.add(btnNewButton_1); JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\Three_Kingdoms.jpg"));
lblNewLabel.setBounds(0, 0, 1240, 700);
contentPane.add(lblNewLabel);
btnNewButton_1.addActionListener(new deletelistener());
}
class addlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
dba.this.setVisible(false);
addhero f7=new addhero();
f7.setVisible(true);
}
}
class deletelistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
dba.this.setVisible(false);
deletehero f8=new deletehero();
f8.setVisible(true);
}
} }
import java.awt.BorderLayout;
import java.awt.EventQueue; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException; public class addhero extends JFrame { private JPanel contentPane;
private JTextField []textField=new JTextField[6];
//private JTextField textField_1;
//private JTextField textField_2;
//Field textField_3;
//private JTextField textField_4;
//private JTextField textField_5; JFrame tt;
public addhero() {
setTitle("增加英雄");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(50, 50, 1000, 701);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
getContentPane().setLayout(null); for(int i=0;i<6;i++)
textField[i] = new JTextField();
textField[0].setBounds(93, 24, 220, 37);
contentPane.add(textField[0]);
textField[0].setColumns(10); System.out.println("sadas");
//textField[1] = new JTextField();
textField[1].setColumns(10);
textField[1].setBounds(93, 91, 220, 37);
contentPane.add(textField[1]); //textField[2]= new JTextField();
textField[2].setColumns(10);
textField[2].setBounds(93, 158, 220, 37);
contentPane.add(textField[2]); //textField[3] = new JTextField();
textField[3].setColumns(10);
textField[3].setBounds(93, 222, 220, 37);
contentPane.add(textField[3]); //textField[4] = new JTextField();
textField[4].setColumns(10);
textField[4].setBounds(93, 283, 220, 37);
contentPane.add(textField[4]); //textField[5] = new JTextField();
textField[5].setColumns(10);
textField[5].setBounds(93, 349, 220, 37);
contentPane.add(textField[5]); for(int i=0;i<6;i++)
textField[i].addActionListener(new addlistener2()); JLabel label = new JLabel("\u6B66\u5C06\u540D");
label.setFont(new Font("长城行楷体", Font.PLAIN, 21));
label.setBounds(10, 24, 73, 37);
contentPane.add(label); JLabel label_1 = new JLabel("\u5B57");
label_1.setFont(new Font("长城行楷体", Font.PLAIN, 21));
label_1.setBounds(10, 91, 73, 37);
contentPane.add(label_1); JLabel label_2 = new JLabel("\u6B66\u529B");
label_2.setFont(new Font("长城行楷体", Font.PLAIN, 21));
label_2.setBounds(10, 158, 73, 37);
contentPane.add(label_2); JLabel label_3 = new JLabel("\u667A\u529B");
label_3.setFont(new Font("长城行楷体", Font.PLAIN, 21));
label_3.setBounds(10, 222, 73, 37);
contentPane.add(label_3); JLabel label_4 = new JLabel("\u54C1\u5FB7");
label_4.setFont(new Font("长城行楷体", Font.PLAIN, 21));
label_4.setBounds(10, 283, 73, 37);
contentPane.add(label_4); JLabel label_5 = new JLabel("\u6B66\u5668");
label_5.setFont(new Font("长城行楷体", Font.PLAIN, 21));
label_5.setBounds(10, 349, 73, 37);
contentPane.add(label_5);
}
class addlistener2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try{ String []s=new String[6];
for(int i=0;i<6;i++)
{
s[i]=new String();
s[i]=textField[i].getText();
} String temps=new String();
temps="insert into hero values(null,'"+s[0]+"','"+s[1]+"',"+s[2]+","+s[3]+","+s[4]+",'"+s[5]+"',null,null)"; System.out.println(temps);
ResultSet res=start.statement.executeQuery(temps);
tt=new JFrame();
tt.setBounds(100, 100, 500, 80);
JButton ta = new JButton("恭喜!武将"+s[0]+"添加成功! 点击返回");
tt.add(ta);
tt.setVisible(true);
ta.addActionListener(new backlistener());
}catch(SQLException ss )
{
textField[0].setText("error!");
}
}
}
class backlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
addhero.this.setVisible(false);
tt.setVisible(false);
dba f8=new dba();
f8.setVisible(true);
}
}
}
import java.awt.BorderLayout;
import java.awt.EventQueue; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException; public class deletehero extends JFrame { private JPanel contentPane;
private JTextField textField;
JFrame tt;
public deletehero() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("删除英雄");
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null); textField = new JTextField();
textField.setBounds(125, 55, 195, 63);
contentPane.add(textField);
textField.setColumns(10);
textField.addActionListener(new deletelistener()); JLabel label = new JLabel("\u6B66\u5C06\u540D");
label.setFont(new Font("长城行楷体", Font.ITALIC, 30));
label.setBounds(10, 55, 105, 63);
contentPane.add(label);
}
class deletelistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try{ String s=new String();
s=textField.getText();
String temps=new String();
temps="delete from hero where hname='"+s+"'"; System.out.println(temps);
ResultSet res=start.statement.executeQuery(temps);
tt=new JFrame();
tt.setBounds(100, 100, 500, 80);
JButton ta = new JButton("恭喜!武将"+s+"删除成功! 点击返回");
tt.add(ta);
tt.setVisible(true);
ta.addActionListener(new backlistener());
}catch(SQLException ss )
{
textField.setText("error!");
}
}
}
class backlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
deletehero.this.setVisible(false);
tt.setVisible(false);
dba f8=new dba();
f8.setVisible(true);
}
}
}
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
import java.io.File; public class music{
private AudioInputStream stream = null;
private AudioFormat format = null;
private SourceDataLine m_line;
public void play(File fileName)
{
try {
stream = AudioSystem.getAudioInputStream(fileName);
// At present, ALAW and ULAW encodings must be converted
// to PCM_SIGNED before it can be played
format = stream.getFormat();
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
format = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
16,
format.getChannels(),
format.getChannels() * 2,
format.getSampleRate(),
false); // big endian
stream = AudioSystem.getAudioInputStream(format, stream);
}
// Create the clip
DataLine.Info info = new DataLine.Info(SourceDataLine.class, stream.getFormat(), AudioSystem.NOT_SPECIFIED);
m_line = (SourceDataLine) AudioSystem.getLine(info);
m_line.open(stream.getFormat(),m_line.getBufferSize());
m_line.start();
int numRead = 0;
byte[] buf = new byte[m_line.getBufferSize()];
while ((numRead = stream.read(buf, 0, buf.length)) >= 0) {
int offset = 0;
while (offset < numRead) {
offset += m_line.write(buf, offset, numRead-offset);
}
}
m_line.drain();
m_line.stop();
m_line.close();
stream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public double getDuration()
{
return m_line.getBufferSize() /
(m_line.getFormat().getFrameSize() * m_line.getFormat().getFrameRate());
}
public double getDecision()
{
return m_line.getMicrosecondPosition()/1000.0;
} }
三国武将查询系统 //Java 访问 数据库的更多相关文章
- 三国武将查询系统 //Java 訪问 数据库
import java.awt.*; import javax.swing.*; import java.awt.event.ActionListener; import java.awt.event ...
- JavaSE学习总结(九)—— Java访问数据库(JDBC)
一.JDBC简介 JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Java ...
- oracle 事务简介,锁的概念,java访问数据库注意事项
java链接oracle和连接其他数据库一样有两种方式:1 桥接 jdbc-obdc2 jbdc insert语句一次插入大量数据 insert into table (列1,列2,列3) selec ...
- Java访问数据库Mysql
一.概述 本文主要介绍Java接连数据库的基本方法和步骤,并对其中的几个要点进行简要说明. 二.数据库访问步骤 在Java中连接数据库进行的访问主要有以下几个步骤: 加载数据库驱动 注册数据库驱动 建 ...
- java 访问数据库公共类
package com.javaweb.mvc; import java.sql.*; /** * @author 公共数据访问类 * * Statement 和 PreparedStatement之 ...
- java访问数据库步骤详解
eg1: public static void main(String[] args) throws ClassNotFoundException, SQLException { //第一步:加载JD ...
- java访问数据库被拒绝,不能连接数据库ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
错误原因:mysql数据库只允许本地ip访问: 解决方法:修改mysql表设置所有ip都可以访问: 登录数据库 使用以下命令: use mysql; grant all privileges on * ...
- java 访问数据库
Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);//依据不同数据库,加载不同驱动 String url = “jdbc:sq ...
- java访问数据库的sql
drop database if exists STOREDB;create database STOREDB;use STOREDB; create table CUSTOMERS ( ID big ...
随机推荐
- k8s 如何 Failover?
上一节我们有 3 个 nginx 副本分别运行在 k8s-node1 和 k8s-node2 上.现在模拟 k8s-node2 故障,关闭该节点. 等待一段时间,Kubernetes 会检查到 k8s ...
- 用 Deployment 运行应用【转】
从本章开始,我们将通过实践深入学习 Kubernetes 的各种特性.作为容器编排引擎,最重要也是最基本的功能当然是运行容器化应用,这就是本章的内容. Deployment 前面我们已经了解到,Kub ...
- 用navcat编写定时任务调用存储过程
最近项目需要改动比较大,数据库结构也有所改变,这时就需要转移旧数据到新库中 第一时间想到的是用代码操作,由于两个库表结构不同,实体什么的得需要重新生成 并编写转移代码,这将是很大的工作量: 然后就想着 ...
- PAT (Basic Level) Practise (中文)-1030. 完美数列(25)
PAT (Basic Level) Practise (中文)-1030. 完美数列(25) http://www.patest.cn/contests/pat-b-practise/1030 给 ...
- PAT 乙级 1033
题目 题目地址:PAT 乙级 1033 题解 本题一直有一分的样例点过不了,原因在于用了cin接收输入的字符…… 问题在于:如果用cin输入,无法接收无坏键的情况的输入,需要getline作为输入:这 ...
- 006 CSS三种引入方式
CSS三种引入方式 一.三种方式的书写规范 1.行间式 <div style="width: 100px; height: 100px; background-color: red&q ...
- grub加密。
一.介绍 安全无小事 linux系统的安全分为很多方面,什么端口啊,什么网络啊,听着都特么烦,今天谈谈最简单明显的密码安全. 二.单用户模式 单用户模式个人觉得相当有用,可以用来修复系统,修改密码… ...
- 【01】blockqote美化
[01]blockqote美化 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta ch ...
- Matplotlib基本图形之条形图2
Matplotlib基本图形之条形图2 1.绘制多条条形图 示例代码: import time import numpy as np import matplotlib.pyplot as plt b ...
- 脑阔疼的双层SQLserver游标
本来简单的双层游标没啥的,内层游标需要读取的是视图的内容,一直报“当前命令发生了严重错误.应放弃任何可能产生的结果.”的错误.无可奈何尝试先将视图的数据放到表变量中,之后再用游标遍历表变量. 简直很怀 ...