473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

error occurred: Can not issue SELECT via executeUpdate()

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
0 1766

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

Similar topics

1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
1
by: Angel | last post by:
I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile. I try to read the information with this code: string...
2
by: slylos | last post by:
I've got a C# windows app that passes a Dataset to a webservice, which handles the DB operations. Intermittenly, I get "System.Web.Services: The underlying connection was closed; an unexpected...
1
by: Marco Gerlach | last post by:
Hello, on one of our customers servers we get following error on first ASPX-page: An error occurred while try to load the string resources (GetModuleHandle failed with error -2147023888) ...
1
by: campwes | last post by:
Hey, all! We're having trouble displaying SQL Server data in a web site as XML, using a transform. The query is a simple SELECT statement. When running the query, we get the following error from...
5
by: Vijayakrishna Pondala | last post by:
Hi, We are using the following error randomly, when accessing a webservice method/servlet hosted on JBoss application server: The underlying connection was closed: An unexpected error occurred...
6
by: Yoel | last post by:
Hi, I'm trying consuming web services over SSL by an ASP .Net client without success. System Architecture: My Server side contains the following layers, starting from the client side: ...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
0
by: Brent | last post by:
I've written a bit of .Net 1.1 code to download data from a Web Service over SSL. The code works fine on Windows XP machines, but fails on Windows Vista with the error, "The underlying connection...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.