java数据库报错String sql="select user,password,type, from student where user=? and password=?
YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfo...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from student where user=? and password=?' at line 1
部分源代码:
public void actionPerformed(ActionEvent e) {
String user=jtfUser.getText();
student yu=null;
if (e.getSource() == jbtOk) {
if (jtfUser.getText().equals("") || jtfPass.getText().equals("")) {
if (JOptionPane.showConfirmDialog(this, "用户ID和密码不能为空!", "退出界面",JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION);
} else {String sql="select user,password,type, from student where user=? and password=? and type=?";
PreparedStatement stmt=null;
ResultSet re=null;
try {
stmt=conn.prepareStatement(sql);
stmt.setString(1,user);
re=stmt.executeQuery(sql);// 调用db.JdbcConnection类中的executeQuery()方法,返回单个结果集
if (re.next()) // 调用next()指针从当前位置下移一行
{
if(jcbUserType.getSelectedItem().equals("学生"))
right = 2; // 学生用户权限为2
else if(jcbUserType.getSelectedItem().equals("教师"))
right = 1; // 教师用户权限为1
else if(jcbUserType.getSelectedItem().equals("教务管理员"))
right = 0; // 教务管理员为0
大神。。。求帮忙啊。,数据库建立了的 展开
部分源代码:
public void actionPerformed(ActionEvent e) {
String user=jtfUser.getText();
student yu=null;
if (e.getSource() == jbtOk) {
if (jtfUser.getText().equals("") || jtfPass.getText().equals("")) {
if (JOptionPane.showConfirmDialog(this, "用户ID和密码不能为空!", "退出界面",JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION);
} else {String sql="select user,password,type, from student where user=? and password=? and type=?";
PreparedStatement stmt=null;
ResultSet re=null;
try {
stmt=conn.prepareStatement(sql);
stmt.setString(1,user);
re=stmt.executeQuery(sql);// 调用db.JdbcConnection类中的executeQuery()方法,返回单个结果集
if (re.next()) // 调用next()指针从当前位置下移一行
{
if(jcbUserType.getSelectedItem().equals("学生"))
right = 2; // 学生用户权限为2
else if(jcbUserType.getSelectedItem().equals("教师"))
right = 1; // 教师用户权限为1
else if(jcbUserType.getSelectedItem().equals("教务管理员"))
right = 0; // 教务管理员为0
大神。。。求帮忙啊。,数据库建立了的 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询