资源简介
一个链接数据库的小作品,没什么技术技巧,仅供志同道合在学习java的同学参考参考

代码片段和文件信息
package com.rainplus;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
class Loginframe extends Jframe {
private JPanel content;
private JLabel userLabel;
private JLabel passwordLabel;
private JPasswordField passwordField;
private JTextField userNameField;
private JButton loginButton;
private JButton exitButton;
public Loginframe() {
super(“学生选课系统“);
setSize(250 200);
setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
content = new JPanel();
content.setLayout(null);
add(content);
userLabel = new JLabel(“学号:“);
userLabel.setBounds(30 30 40 20);
content.add(userLabel);
userNameField = new JTextField(“11046208“);
userNameField.setBounds(80 30 120 20);
content.add(userNameField);
passwordLabel = new JLabel(“密码:“);
passwordLabel.setBounds(30 60 40 20);
content.add(passwordLabel);
passwordField = new JPasswordField();
passwordField.setBounds(80 60 120 20);
content.add(passwordField);
loginButton = new JButton(“登录“);
loginButton.setBounds(30 100 80 30);
loginButton.addActionListener(new buttonListenner());
content.add(loginButton);
exitButton = new JButton(“退出“);
exitButton.setBounds(120 100 80 30);
exitButton.addActionListener(new buttonListenner());
content.add(exitButton);
/* 设置窗体可见和居中 */
setVisible(true);
setLocationRelativeTo(null);
}
public static void main(String[] args) {
new Loginframe();
}
class buttonListenner implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
if (exitButton == e.getSource()) {
System.exit(0);
}
if (loginButton == e.getSource()) {
/* 对数据库的提取验证操作; */
try {
Class.forName(“com.mysql.jdbc.Driver“);
String url = “jdbc:mysql://localhost/school?user=root&password=root“;
Connection conection = DriverManager.getConnection(url);
Statement statement = conection.createStatement();
String sql = “SELECT * FROM user“;// 选择用户表
/* 获取结果集 */
ResultSet resultSet = statement.executeQuery(sql);
resultSet.next();
String userName = resultSet.getString(1);
while (!userName.equals(userNameField.getText())) {
resultSet.next();
userName = resultSet.getString(1);
}
if (userName.equals(userNameField.getText())) {
String password = resultSet.getNString(2);
if (password.equals(new String(passwordField
.getPassword()))) {
new Mainframe(userNamestatement);
dispose();
} else {
JOptionPane.showMessageDialog(null “密码
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 451 2013-10-28 20:38 学生管理系统\.classpath
文件 394 2013-10-22 21:47 学生管理系统\.project
文件 598 2013-10-22 21:47 学生管理系统\.settings\org.eclipse.jdt.core.prefs
文件 2897 2013-10-31 19:30 学生管理系统\bin\com\rainplus\Loginfr
文件 2417 2013-10-31 19:30 学生管理系统\bin\com\rainplus\Loginfr
文件 905 2013-11-01 16:09 学生管理系统\bin\com\rainplus\Mainfr
文件 1173 2013-11-01 16:09 学生管理系统\bin\com\rainplus\Mainfr
文件 1010 2013-11-01 16:09 学生管理系统\bin\com\rainplus\Mainfr
文件 7242 2013-11-01 16:09 学生管理系统\bin\com\rainplus\Mainfr
文件 3240 2013-10-26 16:02 学生管理系统\src\com\rainplus\Loginfr
文件 7063 2013-11-01 16:09 学生管理系统\src\com\rainplus\Mainfr
目录 0 2013-10-31 19:30 学生管理系统\bin\com\rainplus
目录 0 2013-10-25 15:56 学生管理系统\src\com\rainplus
目录 0 2013-10-31 19:30 学生管理系统\bin\com
目录 0 2013-10-22 21:53 学生管理系统\src\com
目录 0 2013-10-22 21:47 学生管理系统\.settings
目录 0 2013-10-31 19:30 学生管理系统\bin
目录 0 2013-10-22 21:53 学生管理系统\src
目录 0 2013-10-22 21:47 学生管理系统
----------- --------- ---------- ----- ----
27390 19
相关资源
- Mysql5.5jdbc驱动程序
- 美食天下项目Android版源码和Web版源码
- java代码编写将excel数据导入到mysql数据
- JSP+MYSQL旅行社管理信息系统
- mysql jsp网站源码下载
- 基于jsp的bbs论坛 非常详细
- JSP学生信息管理系统 Mysql数据库
- android通过JDBC连接Mysql数据库
- JSP+mysql新闻发布系统.rar
- 简易教学管理系统(jsp spring struts h
- 学生信息管理系统 JSP MySQL
- JSP课程设计-留言本 jsp mysql tomcat实现
- jsp mysql tomcat学生信息管理系统
- 科研管理系统 java swing mysql
- dreamweaver jsp mysql网站实现
- jsp mysql在线考试系统 文档
- 设备管理系统/Javaamp;MySQL
- 简单的登录页面,实现增删改查(运
- jsp+mysql学生信息管理系统
- jsp+servlet+javabean+mysql党员信息管理系统
- mysql数据处理,java用户登录处理
- 学生信息管理系统源码+mysql数据库
- shine网上书城(jsp+mysql)
- 奖学金管理系统java+jsp+mysql
- mysql-connector-java-5.0.8-bin驱动jar
- 官方mysql-connector-java-5.1.28-bin.jar
- mysql-connector-java-5.1.17.jar
- Android直连Mysql数据库需要导入的jar包
- mysql与java连接的适配包mysql-connector-
- JSP+MYSQL鞋城在线销售系统
评论
共有 条评论