URGENT! Having problem with while statement and other syntax errors
I am trying to teach myself JSP for a school project due very soon. But I keep receiving errors surrounding my while statement. The errors are:
Syntax: ";" inserted to complete BlockStatements
Syntax: "}" inserted to complete Block
I have checked it over and over again, comparing against other examples found in this forum and against servlet examples and I can see no difference. This is my file for your information. It is supposed to list all the users in the user table. Is there a simpler way to do this?
regards
rach
<%@ page language="java" import="java.sql.*, java.util.*"%>
<html>
<head>
<title></title>
</head>
<body>
<%! String selected = null; %>
<%
try{
// Connect to the database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:odbc:dbtest");
catch(ClassNotFoundException e) {
System.out.println("Database driver could not be found.");
System.out.println(e.toString());
throw new UnavailableException(this, "Database driver class not found");
try{
//create SQL statement
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from USER ORDER BY User_lastname, User_firstname");
catch(SQLException e){
System.out.println("Error connecting to the database.");
System.out.println(e.toString());
throw new UnavailableException(this, "Cannot connect to the database");
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10"> </td>
<td width="200" valign="top" align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td><form method="post" action="userupdatedelete.jsp" target="content" name="userlist">
<h2>Users</h2>
</td>
</tr>
<tr>
<td width="10"> </td>
</tr>
<tr>
<td valign="top"><select size="15" name="rec">
<!-- if the resultset is not null -->
<% try {
//if (rs.next()) {
While (rs.next()){
//retrieve data from User table
String userid = rs.getString("User_ID");
String firstname = rs.getString("User_firstname");
String lastname = rs.getString("User_lastname");
out.println("<option value='userid'>lastname + ', ' + firstname</option>");
//<option value="<%=userid%>"><%=lastname + ", " + firstname%></option>
//else {
// out.println("<option> - No Users Entered - </option>");
//<option> - No Users Entered - </option>
stmt.close();
con.close();
catch (SQLException ex){
System.err.print("SQL Exception :");
System.err.println(ex.getMessage());
%>
</select>
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="Update/Delete"></td>
</tr></form>
<tr>
<td><br></td>
</tr>
<tr>
<td align="center">
<form method="post" action="useraddform.jsp" name="addbuttonform">
<input type="submit" value=" Add New " name="addnew">
</tr></form>
</table>
</td>
<td width="10"> </td>
</tr>
</table>
</body>
</html>
There is a problem here with the "scope" of variables namely your variables "rs" and "stmt". Variables declared within a try block are available only within that try block. Also, the type for stmt is not even given.
Change:
try{
//create SQL statement
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from USER ORDER BY User_lastname, User_firstname");
catch(SQLException e){
System.out.println("Error connecting to the database.");
System.out.println(e.toString());
throw new UnavailableException(this, "Cannot connect to the database");
}to:
Statement stmt = null;
ResultSet rs = null;
try
//create SQL statement
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * from USER ORDER BY User_lastname, User_firstname");
catch(SQLException e)
System.out.println("Error connecting to the database.");
System.out.println(e.toString());
throw new UnavailableException(this, "Cannot connect to the database");
Similar Messages
-
Q since upgrade to iOS6 l have been having problem with wifi connection and getting into App Store and itunes
Saw this on another post.
Applecare Senior Advisor Txx Bxxx (I have his contact info in an email he just sent) just confirmed with me that the problem people are having with the App Store not loading is an apple issue with there servers, ITS NOT YOUR IPAD so don't go restoring it! It's not happening to everyone however but they are looking into it, its really hit or miss.
In the meantime ...........
The Complete Guide to Using the iTunes Store
http://www.ilounge.com/index.php/articles/comments/the-complete-guide-to-using-t he-itunes-store/
Can't connect to the iTunes Store
http://support.apple.com/kb/TS1368
iTunes: Advanced iTunes Store troubleshooting
http://support.apple.com/kb/TS3297
Best Fixes for ‘Cannot Connect to iTunes Store’ Errors
http://ipadinsight.com/ipad-tips-tricks/best-fixes-for-cannot-connect-to-itunes- store-errors/
Try this first - Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
This works for some users. Not sure why.
Go to Settings>General>Date and Time> Set Automatically>Off. Set the date ahead by about a year.Then see if you can connect to the store.
~~~~~~~~~~~~~~~~
iOS 6 Wifi Problems/Fixes
Fix For iOS 6 WiFi Problems?
http://tabletcrunch.com/2012/09/27/fix-ios-6-wifi-problems/
Did iOS 6 Screw Your Wi-Fi? Here’s How to Fix It
http://gizmodo.com/5944761/does-ios-6-have-a-wi+fi-bug
How To Fix Wi-Fi Connectivity Issue After Upgrading To iOS 6
http://www.iphonehacks.com/2012/09/fix-wi-fi-connectivity-issue-after-upgrading- to-ios-6.html
iOS 6 iPad 3 wi-fi "connection fix" for netgear router
http://www.youtube.com/watch?v=XsWS4ha-dn0
Apple's iOS 6 Wi-Fi problems
http://www.zdnet.com/apples-ios-6-wi-fi-problems-linger-on-7000004799/
~~~~~~~~~~~~~~~~~~~~~~~
Look at iOS Troubleshooting Wi-Fi networks and connections http://support.apple.com/kb/TS1398
iPad: Issues connecting to Wi-Fi networks http://support.apple.com/kb/ts3304
WiFi Connecting/Troubleshooting
http://www.apple.com/support/ipad/wifi/
How to Fix: My iPad Won't Connect to WiFi
http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-My-Ipad-Wont-Connect -To-Wi-Fi.htm
iOS: Connecting to the Internet
http://support.apple.com/kb/HT1695
iOS: Recommended settings for Wi-Fi routers and access points http://support.apple.com/kb/HT4199
Additional things to try.
Try this first. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
Another thing to try - Go into your router security settings and change from WEP to WPA with AES.
How to Quickly Fix iPad 3 Wi-Fi Reception Problems
http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
If none of the above suggestions work, look at this link.
iPad Wi-Fi Problems: Comprehensive List of Fixes
http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
Fix iPad Wifi Connection and Signal Issues http://www.youtube.com/watch?v=uwWtIG5jUxE
Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
Unable to Connect After iOS Update - saw this solution on another post.
https://discussions.apple.com/thread/4010130
Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
~~~~~~~~~~~~~~~
If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
Cheers, Tom -
I'm having problems with 8.1 and Continuity / Handoff. It will work fine for web pages, etc. but in email when I try to do it between by iPhone 5s running 8.1 and my Macbook Pro running Yosemite I consistently get an error. "Failed to Continue Activity" Cocoa Error 4609. Handoff is working for phone calls and text messages. By email just crashes each time. It was also doing it under 8.0.2. My iPhone and iPad handle this fine. It's only the MacBook to the iPhone that fails, and only on email.
Handoff Continuity Troubleshooting
-
Having problems with ipad mini and Siri. Works sporadically, will work once and then the second time not. Worked all the time with the original Mailbox app. Then started doing the same thing when I installed the new update so wondering if it is software?
Hi,
I have the check box on a second Partition but not on the Time Machine one
I forget what I did now to get this called "Recovery HD"
For the rest try https://discussions.apple.com/docs/DOC-4055 User Tip that links to Pondini's work on Time Machine.
10:17 pm Friday; May 2, 2014
iMac 2.5Ghz i5 2011 (Mavericks 10.9)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad -
I'm having problems with iPad 2 and my smart cover. The attachment seems to be depolarized, trys to connect using the back (curved) edge of the magnetized bracket. When I try to attach it, it moves around causing the device to toggle in a way that looks like the camera flash. Anyone having problems? Help.
Update. My carrier says the antenna of my iPhone 4s is not so good as the one in the iPhone 3G. They can't solve the problem. Their signal is too weak for the 4s at places I spend most of my time. Not the answer I expected, but I'm free to choose an other carrier. Hope this will help.
This was not the correct answer, I accidentially clicked the button..
Message was edited by: vasch -
hi im having problems with my internet and email Ive reset the network even with my WiFi on Ive also turned off and on airplane mode help please thank you
hi Ive reset my network toggled the airplane on and off and turned off my carrier off then turned my phone off and turned my carrier back on but still problem persists
-
I am having problems with Time Machine and having enough space to finish my last back up.
I am having problems with Time Machine and having enough space to finish my last back up.
Take a look at this link, http://support.apple.com/kb/HT1427
-
I installed Lion and now seem to have problems with Microsoft Silverlight and other plug ins and applications. I haven't ever used time machine to back up (my bad I know). Is there a way to go back to snow leopard with messing up all my files and my set?
Are you using the latest version of Silverkeeper? - v.2.0.2 is stated to be compatible with Snow Leopard.
http://www.lacie.com/silverkeeper/
If it's messing things up you could try asking LaCie Support for assistance. -
Problem with BT Netprotect (and other things)
We are having problems with various things on our laptop today (Friday), including with BT Netprotect. I am wondering if it is something to do with the recent Windows security updates.
I want to run a scan with BTNP but when I double click on the red icon a blank white box appears, although according to Task Manager BTNP is running.
Does anyone have any ideas on what is happening and what I can do? Other problems today are with Google Maps, Youtube and BBC iPlayer (iPlayer tells me Javascript isn't enabled although it is).
Best wishes
DavidI don't know if your recent updates have caused a problem but I do know that BTNetprotect has and does cause problems on some computers. It is also a resources hog and slows your computer down. The general opinion on this forum is to uninstall it and install another antivirus such as Microsoft Security Essentials or AVG Free or Avast free.
If you do want to uninstall it follow this link. Also with regards to the specific problem you are having with it I would recommend uninstalling it fully then if you still want it on your computer, reinstall it. This usually sorts out most of its problems at least for a short while.
http://bt.custhelp.com/app/answers/detail/a_id/13523/~/i-don%27t-want-bt-netprotect-plus-anymore.-ho...
Make sure you follow all the guide including restarting your computer and running the McAfee removal tool. Once you have done that check to see if your other problems are still there and if so report back to the forum and we'll see if we can help. -
Anyone NOT having problems with ITunes 8 and latest firmware update???
I have really been put off updating to ITunes 8. The firmware update appears to be doing well. Is there anyone that uses a MacBook like myself who have had absolutely NO problems with new Itunes and firmware update? Answers on the back of a £50 note....
Not having issues now that I have updated all i(hardware) firmware to version 2.1, two phones and an iPod Touch, all work fine (So Far) (knocking on wood). As far as iTunes goes I have mixed feelings. It's a bit faster and more stable, however they removed the "Burn CD" ability from the software. That blows a bit as I would make CD's from some of my play lists to play in the car. Yes I can dock my devices in the car, but as a matter of convenience it's easier to fire up the CD when your in a rush.
-
Im having problems with my illustrator , and i don't know how to fix it?
hey, guys. um my illustrator is having this problem with the navigator . and its makiing this fat lines and when i click the line on the little box in the bottom
and put it at 100 % it comes out like this
all small and i dont understand why is doing this.
can tou guys please help me with this i have a big project due and i cant work with this like it is ...>!!!!!You can change your artboard size without having to make a new document.
1. Click on the Artboard Tool
2. In the top menu, you can type new dimensions. Make sure to type in the correct units! -
Having problems with front row (and the opticle drive)
I bought my macbook three days ago, and I'm already having problems. First off, I transfered music from my user profile on my old iMac G5 to the macbook via data DVD. My music collection had some purchaces from the itunes store, so I had to go through the authorization thing, and I can now play them just fine in the iTunes library, but the problem is, if I try to use the front row program to play my purchaced music, I get the message saying that I have to authorize it first. What the ****? Does anybody else have this problem? Also, like many other macbook users, I'm having problems with the opticle drive, such as getting cds to be recognized and other things of that nature.
I noticed that this problem started after I tried to use a software to unlock my drive's region...
I believe this is the problem. The VLC Media Player will usually play DVDs from other regions without changing the settings on your optical drive. You may need to reset your optical drive's firmware back to the original setting, make sure you have the region set for the one you'd prefer to use the most and then use VLC to play the other DVDs.
-Doug
P.S. After two years in the Front Row forum, I'm not sure I've ever heard of anyone playing HDDVD_TS folders with Front Row. I'm not saying it won't work, but I'm not sure it's really supported either. I do have DVD Studio Pro myself, but I'll have friends or family staying with me for nearly the next month, so my evenings and weekends will be a bit full to try making one up for testing... -
I have a windows 7 premium laptop, 64 bit driver, have tried to install itunes but recieve an error when trying to open. Error states "Apple Application Support is required to run itunes. uninstall and reinstall again, error 2 (windows error 2). have tried this 4-5 times with no success. help!
For general advice see Troubleshooting issues with iTunes for Windows updates.
The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
The section Install missing components has advice on breaking down the iTunes installer into the individual .msi files which might prove useful if AAS won't install normally.
tt2 -
Problem with while statement :(
i am having a problem with my while statement, can anyone help me to get it working :(
i am trying to get the while statement to only run when the input hasnt been a yes or a no, can someone please help me.
System.out.print("Are you a Resident? (yes/no): ");
Resident = console.next(); //Requests resident status from user and puts in in Resident
while ((Resident != "yes") && (Resident != "no"))
System.out.print("error - You didnt type yes or no. Try again: ");
Resident = console.next();
}while ((Resident != "yes") && (Resident != "no"))Don't compare Strings with ==, use the equals() method instead.
while(!("yes".equals(Resident) && "no".equals(Resident))) -
Problem with PIVOT statement and ORA-56901
Hi,
I am having a problem with PIVOT in Oracle.
I have a view in an oracle 11g database
that returns me data in the format:- (... indicates left out text)
DefinitionID ... AttributeValue FieldID
============ ============== =======
... 3000 X30a9...
... JohnN X4674...
I am then trying to use a PIVOT statement to hopefully give me data
in the format
COLUMN1 COLUMN2
======= =======
JohnN 3000
The PIVOT statement I am trying is
SELECT X4674... AS Column1,
X30A9... AS COLUMN2
FROM (SELECT instanceid, definitionid, attributevalue, FIELDID
FROM PI_ENTITY_INSTANCE_VIEW) up PIVOT (MAX(ATTRIBUTEVALUE)
FOR FIELDID IN (X4674...,X30A9... ) )
where definitionid = hextoraw('7353C67A56C74B5A8234CD16064399E8')
I have used a very similar VIEW and PIVOT statement for sql server
(with necessary changes for Oracle applied) and the
data returns in SQL Server as expected.
Unfortunately I am getting the Oracle error
ORA-56901: non-constant expression is not allowed for pivot|unpivot values
Is there anyway to get a PIVOT working on Oracle where I use the
fieldid's like I do above or is there some other way to supply the vales to the
IN clause to overcome this error?
Thank you for any help you can provide
John NugentHi, John,
Welcome to the forum!
X4674, X30A9 and os on are the literal values that you're looking for, right?
In Oracle, string literals need to be enclosed in single-quotes, like this:
FOR FIELDID IN ('X4674', 'X30A9') You might find it more convenient to assign column aliases in the PIVOT clause, like this:
PIVOT ( MAX (attributevalue)
FOR fieldid IN ( 'X4674' AS column1
, 'X30A9' AS column2
) Remember that anything inside quotes is case-sensitive, so 'X30A9' is not equal to 'X30a9'. Use UPPER (or LOWER) to do case-insensitive string comparisons.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
If you can use commonly available tables (such as those in the scott or hr schemas) to show your problem, then you don't have to post any sample data; just the results and explanation.
Always say which version of Oracle you're using. You did say you were using Oracle 11g, but there's no 11f or 11h, and sometimes the difference between, say 11.1 and 11.2 can be significant. Why not say exactly what you're using, e.g. 11.1.0.7.0?
You'll get better answers faster if you always supply this information whenever you post a question.
Edited by: Frank Kulash on Sep 22, 2011 2:09 PM
Added allliterative alias alternative
Edited by: Frank Kulash on Sep 22, 2011 4:04 PM
Maybe you are looking for
-
How do i delete .lock video files on my iMac in final cut pro
I'm trying delete video files in Final Cut Pro X but they come with cant delete because of .lock how can i get rid of these?
-
Urgent help with PIX 520 & downgrade to 4.X ver.
Hi all, I need help with the problem which occured recently my colleague.We had got PIX 520 with ver 6.x. But my colleague inserted into floppy disc drive floppy with ver. 4.4.7 and rebooted PIX. And it downgraded PIX OS. From that time we cannot boo
-
Triggering an HTTP to file scenario using UDF
Hi, Is it possible to trigger an http to file scenario from UDF? If it is possible can anyone tell me how it can be acheived. regards, Meenakshi
-
TPETRAN - error starting transaction" gwerrno(402017)
I'm making a TPCALL(TOUPPER, TypedString, 0) to tuxedo through WTC on WebLogicServer8.1. Below is the error from ULOG on Tuxedo side. LIBGW_CAT:1029: ERROR: Service request not forwarded to remote site:"TPETRAN - error starting transaction" gwerrno(4
-
[SOLVED] Help with some warning messages regarding permissions.
Hey, I received these warnings from pacman during an upgrade: [2010-02-20 13:24] warning: directory permissions differ on var/run/gdm/ filesystem: 1775 package: 1777 [2010-02-20 13:24] warning: directory permissions differ on var/log/gdm/ filesystem