By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

error occurred: Can not issue SELECT via executeUpdate()

P: 2
Expand|Select|Wrap|Line Numbers
  1. package com;
  2.  
  3. import com.opensymphony.xwork2.ActionSupport;
  4. import java.sql.*;
  5.  
  6.  
  7. /**
  8.  * <p> Validate a user login. </p>
  9.  */
  10. public  class retrieve  extends ActionSupport 
  11. {
  12.  
  13.       public String execute() throws Exception 
  14.       {          
  15.           String url = "jdbc:mysql://localhost:3306/";
  16.           String dbName = "login";
  17.           String driverName = "com.mysql.jdbc.Driver";
  18.           String userName = "root";
  19.           String passWord = "12345";
  20.           Connection con=null;
  21.           Statement stmt=null;
  22.           try{
  23.           Class.forName(driverName).newInstance();
  24.           con=DriverManager.getConnection(url+dbName, userName, passWord);
  25.           stmt=con.createStatement();
  26.           }
  27.           catch(Exception e){
  28.           System.out.println(e.getMessage());
  29.           }
  30.           String username=getUsername();
  31.           String password=getPassword();
  32.           stmt = con.createStatement();
  33.           int val = stmt.executeQuery("SELECT USERNAME , password FROM employee WHERE username='admin' AND password ='admin' Values ('"+username+"','"+password+"')");
  34.           if(val == 0)
  35.           {
  36.                   return ERROR;
  37.           }
  38.           else
  39.           {
  40.               return SUCCESS;
  41.           }
  42.       }
  43.       // ---- Username property ----
  44.  
  45.       private String username;
  46.       public String getUsername() 
  47.       {
  48.           return username;
  49.       }
  50.  
  51.       private String password;
  52.       public String getPassword()
  53.       {
  54.           return password;
  55.       }
  56.  
  57. }


Above is my code .. please help me in debugging this ASAP
Nov 4 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.

Browse more MySQL Database Questions on Bytes