设为首页 加入收藏

TOP

三国武将查询系统//Java访问数据库(六)
2015-07-24 10:44:43 来源: 作者: 【 】 浏览:3
Tags:三国 武将 查询系统 //Java 访问 数据库
ut.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 ) { myJTextFie
首页 上一页 3 4 5 6 7 8 9 下一页 尾页 6/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇关于jdbc的一些疑问 下一篇用户登录失败,该用户与可信SQLSe..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++ Lambda表达式保 (2025-12-26 05:49:45)
·C++ Lambda表达式的 (2025-12-26 05:49:42)
·深入浅出 C++ Lambda (2025-12-26 05:49:40)
·C语言指针从入门到基 (2025-12-26 05:21:36)
·【C语言指针初阶】C (2025-12-26 05:21:33)