java界面查询功能代码 Java查询语句
Java实现查询的功能
查询部分代码如下:
创新互联建站是一家集网站建设,都匀企业网站建设,都匀品牌网站建设,网站定制,都匀网站建设报价,网络营销,网络优化,都匀网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
String strSQL;
strSQL="select * from tb_manager where manager='"+jTextField1.getText().trim()+"'";
rs=db.getResult(strSQL);
try
{
if(rs.first())
{
jTextField1.setText(rs.getString("manager"));
jTextField2.setText(rs.getString("den"));
jTextField3.setText(rs.getString("ID"));
jTextField4.setText(rs.getString("remark"));
jTextField5.setText(rs.getString("sex"));
}
else
{
JOptionPane.showMessageDialog(null,"无此信息");
}
}catch(SQLException e)
{JOptionPane.showMessageDialog(null," 查询信息失败!");}
}
java顺序查找界面实现代码 急求
int[] numbers = new int[5]{1,2,3,4,5};
public int indexOf(int n){
for(int i = 0; i numbers.length; i++){
if(numbers[i] == n){
return i;
}
}
return -1;
}
基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写?
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import javax.swing.JButton;
public class Stmessege {
Font font = new Font("楷体", Font.BOLD, 18);
private Frame m = new Frame("登陆成功界面");
protected Window f;
public Stmessege() {
m.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
m.setVisible(false);
m.dispose();
System.exit(0);
}
});
m.setSize(460, 360);
m.setBackground(Color.green);
m.setLayout(null);
m.setLocationRelativeTo(null);
Label l0 = new Label("管理员信息");
Font font1 = new Font("楷体", Font.BOLD, 32);
l0.setForeground(Color.blue);
l0.setSize(180, 50);
l0.setLocation(150, 30);
l0.setFont(font1);
final Label l1 = new Label("姓名:");
l1.setSize(60, 20);
l1.setLocation(10, 100);
l1.setFont(font);
TextField tf1 = new TextField("黄朋");
tf1.setForeground(Color.blue);
tf1.setBackground(Color.white);
tf1.setSize(50, 20);
tf1.setLocation(70, 100);
final Label l2 = new Label("学号:");
l2.setSize(60, 20);
l2.setLocation(140, 100);
l2.setFont(font);
TextField tf2 = new TextField("111265");
tf2.setForeground(Color.blue);
tf2.setBackground(Color.white);
tf2.setSize(60, 20);
tf2.setLocation(190, 100);
final Label l3 = new Label("性别:");
l3.setSize(60, 20);
l3.setLocation(280, 100);
l3.setFont(font);
TextField tf3 = new TextField("男");
tf3.setForeground(Color.blue);
tf3.setBackground(Color.white);
tf3.setSize(40, 20);
tf3.setLocation(360, 100);
final Label l4 = new Label("班级:");
l4.setSize(60, 20);
l4.setLocation(10, 170);
l4.setFont(font);
TextField tf4 = new TextField("611231");
tf4.setForeground(Color.blue);
tf4.setBackground(Color.white);
tf4.setSize(60, 20);
tf4.setLocation(67, 170);
final Label l5 = new Label("系别:");
l5.setSize(60, 20);
l5.setLocation(140, 170);
l5.setFont(font);
TextField tf5 = new TextField("计算机工程系");
tf5.setForeground(Color.blue);
tf5.setBackground(Color.white);
tf5.setSize(80, 20);
tf5.setLocation(200, 170);
final Label l6 = new Label("成绩:");
l6.setSize(60, 20);
l6.setLocation(280, 170);
l6.setFont(font);
TextField tf6 = new TextField("95");
tf6.setForeground(Color.blue);
tf6.setBackground(Color.white);
tf6.setSize(40, 20);
tf6.setLocation(360, 170);
final Label l7 = new Label("专业:");
l7.setSize(60, 20);
l7.setLocation(10, 230);
l7.setFont(font);
TextField tf7 = new TextField("软件技术");
tf7.setForeground(Color.blue);
tf7.setBackground(Color.white);
tf7.setSize(60, 20);
tf7.setLocation(70, 230);
JButton btn1 = new JButton("添加");
btn1.setForeground(Color.blue);
btn1.setSize(80, 38);
btn1.setLocation(35, 300);
btn1.setFont(font);
btn1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 插入();
m.setVisible(true);
}
});
JButton btn2 = new JButton("查询学生学籍信息");
btn2.setForeground(Color.blue);
btn2.setSize(200, 38);
btn2.setLocation(135, 300);
btn2.setFont(font);
btn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Stmessege1 f;
try {
f = new Stmessege1();
f.Stmessege11();
m.setVisible(true);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
JButton btn3 = new JButton("删除");
btn3.setForeground(Color.blue);
btn3.setSize(80, 38);
btn3.setLocation(350, 300);
btn3.setFont(font);
btn3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 删除();
//f.setVisible(false);
m.setVisible(true);
}
});
JButton btn4 = new JButton("更新");
btn4.setForeground(Color.blue);
btn4.setSize(80, 38);
btn4.setLocation(200, 230);
btn4.setFont(font);
btn4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new 更新();
m.setVisible(true);
}
});
m.add(l0);
m.add(l1);
m.add(tf1);
m.add(l2);
m.add(tf2);
m.add(l3);
m.add(tf3);
m.add(l4);
m.add(tf4);
m.add(l5);
m.add(tf5);
m.add(l6);
m.add(tf6);
m.add(l7);
m.add(tf7);
m.add(btn1);
m.add(btn2);
m.add(btn3);
m.add(btn4);
m.setVisible(true);
}
public static void main(String[] args) {
new Stmessege();
}
}
可以仿照我的做一下,希望采纳,我才一级哦
java使用面向对象写一个登录注册查询的功能
import java.util.Scanner;/**
* 采用面向对象的方式 写一个登录系统
* @author Administrator
*
*///用户信息class UserInfo{ public static String[] user = new String[10]; public static String[] passwd = new String[10];
public UserInfo() { this.user[0] = "test"; this.passwd[0] ="123456";
}
}//找回密码class ZhaoHui extends UserInfo{ public static void zhaohui() {
Scanner s = new Scanner(System.in);
System.out.println("请输入你要找回的用户名:");
String zname = s.nextLine(); for(int i=0;i2;i++) { if(user[i].equals(zname)) {
Scanner ss = new Scanner(System.in);
System.out.println("恭喜你!成功找回密码,请输入:"+"'张哥最帅'"+" 查看密码");
String zgzs = ss.nextLine();
if("张哥最帅".equals(zgzs)) {
System.out.println(passwd[i]);
}else {
System.out.println("请输正确!");
}
}else if(user[i]!=zname){
System.out.println("用户名不存在!"); return;
}
break;
}
}
}//修改密码 class XiuGai extends UserInfo{ public static void xiugai() {
Scanner s =new Scanner(System.in);
System.out.println("请输入您要修改的密码:");
String xpasswd = s.nextLine(); for(int i=0;i2;i++) {
passwd[i] = xpasswd; if(xpasswd.equals(passwd[i])) {
System.out.println("恭喜你,修改成功!"); break;
}else {
System.out.println("修改密码失败"); break;
}
}
}
}//查询用户class ChaXun extends UserInfo{
public static void select() { for(int i=0;i2;i++) {
System.out.println("当前用户:"+user[i] +"\n"+ "当前密码:"+passwd[i] );
i++; break;
}
}
}//注册class ZhuCe extends UserInfo{
public static void regist() {
Scanner ss = new Scanner(System.in);
System.out.println("请输入用户名:");
String suser = ss.nextLine();
System.out.println("请输入密码:");
String spasswd = ss.nextLine();
for(int i=0;iuser.length;i++) {
user[i] = suser;
passwd[i] = spasswd;
System.out.println("注册成功!"); break;
}
}
}//登录class Loginc extends UserInfo{
public static void login() { int flag = 1;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入用户名:");
String users = scanner.nextLine();
System.out.println("请输入密码:");
String passwds = scanner.nextLine();
for(int i=0;iUserInfo.user.length;i++) { if(user[i].equals(users) passwd[i].equals(passwds)) {
System.out.println("登陆成功!"); break;
}
System.out.println("登陆失败!"); break;
}
}
}//主界面class ZhuJieMian{ public static void Start() {
Loginc Loginc = new Loginc();
ZhuCe ZhuCe = new ZhuCe();
ChaXun ChaXun = new ChaXun();
XiuGai XiuGai = new XiuGai();
ZhaoHui ZhaoHui = new ZhaoHui();
Scanner s = new Scanner(System.in); while(true) {
System.out.println("|"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+"\t"+"|");
System.out.println("|"+"\t" + "测试用户名:test 测试密码:123456" + "\t"+ "\t"+ "\t"+ "\t"+"|");
System.out.println("|" + "\t"+ "请输入[1-5]进行操作 1.登录|2.注册|3.查询当前用户|4.修改密码|5.找回密码 " + "\t"+"|");
System.out.print("请输入:"); int temp = s.nextInt();
switch(temp) { case 1:Loginc.login(); break; case 2:ZhuCe.regist();; break; case 3:ChaXun.select();; break; case 4:XiuGai.xiugai();; break; case 5:ZhaoHui.zhaohui();; break; default:System.out.println("错误!请重写输入正确的数字进行操作!");
}
}
}
}public class LoginTest { public static void main(String[] args) {
ZhuJieMian zjm = new ZhuJieMian();
zjm.Start();
}
}
用java写了一个界面,要求实现搜索功能,怎么做~?
实现方式有多种,建议方式一:
1. 在页面制作好输入框input,并且定义动作为打开一个帧iframe;
2. 在帧里,执行动作为百度的链接。意思也就是百度执行的结果在我自己的iframe里打开
JAVA中怎么实现查询 代码
try{Connection con;
Statement stmt;
ResultSet rs;
int temp;
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/java","root","");//以上是数据库连接,不同的数据管理器有 //不同的驱动和链接方式,以上是mysql的连接
stmt=con.createStatement();
rs=stmt.executeQuery("select * from student");//执行查询语句,结果赋值给结果集rs
//结果集是结果于字段编号的映射,每一个字
//段都有一个编号,最小为1,也就是第一个字段
while(rs.next()){
String names=rs.getString("name");//查询结果转换成字符串。
System.out.println(names);
}rs.close();
}catch(Exception e){
e.printStackTrace();
}
名称栏目:java界面查询功能代码 Java查询语句
文章转载:http://myzitong.com/article/hgjdsi.html