Trying to use a rs and a executeUpdate in same method
Essentially I am trying to take a piece of data, add to that data, then update the database with the new value. I am also trying to apply it across multiple rows. When I run the program it iterates once. in trouble shooting I definitely narrowed it down to a conflict I dont completely understand. I get the following error statement, but I havent closed the rs in the code. If I take out the executeUpdate() I can print out all the rows that would otherwise be affected, but I cant run my update.
"Problem with training program: java.sql.SQLException: Operation not allowed after ResultSet closed"
suggestions? I modified the switch conditional for simplicity sake.
try {
Class.forName(driverName);
conn = DriverManager.getConnection(url, userName, password);
state = conn.createStatement();
rs2 = null;
//========================= rs1 =================================================>>>>>>>>
// Reads in individual teams win and losses.
rs = state.executeQuery("SELECT * FROM " + table + " WHERE (training > 0 AND training < 10) AND Team_ID !=0");
while ( rs.next() ) {
PlayerID = rs.getInt("Player_ID");
TeamID = rs.getInt("Team_ID");
Age = rs.getInt("age");
Training = rs.getInt("training");
String skill = "";
float improveF = 0;
if (TeamID == 0) {
improvement = 0;
System.out.println(PlayerID + " has no team, skipped training.");
} else {
// checks if player is over 30 (no improvment)
if (Age >= 30){
improvement = 0;
System.out.println(PlayerID + " is over 30, skipped training.");
} else {
if (Training == 16 || Training == 0) {
improvement = 0;
System.out.println(PlayerID + " is not assigned to practice.");
} else {
switch(Training){
//Speed
case 1:
skillValue = rs.getFloat("SPEED");
maxSkillValue = rs.getFloat("max_SPEED");
skill = "SPEED";
break;
// Stamina
} // end switch
System.out.println(skill);
if (skillValue >= maxSkillValue) {
improvement = 0;
System.out.println(PlayerID + "Skills are maxed in " + skill);
} else {
improveF = (float) .015;
improvement = (test.trainingImprovement() * improveF);
skillValue += improvement;
System.out.println(improvement);
System.out.println(skillValue);
state.executeUpdate("UPDATE " + table +
" SET " + skill + "= '" + skillValue +
"', improve=" + improvement +
" WHERE Player_ID = '" + PlayerID + "'" );
} // end No Training Setting
} // end age IF test
} // end TeamID IF test
} // end while
conn.close();
} catch (Exception e) {
System.out.println("Problem with training program: " + e.toString() );
finally {
System.out.println("Player Training Executed");
} // END Finally
Any additional suggestions would be great but I got my code to work.
I changed the state.executeUpdate() to state2.executeUpdate. I did some reading in the forums and it was suggested that i cant use the my initial rs.
Similar Messages
-
I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column, find the 10 lowest numbers, then get the average and after that multiply it by .96 I used to use Excel and the formula worked fine in that. Here is my Formula
=(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96 So instead of using 1 cell, I'm using 12 cells to get my answer.
This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
Hoping I explain myself well enough and that someone can help me.
ThanksYou can still do it in one cell but it will be more unruly than the Excel array formula.
=average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
where you would, of course, replace the "..." with the remaining six SMALL functions. -
I am trying to use both DaqMx and DaqMxBase on the same (Windows) PC
Context: I am seeking to build and test the EPICS driver for "National Instruments - Various DAQ cards" - see http://www.aps.anl.gov/epics/modules/manufacturer.php for Windows.
This depends on NiDaqMxBase because it is built for Linux.
Consequently, I have installed DaqMxBase 3.7 on my (Window 7 /x64) PC, which already held DaqMx 9.7.5.
I cannot get DaqMxBase to recognise my pci-6601 counter/timer card.
It it recognised by DaqMx.
Should this card be recognised by DaqMxBase on Windows?
Is it OK to have both driver versions installed on the same PC?Hey Peter,
The USB-6008/9 has it's own article on this that I will link rather than typing it, it shows which operating systems support which drivers. Base and mx are both supported in some instances.
http://digital.ni.com/public.nsf/allkb/2B1BB86D649297FB86256F96007AC55E
Interestingly, in this case, Linux seems to only be supported by the Base driver.
Thanks,
Justin, Applications Engineer -
I have an old iPhone 3Gs with software version 4.3.5, I am trying to use it again, and it works fine, but I have not been able to update the software. Every time I try, I get the following message:
"there was a problem downloading the software for the iPhone, the network connection could not be established". This happens even though I have a working internet connection.
Besides that, all the other functions work properly, even synchronize apps and library.
Will I be able to update the software?look around the forum tons of people repport that they can't update
makes you suspect that apples update servers can't meet the depand of too many users
trying to update at once -
I am trying to use macro express and adobe acrobat 9 profession keeps shutting down, why is this happening? I tried to run as administrator already as well on both Macro Express and in Adobe and it still keeps shutting down.
same problem, it's been happening to me for a week or two now i'm thinking about backing up my documents and just wiping it completely, see if that works. Has anyone else tried this? I'm loosing time and have already lost a good few hours of work as it just crashes randomly. need help!!!
- saving these threads on my favourites cause i'm about to crash . . . -
I have not used my CS3 version for about 3-4 years. I tried to use it recently and I get a message about activation. Called the phone number recommended but no longer in use. How do I start using MY version I paid for? Using PC
Can you activate CS3. If you lost your serial you can retrieve it from Adobe.com. Sign in at Adobe.com the use this link https://www.adobe.com/account/my-products-services.html When your Adobe Product list is displayed click on your CS3 product your serial number should be displayed.
-
I am having trouble with my iPad, i can start it, but the iPad does not work. i tried to use the power and home button at the same time, the apple logo appears, but the iPad does not work. What am I suppose to do?
After the Apple logo appears, what happens then? Can you hear any sounds or if you tap on the screen, does it seem like apps can open or are you just seeing a black screen? You might have a hardware problem, but you can try restoring the software and see what happens.
Read this in its entirety before you do anything. Make sure you read the sections at the end about using recovery mode.
iTunes: Restoring iOS software - Support - Apple -
I am trying to use IMAQ acquire and other IMAQ functions with Queue functions.
i am trying to use IMAQ acquire and other IMAQ functions with Queue functions.
i mean i would like to acquire the image in a queue and deque it afterwards. would be the queue function accept the IMAQ data type?Refer posting, http://exchange.ni.com/servlet/Redirect?id=8879554
-
I am trying to use Adobe Color and the screen won't load
I am trying to use Adobe Color and the screen won't load. All I get is the 4 spinning squares in the center of the screen. I Am using a Mac. Any help would be much appreciated.
Try:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Go to Settings>Store and sign out and sign back in.
- Reset all settings
Go to Settings > General > Reset and tap Reset All Settings.
All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
- Restore from backup
- Restore to factory settings/new iOS device. -
I'm using Photoshop CS6, created a new document. trying to use my layers and my work keeps going black. when I click on the workspace i am able to see my work but when I move my mouse any little bit it goes black again.
Good day!
Does turning off »Use Graphics Processor« in the Performance Preferences and restarting Photoshop have any bearing on the issue?
Regards,
Pfaffenbichler -
firefox sent an update to my imac but I couldn't download it because it said it came through an email improperly coded or tried to use adobe acrobat and that doesn't work. what do I do??
What to Do When Your iPad Won't Turn On
http://ipad.about.com/od/iPad_Troubleshooting/ss/What-To-Do-When-Your-Ipad-Wo-No t-Turn-On.htm
iOS: Not responding or does not turn on
http://support.apple.com/kb/TS3281
iPad Frozen? How to Force Quit an App, Reset or Restart Your iPad
http://ipadacademy.com/2010/11/ipad-frozen-how-to-force-quit-an-app-reset-or-res tart-your-ipad
iPad: Basic troubleshooting
http://support.apple.com/kb/TS3274
Update and restore alert messages on iPhone, iPad, and iPod touch
http://www.buybuyla.com/tech/view/012953a0d412000e.shtml
iOS: Resolving update and restore alert messages
http://support.apple.com/kb/TS1275
iPad: Unable to update or restore
http://support.apple.com/kb/ht4097
iTunes: Specific update-and-restore error messages and advanced troubleshooting
http://support.apple.com/kb/TS3694
Cheers, Tom -
i was in science trying to use my calculator and i couldn't slide to unlock my ipod. later i kept getting notifications but it still wouldnt slide. help please?
Try:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
- Make an appointment at the Genius Bar of an Apple store.
Apple Retail Store - Genius Bar -
Hello.
I am having much difficulty using any software drum program. I am trying to use EZ Drummer and the drum programs in Logic, with limited success. I was using them, and they were working, but this is no longer the case. Please help me navigate my way through these issues, if possible.
Thanks.
EricAha! I have sorted it.
For those with similar problems, the solution is this:
Macintosh HD > Library > Audio > MIDI Drivers
Then delete DigiDioMidiDriver.plugin -
I am trying to use my Bluetooth and it asks for a pin
I am trying to use my Bluetooth and it asks for a pin #. Where do I find this?
Check the manual on the device you are trying to pair with.
-
Need help trying to use close button and i really like to know why it off
need help trying to use close button and i really like to know why it off
And in English? You need to explain better.
Mylenium
Maybe you are looking for
-
Lightroom 5 What is the Color box for in the adjustment brush and filters
Hi I am running Lightroom 5.6 although I think this has been around probably from 4.In the Basic Development module when I select the Adjustment brush, Radial filter or Graduated filter then below Defringe I get a box marked Color. What does this box
-
Anyone have a G4 15"PB and a 20" mac display connected?
I was just wondering what experience anyone has had if they have purchased a 20" Apple display and have it connected to their 15" powerbook. Also, can you keep the PB closed while using the external monitor and how? thanks in advance Aj
-
Problem of Statement and PreparedStatement
hi The PreparedStatement has a metod : setNull(int parameterIndex, int sqlType) I want make a class to simulate PreparedStatement. String sql = "update tablename custname = ?,orderdate = ? where id = ?"; mySimulate = new mySimulate(sql); mySimulate.s
-
Sequential numbering of the bank statements in transaction FEBA
Hi expert, When I load the bank statements in transaction FEBA, the numbering of the bank statements is not sequential. How can I make it sequential? Thank you. Kind regards, Linda
-
Upgrade Perl 5.8.8 to 5.10 on OS X 10.5.8
How would I upgrade the default Perl 5.8.8 to 5.10 on OS X 10.5.8 ? Thanks in advance, Marx