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注冊登錄代碼並且登陸只有三次機會外加基本的增刪改查登錄注冊退出的就好
嘖嘖嘖,少年 你這想法很危險啊