📄 userid.java~1~
字号:
package untitled5;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.lang.*;
import javax.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class userid extends Applet {
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
//Initialize the applet
public void init() {
jLabel1.setText("姓名");
this.setLayout(xYLayout1);
jTextField1.setText("");
jLabel2.setText("密码");
jButton1.setText("登录");
Font font=new Font("宋体",Font.PLAIN,12);
add(jLabel1, new XYConstraints(13, 94, -1, 22));
add(jTextField1, new XYConstraints(34, 94, 78, 25));
add(jLabel2, new XYConstraints(114, 94, -1, 22));
add(jTextField2, new XYConstraints(137, 94, 73, 25));
add(jButton1, new XYConstraints(209, 94, -1, 26));
}
public boolean handleEvent(Event e)
{ if(e.id==Event.ACTION_EVENT)
{ if(e.target==jButton1)
{
validID();
return true;
}
}
return false;
}
void validID(){
try{
String str1,str2;
str1=jTextField1.getText();
str2=jTextField2.getText();
//装载jdbc驱动程序
String driverName="oracle.jdbc.OracleDriverZ";
Driver driver=(Driver)Class.forName(driverName).newInstance();
//连接数据库
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@thsspc0791:1521:tongfang","sa","tongfang");
PreparedStatement pstmt=con.prepareStatement(" select * from first where id=? ");
pstmt.setString(1,str1);
ResultSet res=pstmt.executeQuery();
if(res.getString("password")==null)
{ JOptionPane.showMessageDialog(this ,"查无此人","错误",JOptionPane.ERROR_MESSAGE); }
else
{
if(res.getString("password")!=str2)
{
}
else{
while(res.next())
System.out.println(res.getString(1));
loader();
}
}
pstmt.close();
con.close();
}
catch(Exception edd){
}
}
void loader()
{ try{
URL url;
url = new URL("e:\\");
this.getAppletContext().showDocument(url);
}
catch(Exception ew){
}
}
class ValidFailedException extends SQLException{
public ValidFailedException(){
}
public ValidFailedException(String reason){
super(reason);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -