private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: MyConnection mc = new MyConnection();
String username = jTextField1.getText().trim();
String userpass=new String(this.jPasswordField1.getPassword());
try{
if(username.equals("")||userpass.equals("")){
message.setText("用户名和密码不能为空!!!"); }
Connection conn = null;
PreparedStatement pstatm = null;
CallableStatement cstatm = null;
//ResultSet rs = null;
conn = mc.getConnection();
cstatm = conn.prepareCall("{call user_id_name(?,?)}"); cstatm.setString(1,username);
cstatm.setString(2,userpass);
cstatm.registerOutParameter(2, Types.VARCHAR); //注册
int flag = pstatm.executeUpdate();
if(flag!=0){
System.out.println("成功");
} }catch(SQLException e){
e.printStackTrace(); }
}
我建了个存储过程 就是set 不进去值 实在找不出错误了 那位高手 帮忙指点哈 谢谢了
// TODO add your handling code here: MyConnection mc = new MyConnection();
String username = jTextField1.getText().trim();
String userpass=new String(this.jPasswordField1.getPassword());
try{
if(username.equals("")||userpass.equals("")){
message.setText("用户名和密码不能为空!!!"); }
Connection conn = null;
PreparedStatement pstatm = null;
CallableStatement cstatm = null;
//ResultSet rs = null;
conn = mc.getConnection();
cstatm = conn.prepareCall("{call user_id_name(?,?)}"); cstatm.setString(1,username);
cstatm.setString(2,userpass);
cstatm.registerOutParameter(2, Types.VARCHAR); //注册
int flag = pstatm.executeUpdate();
if(flag!=0){
System.out.println("成功");
} }catch(SQLException e){
e.printStackTrace(); }
}
我建了个存储过程 就是set 不进去值 实在找不出错误了 那位高手 帮忙指点哈 谢谢了
String username = jTextField1.getText().trim();
String username = jTextField1.getText();
if (username!=null){
username = username.trim();
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: MyConnection mc = new MyConnection();
String username = jTextField1.getText();
if(username!=null){
username = username.trim();
}
String userpass=new String(this.jPasswordField1.getPassword());
try{
if(username.equals("")||userpass.equals("")){
message.setText("用户名和密码不能为空!!!"); }
Connection conn = null;
PreparedStatement pstatm = null;
CallableStatement cstatm = null;
//ResultSet rs = null;
conn = mc.getConnection();
cstatm = conn.prepareCall("{call user_id_name(?,?)}"); cstatm.setString(1,username);
cstatm.setString(2,userpass);
cstatm.registerOutParameter(2, Types.VARCHAR); //注册
int flag = pstatm.executeUpdate();
if(flag!=0){
System.out.println("成功"); }
if(cstatm.getString(2).equals("128080")){
message.setText("登录成功"); }else{
message.setText("登录失败"); } }catch(SQLException e){
e.printStackTrace(); }
} private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
} /**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Userframe().setVisible(true);
}
});
}
楼上回答的问题 应该不是 我觉的 那是等效的