java登录注册代码下载
A. 求java web程序,可以实现用户登录、注册,上传、下载文件功能 的小工程
在学习资料库网站上搜索一下,有很多这种小项目的。
B. java编写一个登陆和注册信息的源代码,最简单的就可以,不需要数据库的那种
。。。不需要数据库,还要进行存储,好吧,我还真没这么尝试过,这是要存储为txt文件么⊙﹏⊙b。。。
C. JAVA编写一个与数据库连接,具有登陆,注册,上传,下载功能的TXT小说管理器
你把小说保存在哪呢?
附上一个登陆代码
if(choice.equals("学生")){
check=Check.checkSno(no);
if(check==1&&id.length()==8){//判断在表S_LOGIN中是否有此登陆号
String pwd =jPasswordField1.getText();
String sql = "select * from S_LOGIN where SNO='"+id+"'";
ResultSet rs = dbUtil.executeQuery(sql);
//一个ResultSet对象对应着一个由查询语句返回的一个表,这个表中包含所有的查询结果,
try {
while(rs.next()){
if(rs.getString("PWD").trim().equals(pwd.trim())==true){//去掉空格之后判断密码是否相符
Student.main(null);//登陆成功调到Student面板进行成绩查询操作
jTextField1.setText("");
jPasswordField1.setText("");
}
else{
JOptionPane.showMessageDialog(null, "密码错误", null, JOptionPane.ERROR_MESSAGE);
}
}
}catch (Exception e) {
e.printStackTrace();
}
}
else if("".equals(no)){
JOptionPane.showMessageDialog(null, "请输入学号","提示", JOptionPane.INFORMATION_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"学号输入错误","提示",JOptionPane.INFORMATION_MESSAGE);
}
}
check类中的函数
public static int checkSno( String X)//判断登陆信息表中是否有此学号 有则返回1
{ DatabaseUtil dbUtil=new DatabaseUtil();
int num=0;
String sql = "select * from S_LOGIN";
ResultSet rs = dbUtil.executeQuery(sql);
try {
while(rs.next()){
if(rs.getString("SNO").trim().equals(X.trim())==true){//去掉空格之后判断是否相符
num=1;
}
}
}catch (Exception e)
{
e.printStackTrace();
}
return num;
}
D. java编写登陆注册页面(简单一点的,连接数据库)
这是我自己做的一个管理系统的登录界面,代码虽然有点繁琐,不过简单易懂,你根据自己的需要进行修改吧。
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JDialog;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
*
* @author mzhe
*
*/
class Loginfrm extends JDialog implements ActionListener
{
JLabel l_name,l_pass,l_error;
JTextField t_name;
JButton b_enter,b_cancle,b_clear;
JPanel pan1,pan2,pan3,pan4;
JPasswordField t_pass;
String sname,spass;
int sunit;
NetConn sql;
Statement sqll;
ResultSet rs;
Librarybox lbox;
int until=0;
Loginfrm(JFrame f,String s)
{
//界面布局
super(f,s);
l_name=new JLabel("名字:");
l_pass=new JLabel("密码:");
l_error=new JLabel("请输入用户名和密码登录");
t_name=new JTextField("",10);
t_pass=new JPasswordField("",10);
t_pass.setEchoChar('*');
b_enter=new JButton("确定");
b_enter.addActionListener(this);
b_cancle=new JButton("取消");
b_cancle.addActionListener(this);
b_clear=new JButton("清除");
b_clear.addActionListener(this);
pan1=new JPanel();
pan2=new JPanel();
pan3=new JPanel();
pan4=new JPanel();
pan1.add(l_name);pan1.add(t_name);
pan2.add(l_pass);pan2.add(t_pass);
pan3.add(l_error);
pan4.add(b_enter);pan4.add(b_cancle);pan4.add(b_clear);
setLayout(new GridLayout(4,1));
add(pan1);add(pan2);add(pan3);add(pan4);
//建立数据库连接
sql=new NetConn();
//设置窗口大小
setSize(300,300);
setVisible(false);
//得到屏幕信息以便使框架居中显示
Dimension screeSize = Toolkit.getDefaultToolkit().getScreenSize();
int screeWidth=screeSize.width;
int screeHeight=screeSize.height;
//得到框架的大小信息
Dimension frameSize=this.getSize();
int x=(screeWidth-frameSize.width)/2;
int y=(screeHeight-frameSize.height)/2;
this.setLocation(x, y);
}
public void actionPerformed(ActionEvent e)
{
//单击确定按钮的事件处理程序
if(e.getSource()==b_enter)
{
//如果连续登录次数小于4
if(until<=4)
{
//如果用户名或者密码为空,将显示提示信息
if(t_name.getText().equals("")||t_pass.getText().equals(""))
{
l_error.setText("用户名和密码不能为空");
}
else
{
try
{
sqll=sql.connect();
//根据用户名查询
rs=sqll.executeQuery("SELECT * FROM users where username="+"'"+t_name.getText()+"'");
//遍历查询得到的结果集
while(rs.next())
{
sname=rs.getString(2);
spass=rs.getString(3);
//得到登录用户的级别
sunit=Integer.parseInt(rs.getString(4));
//如果密码正确
if(t_pass.getText().equals(spass))
{
//判断用户的级别,根据不同的级别,显示不同的菜单
switch(sunit)
{
case 1:
{
l_error.setText("登录成功");
t_name.setText("");
t_pass.setText("");
lbox=new Librarybox();
lbox.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
lbox.setResizable(false);
lbox.bookfi.setEnabled(true);
lbox.bookse.setEnabled(true);
lbox.bookth.setEnabled(true);
lbox.bookfo.setEnabled(true);
lbox.mi_system_manger.setEnabled(true);
lbox.mi_system_login.setEnabled(false);
lbox.setVisible(true);
this.dispose();
break;
}
case 2:
{
l_error.setText("登录成功");
t_name.setText("");
t_pass.setText("");
lbox=new Librarybox();
lbox.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
lbox.setResizable(false);
lbox.bookfi.setEnabled(false);
lbox.bookse.setEnabled(false);
lbox.bookth.setEnabled(true);
lbox.bookfo.setEnabled(false);
lbox.mi_system_manger.setEnabled(false);
lbox.mi_system_login.setEnabled(false);
lbox.setVisible(true);
this.dispose();
break;
}
case 3:
{
l_error.setText("登录成功");
t_name.setText("");
t_pass.setText("");
lbox=new Librarybox();
lbox.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
lbox.setResizable(false);
lbox.bookfi.setEnabled(true);
lbox.bookse.setEnabled(false);
lbox.bookth.setEnabled(false);
lbox.bookfo.setEnabled(true);
lbox.mi_system_manger.setEnabled(false);
lbox.mi_system_login.setEnabled(false);
lbox.fi_msglabel_user.setEnabled(false);
lbox.setVisible(true);
this.dispose();
break;
}
}
}
else
{
l_error.setText("用户名或密码错误!");
until++;
}
}
}
catch(SQLException e2)
{
e2.printStackTrace();
}
}
}
//超出登录次数
else
{
l_error.setText("你已经超出登录次数");
t_name.setEnabled(false);
t_pass.setEnabled(false);
b_enter.setEnabled(false);
b_clear.setEnabled(false);
}
}
//单击清除按钮的事件处理程序
else if(e.getSource()==b_clear)
{
t_name.setText("");
t_pass.setText("");
l_error.setText("请输入用户名和密码登录");
}
//单击取消按钮的事件处理程序
else if(e.getSource()==b_cancle)
{
dispose();
}
}
}
如果你比较认可的话,请采纳吧,不给分也没关系。只希望对你有用。
E. 求Java 注册登录 连接到数据库的源代码。
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public final class JdbcUtils {
private static String url = "sun.jdbc.odbc.JdbcOdbcDriver";//我这是连ODBC数据库
private JdbcUtils() {
}
static {
try {
Class.forName(url);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
public static Connection getConnection() throws SQLException {
return DriverManager.getConnection("jdbc:odbc:my","","");//根据你自己本地的数据库修改
}
public static void free(ResultSet rs, Statement st, Connection conn) {
try {
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (st != null)
st.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (conn != null)
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
F. 求一个java注册登录的完整代码
public class Test extends JFrame
{
UserCertification uc;
String url;
Connection con;
public Test(String title)
{
setTitle(title);
uc=new UserCertification();
Container c=getContentPane();
c.setLayout(new BorderLayout());
c.add(uc,BorderLayout.CENTER);
setSize(400,250);
try
{
url="jdbc:odbc:aaa";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection(url);
uc.jtusername.setText("恭喜!数据库连接成功!");
}
catch(Exception e)
{
e.printStackTrace();
}
show();
}
public static void main(String args[])
{
Test test=new Test("登录界面");
test.addWindowListener(new MyWindowListener());
}
}
class UserCertification extends JPanel
{
G. 用JAVA编写一个用户或注册登录界面。请哪位高手能够写下具体的代码,谢谢
效果图
<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<title>先锋图书馆管理系统-登录</title>
<style>
*{
margin:0;
padding:0;
list-style:none;
}
#top{
width:1000px;
height:95px;
margin:0auto;
margin-top:25px;
}
#top_top{
width:1000px;
height:65px;
background:deepskyblue;
}
#top_top_left{
width:300px;
height:65px;
float:left;
}
#top_top_left>label{
width:200px;
height:65px;
color:white;
float:right;
}
#top_top_left>#a2{
padding-left:10px;
padding-top:20px;
font-size:16px;
}
#top_bottom{
width:1000px;
height:30px;
}
#top_bottom_left{
width:340px;
height:30px;
line-height:30px;
font-size:12px;
background:skyblue;
color:white;
text-indent:2em;
float:left;
}
#top_bottom_right{
width:660px;
height:30px;
line-height:30px;
font-size:12px;
color:blueviolet;
text-align:center;
float:right;
background:lightskyblue;
}
#content{
width:1000px;
height:600px;
margin:0auto;
background:#587FBA;
}
#content>#text{
width:1000px;
height:50px;
line-height:50px;
padding-top:100px;
font-size:36px;
font-family:"楷体";
font-weight:bold;
text-align:center;
}
#content>#login{
width:480px;
height:210px;
margin-top:20px;
margin-left:260px;
background:#85A0CB;
}
#content>#login>img{
float:left;
}
#content>#login>#select{
width:305px;
height:210px;
float:right;
}
#content>#login>#select>div{
width:230;
height:30px;
margin-left:30px;
}
#content>#login>#select>#d1{
margin-top:30px;
margin-bottom:3px;
}
#content>#login>#select>p{
font-size:14px;
margin-left:95px;
}
#bottom{
width:1000px;
height:35px;
line-height:35px;
margin:0auto;
background:deepskyblue;
text-align:center;
color:white;
}
</style>
</head>
<body>
<divid="top">
<divid="top_top">
<divid="top_top_left">
<imgsrc="img/test/a13.png"width="78px"height="65px"><labelid="a2">先锋图书馆系统管理平台</label>
</div>
</div>
<divid="top_bottom">
<divid="top_bottom_left">当前位置:首页>系统管理>登录</div>
<divid="top_bottom_right">当前时间:<labelid="lable"></label></div>
</div>
</div>
<divid="content">
<divid="text">欢迎登录先锋图书馆管理系统</div>
<divid="login">
<imgsrc="img/test/a14.png"width="175px"height="210px"/>
<formid="select">
<divid="d1">用户名: <inputtype="text"/></div>
<div>密 码: <inputtype="password"/></div>
<p>
<inputtype="radio"name="user"value="read"/>读者
<inputtype="radio"name="user"value="admin"/>管理员
</p><br/>
<p>
<inputtype="button"value="确定"style="width:50px;"onclick="put()"/>
<inputtype="reset"value="重置"style="width:50px;"/>
</p>
</form>
</div>
</div>
<divid="bottom">欣欣科技有限公司版权所有</div>
</body>
<scripttype="text/javascript"src="JQuery/jquery.js"></script>
<scripttype="text/javascript"src="js/GetCurrentTime.js"></script>
<script>
//验证用户名和密码
functionput(){
vard=$("#select>div>input");//获取用户名和密码
varname=d[0].value;
varpass=d[1].value;
varuser=null;
varr=document.getElementsByName("user");//获取用户类型
for(i=0;i<r.length;i++){
if(r[i].checked){
user=r[i].value;
}
}
//console.log(name+","+pass+","+user);//输出测试
if(user==null){
window.alert("请选择用户类型!");
}elseif(user=="admin"&&name!="admin"){
window.alter("用户名错误!");
}elseif(user=="admin"&&name=="admin"&&pass!="123456"){
window.alert("密码错误!");
}elseif(name=="admin"&&pass=="123456"&&user=="admin"){
window.location.href="work_02_welcome.html";//在js中在本页面中打开新链接
}else{
window.alert("用户名错误");
}
}
</script>
</html>
H. java编写一个用户注册及登录界面
mportjava.awt.HeadlessException;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.ImageIcon;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JPasswordField;
importjavax.swing.JTextField;
@SuppressWarnings("serial")
{
JLabellbl1=newJLabel("用户名:");
JLabellbl2=newJLabel("密码:");
JTextFieldtxt=newJTextField("admin",20);
JPasswordFieldpwd=newJPasswordField(20);
JButtonbtn=newJButton("登录");
JPanelpnl=newJPanel();
privateinterror=0;
publicMainFrame(Stringtitle)throwsHeadlessException{
super(title);
init();
}
privatevoidinit(){
this.setResizable(false);
pwd.setEchoChar('*');
pnl.add(lbl1);
pnl.add(txt);
pnl.add(lbl2);
pnl.add(pwd);
pnl.add(btn);
this.getContentPane().add(pnl);
btn.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
if("admin".equals(newString(pwd.getPassword()))){
pnl.removeAll();
JLabellbl3=newJLabel();
ImageIconicon=newImageIcon(this.getClass().getResource("pic.jpg"));
lbl3.setIcon(icon);
pnl.add(lbl3);
}
else{
if(error<3){
JOptionPane.showMessageDialog(null,"密码输入错误,请再试一次");
error++;
}
else{
JOptionPane.showMessageDialog(null,"对不起,您不是合法用户");
txt.setEnabled(false);
pwd.setEnabled(false);
btn.setEnabled(false);
}
}
}
});
}
publicstaticvoidmain(String[]args){
MainFramefrm=newMainFrame("测试");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setBounds(100,100,300,120);
frm.setVisible(true);
}
}
I. java注册登录代码并且登陆只有三次机会外加基本的增删改查登录注册退出的就好
啧啧啧,少年 你这想法很危险啊