"
小弟我ssh远程登录mysql服务器,由于服务器没设密码,直接mysql -uroot就能进去
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1380
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
可是在里面建库的时候就报错:mysql> create database vpn;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'vpn'
想问下各位大虾如何解决阿!
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
"<pre class=""brush:java; toolbar: true; auto-links: false;"">import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class ConnectionDemo02{ //public ConnectionDemo02 conn; public static final String DBDRIVER="org.gjt.mm.mysql.Driver"; public static final String DBURL="jdbc:mysql://localhost:3306/wxf"; public static final String DBUSER="root"; public static final String DBPASS="26533621"; public Connection getConn(){ Connection conn=null; try{ Class.forName(DBDRIVER); }catch (ClassNotFoundException e){ e.printStackTrace(); } try{ conn=DriverManager.getConnection(DBURL,DBUSER,DBPASS); }catch(SQLException e){ e.printStackTrace(); }
return conn;
}
} <pre class=""brush:java; toolbar: true; auto-links: false;""> <pre class=""brush:java; toolbar: true; auto-links: false;"">import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date;
public class Login { PreparedStatement ps = null; ResultSet rs = null; Connection conn = null;
public boolean verify(String name,String password ) {
boolean result=false;
String sql = "select * from usekey where idcard=? and password=?";
Connection con = new ConnectionDemo02().getConn();
try {
ps = con.prepareStatement(sql);
ps.setString(1, name);
ps.setString(2, password);
rs = ps.executeQuery();
if (rs.next()) {//验证成功
result=true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (rs != null)
rs.close();
if (ps != null)
ps.close();
if (conn != null)
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return result;
}
}
高手们 没人知道么 帮帮小弟啊 卡了快1周了
######首先我明白为什么有三个main方法,一个java程序main方法是一个入口,应该只有一个,对于这里来讲main方法就应该是new出你的登录界面denglu dl=new denglu();了,另外你没有给登录这个button注册事件,他当然什么都不做了,大致的流程是这样,main中new出登录窗口,登录按钮注册点击事件,然后在注册的方法中连接数据库检测帐号和密码是否与用户输入的匹配,如果正确就展示用户界面。######这个我知道 我就是写了监听了 一直错 然后一气之下都删掉了 然后看看能不能帮我写一段对的 只是确定的监听验证账号密码代码就好######import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.awt.geom.*;
import java.util.Vector;
public class denglu extends JFrame {
public Label name = new Label("用户名");
public Label pass = new Label("密码");
public TextField txtname = new TextField();
public TextField txtpass = new TextField();
public Button btok = new Button("登陆");
public Button btexit = new Button("取消");
public denglu() {
setTitle("欢迎使用工资管理系统");
setLayout(null);
setResizable(false);
setSize(500, 350);
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frm = this.getSize();
setLocation((scr.width - frm.width) / 2,
(scr.height - frm.height) / 2 - 18);
txtpass.setEchoChar('*');
name.setBounds(70, 260, 40, 27);
pass.setBounds(70, 300, 40, 27);
txtname.setBounds(120, 260, 120, 27);
txtpass.setBounds(120, 300, 120, 27);
btok.setBounds(340, 260, 100, 28);
btexit.setBounds(340, 300, 100, 28);
add(name);
add(txtname);
add(pass);
add(txtpass);
add(btok);
add(btexit);
setVisible(true);
btok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
if (验证用户名和密码通过) {
denglu.this.dispose();
new yonghu().init();
}
}
});
}
public static void main(String args[]) {
denglu dl = new denglu();
}
}
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
public class yonghu {
public void init() {
JFrame jf = new JFrame();
jf.setTitle("aaa");
jf.setBounds(300, 250, 300, 200);
jf.setVisible(true);
}
}