Trying to find ResultSet empty or not - Error - please help
Purpose of the code : I am trying to see if the customer or user is in the database.
Error : Cannote convert boolean to resultset
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*"%><%@page import = "java.sql.ResultSet" %>
<%@page import = "java.sql.Connection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Getting Database Connection</title>
</head>
<body>
<%
ResultSet result = null ;
Connection connection1 = null;
try
String driverName1 = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName1);
String serverName = "localhost";
String portNumber = "1521";
String sid = "XE";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "SYSTEM";
String password = "password";
connection1 = DriverManager.getConnection(url, username, password);
out.println(connection1.isClosed());
String Name = request.getParameter("name");
String Age = request.getParameter("age");
int AgeConvert = Integer.parseInt(Age);
String ADR = request.getParameter("address");
String sqlInsert = " INSERT INTO ADDRESS (NAME,AGE,ADR) VALUES ('" + Name + "' , " + AgeConvert + ", '" + ADR +"')";
Statement stm = connection1.createStatement();
stm.execute(sqlInsert);
out.println(" User Created");
catch(Exception e )
out.println("User not created");
e.printStackTrace();
%>
<table>
<tr>
<td> <b>To search the User Please enter the name in the below box </b> </td>
</tr>
<tr>
<td> Name </td>
<td> <input type = "text" name ="userName" /> </td>
</tr>
<tr>
<td> <input type ="submit" value = "Search" /></td>
</tr>
</table>
<% ResultSet results = null ;
String userNameToBeSearched = request.getParameter("userName");
String sqlselect = " SELECT * FROM ADDRESS WHERE NAME ='"+userNameToBeSearched+"'";
Statement stm2 = connection1.createStatement();
results = stm2.execute(sqlselect);
if (results.next()) {
%>
<TABLE BORDER="1">
<TR>
<TH>Name</TH>
<TH>Age</TH>
<TH>Address</TH>
</TR>
<TR>
<TD> <%= results.getString(1) %> </TD>
<TD> <%= results.getInt(2) %> </TD>
<TD> <%= results.getString(3) %> </TD>
</TR>
</TABLE>
<%
} else
out.println("User not found");
%>
</body>
</html>
DrClap wrote:
jverd wrote:
Better still, use PreparedStatement and its parameters, rather than trying to escape/quote stuff yourself. I can't think of a single case where there's any good reason to use Statement rather than PreparedStatement. (Though I'm sure somebody will come up with one.)
Also, don't put Java code in a JSP. Certainly not DB access code. Icky bad.And don't leave your connection open after you've finished using it. Close it in a finally block to make sure it gets closed no matter what.
And you should be using a connection pool in a web application rather than repeatedly opening and closing connections. Let the container handle the pool and get your connections from it via JNDI.
There we go. That's the usual lot of bad practices, isn't it? I don't think we missed any......and I would like to add this...dont do these type of business logic in a jsp. It is just a view...these works are of controllers'. You should follow MVC rules unless you want to fell in some real problems .
Similar Messages
-
I have updated my iPhone to iOS6.1.3 today and lost all my photos and some data(messageies) I have tried iTunes back up but still not success, please help.
If your messages and photos weren't part of your backup, then they're gone.
Certainly you weren't foolish enough to update the iOS on your phone before importing your photos off your phone for safe keeping on your computer like you would do with any digital camera, were you? -
my device is iPhone 4s iOS 6.0.1
Make sure you select the correct encryption before you put the password in.
-
I can still receive icloud ( ME email address) emails fine. I have not changed my settings at all. I have however tried all the settings I can find on the support pages. PLEASE HELP. Nothing has changed. This suddenly just started happening around a month ago. To frustrate me apple does not seem to have a support email or any method to contact them with this issue to do with their email product. I have spent ages going through the apple support sites and I keep getting asked for an apple product to mark it against. I have no apple product as I am using a PC but I am accessing and using their email product. Is there even a phone number I can call? Surely there is a support area for their Email server issues. Can anyone help? It is driving me mad and causing me major issues. My outlook is Outlook 2010 on a windows 8 PC. As I have said it worked fine then one day decided to stop sending emails.
Thanks for your help.Hi - this problem is discussed here:
https://discussions.apple.com/thread/5375046?start=0&tstart=0 -
i am not able to update my iphone 4 ,when ever i tried to update it its show 1309 error...and at times 9006 error ,please help me ..
Hey alkarim2008,
If you are having an issue with being unable to update or restore your iPhone, I would suggest that you troubleshoot using the steps in this article -
Resolve iOS update and restore errors in iTunes - Apple Support
Thanks for using Apple Support Communities.
Happy computing,
Brett L -
hi i just bought my new iPhone 4s yesterday and when u opened it was not updated so when i tried SO MANY TIMES to update it on the devise and on my new mac it said that there was a unknown error please help me
Please tell us what kind of computer you have, what operating system and what version of iTunes. Not just "the latest version of iTunes", the exact version number.
-
i can not connect my i phon with my pc it shows athorised computer when i am trying to do authorised process the process done but again i connect my phon again show this errore please help me to solve my prob....
I have clicked on the connect button, but it brings up the same There is a problem connecting, and I have also tried SMB://
i tried pinging the ip address with in termial and it times out.
From my windows PC and I can access my MacBook Air just fine, -
i need the drivers for earl 2011 macbook pro 13 inch i7 4 gigs for windows 7 64 bits i tried downloading with bootcamp butt it never completes allways ends up with an error please help if any one has the drivers or knows were i can download them
Doug...
If you don't have it for reference, the manual might come in handy > US/Boot_Camp_Install-Setup.pdf
After it loads, Command + F to find information regarding the drivers. -
i have update my 3g software to 4.21 but its not working when it come to restoring firmware its show a error please help me out
That error shows up when a phone is jailbroken or you are trying to downgrade the iOS version. Neither of which is supported by apple.
-
my ipod generation 5 will not come out of recovery mode. i was simply updating my software and this happened. it will not let me restore it comes up with and error. please help, thanks.
Hey erinoneill24,
Thanks for using Apple Support Communities.
Sounds like you can't update your device. You don't mention an error that it gives you. Take a look at both of these articles to troubleshoot.
iPod displays "Use iTunes to restore" message
http://support.apple.com/kb/ts1441?viewlocale=it_it
If you can't update or restore your iOS device
http://support.apple.com/kb/HT1808?viewlocale=de_DE_1
If you started your device in recovery mode by mistake, restart it to exit recovery mode. Or you can just wait—after 15 minutes the device will exit recovery mode by itself.
Have a nice day,
Mario -
I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.
Send it as a PDF.
-
this is what my iphone 4 shows. iv tried switching off again and again, closing apps by double tapping the home button but still not working. please help.
is there any other method to download ios 6.1.2.
my phone is not being recognized by itunes on my new windows 8. neither its working on touch copy.
kindly help.
thankswell in thatcase, i need another help .
thanks for your instant reply.
i have currently bought a new laptop (windows 8) and my iphone is not being recognized by itunes.
because i have no backup on my previous laptop, i downloaded touchcopy but even touch copy is not recognizing my iphone. -
hi
i tried to update to ios 8.2 on my iphone 5s when message popup to me now my iphone not working, please help i dont want to lose my dataWhat is the exact text of the message you got? And did you not back up before you updated?
-
Whenever I go to facetime on my macbook air it says call failed. Both my WiFi and Facetime are connected. I tried turning my Facetime on, and off,yet it still does not work. please help.
Hey Ekfree95,
Thanks for the question, and great troubleshooting so far. The following article provides additional steps that may have to resolve your issue:
FaceTime for Mac: Troubleshooting FaceTime
http://support.apple.com/kb/TS4185
Thanks,
Matt M. -
Error: Javax.mail does not exist, please help
I have copies mail.jar and activation.jar in the classpath directory as instructed, then try to compile but got the below error: package javax.mail does not exist
please help.
G:\CRD>javac SendMailBean.java
SendMailBean.java:22: package javax.mail does not exist
import javax.mail.*; //JavaMail packages
^
SendMailBean.java:23: package javax.mail.internet does not exist
import javax.mail.internet.*; //JavaMail Internet packages
^
SendMailBean.java:43: cannot resolve symbol
symbol : class Session
location: class SendMailBean
Session l_session = Session.getDefaultInstance(l_props, null);
^
SendMailBean.java:43: cannot resolve symbol
symbol : variable Session
location: class SendMailBean
Session l_session = Session.getDefaultInstance(l_props, null);
^
SendMailBean.java:48: cannot resolve symbol
symbol : class MimeMessage
location: class SendMailBean
MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
^
SendMailBean.java:48: cannot resolve symbol
symbol : class MimeMessage
location: class SendMailBean
MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
^
SendMailBean.java:50: cannot resolve symbol
symbol : class InternetAddress
location: class SendMailBean
l_msg.setFrom(new InternetAddress(p_from)); // Set the From address
^
SendMailBean.java:53: package Message does not exist
l_msg.setRecipients(Message.RecipientType.TO,
^
SendMailBean.java:54: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_to, false));
^
SendMailBean.java:57: package Message does not exist
l_msg.setRecipients(Message.RecipientType.CC,
^
SendMailBean.java:58: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_cc, false));
^
SendMailBean.java:62: package Message does not exist
l_msg.setRecipients(Message.RecipientType.BCC,
^
SendMailBean.java:63: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_bcc, false));
^
SendMailBean.java:68: cannot resolve symbol
symbol : class MimeBodyPart
location: class SendMailBean
MimeBodyPart l_mbp = new MimeBodyPart();
^
SendMailBean.java:68: cannot resolve symbol
symbol : class MimeBodyPart
location: class SendMailBean
MimeBodyPart l_mbp = new MimeBodyPart();
^
SendMailBean.java:72: cannot resolve symbol
symbol : class Multipart
location: class SendMailBean
Multipart l_mp = new MimeMultipart();
^
SendMailBean.java:72: cannot resolve symbol
symbol : class MimeMultipart
location: class SendMailBean
Multipart l_mp = new MimeMultipart();
^
SendMailBean.java:83: cannot resolve symbol
symbol : variable Transport
location: class SendMailBean
Transport.send(l_msg);
^
SendMailBean.java:98: cannot resolve symbol
symbol : class MessagingException
location: class SendMailBean
} catch (MessagingException mex) { // Trap the MessagingException Error
^
19 errorsAnother person who doesn't understand how to set CLASSPATH.
Move those JARs into the same directory as your SendMailBean.java and do it like this:
javac -classpath .;mail.jar;activation.jar -d . *.java
java -classpath .;mail.jar;activation.jar SendMailBeanRead how to set CLASSPATH properly:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
Maybe you are looking for
-
Does anyone know how to upgrade from 4.1 to 4.3 ios?
After being tricked by the fast talking smoothy helper at Apple store in London to buy a micky mouse ipodtouch (fourth generation) two years ago I am stuck at ios 4.1 and find that all the useful applications need 4.3 or more. So I went to the troubl
-
Subcontracting Process with Customer owned stock
We are looking for SAP supported process where the customer sends us components along with a sales order for a finished good. The components have to be received into customer owned stock and will be used (for instance as part of the BOM) to produce t
-
Modify Self Profile in Request Failed status
Hi, I have requiement to allow user to update his few details though Self-Service>My Profile> Attributes Update . System trigers an OOB approval to System Administrator for the Modify Self Profile , and on approval of task the attributes are getting
-
From Photoshop CS6, How do I render multiple files to Media Encoder when editing Video?
I'm trying to send one version of my video open in PS CS6 to Media Encoder at 1920x1080 then while that renders, I'd like to crop it and render it as 1440x1080. Is there a faster way to to this? Ideally I'd like to Send it to ME rather than Export ri
-
CS6: how to update 12.0 to 12.2? [was: cs6 1200 updates]
Hello I have cs6 Version 12.0 build 5861 I understand there is a later version 12.2 Build 6006. According to Help Updates the applications are all up to date. Can anyone say how I can get the latest updates please? Thank you John