SQLException: how do I know where I went wrong?
I just revolutioned the database I was using for my tomcat application, switching from MyIsam to InnoDB.
But as soon as I tried an insert I got an SQLException.
this is part of the code (which is called from a servlet):
public void saveInitialize(String gameName) throws ClassNotFoundException, SQLException {
Connection con = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DBConnect.connect("GAMES");
con.setAutoCommit(false);
stmt = con.createStatement();
int IDGioco = 1;
rs = stmt.executeQuery("SELECT ID FROM GAMES ");
while (rs.next()) {
IDGioco = rs.getInt("ID") + 1;
rs.close();
stmt.executeUpdate("INSERT INTO GAMES VALUES (" + IDGioco + ", '" + gameName + "', " + numeroPeriodi + ", " + numeroAziende + ", " + numeroProdotti + ", " + periodiGiocati + ")");
for (int i = 1; i <= numeroAziende; i++) {
stmt.executeUpdate("INSERT INTO AZIENDE " +
"VALUES (" + i + ", '" + nomeAzienda[i] + "', ENCODE('" + passwordAzienda[i] + "','tbg'), " + IDGioco + ", " + periodiInseriti[i] + ")");
for (int j = 1; j <= numeroProdotti; j++) {
stmt.executeUpdate("INSERT INTO PRODOTTI " +
"VALUES (" + j + ", '" + nomeProdotto[j] + "', " + IDGioco + ")");
pstmt = con.prepareStatement("INSERT INTO P_UNITA VALUES ( ?, ?, ?, ?)");
pstmt.setInt(1, parametroUnitaPrezzo);
pstmt.setInt(2, parametroUnitaInvestimenti);
pstmt.setInt(3, parametroUnitaPezzi);
pstmt.setInt(4, IDGioco);
pstmt.executeUpdate();
pstmt.close();
pstmt = con.prepareStatement("INSERT INTO P_DEFAULT_PRODOTTO VALUES ( ?, ?, ?, ?, ?, ?, ?, ?)");
for (int j = 1; j <= numeroProdotti; j++) {
pstmt.setInt(1, parametroDefaultPrezzo[j]);
pstmt.setInt(2, parametroDefaultPromozione[j]);
pstmt.setInt(3, parametroDefaultPubblicita[j]);
pstmt.setInt(4, parametroDefaultPrevisioneDiVendita[j]);
pstmt.setInt(5, parametroDefaultDesign[j]);
pstmt.setInt(6, parametroDefaultTecnologia[j]);
pstmt.setInt(7, IDGioco);
pstmt.setInt(8, j);
pstmt.addBatch();
pstmt.executeBatch();
pstmt.close();
/// etc. etc. etc.this is the error message I get:
java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '800. 600. 1)' at line 1 at com.mysql.jdbc.MysqlIO.sendCommand(Unknown Source) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(Unknown Source) at com.mysql.jdbc.Connection.execSQL(Unknown Source) at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source) at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source) at Game.saveInitialize(Game.java:7759) at SingletonGame.syncInitialize(SingletonGame.java:71) at SaveNewGame.doPost(SaveNewGame.java:316) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at
etc. etc. etc.
how do I know where I went wrong (the insert code is about 1200 lines)?
thank you
alessandro
While not related to your problem, I did notice that you're inserting into columns without specifying the column names, ie.
stmt.executeUpdate("INSERT INTO GAMES VALUES (" + IDGioco + ", '" + gameName + "', " + numeroPeriodi + ", " + numeroAziende + ", " + numeroProdotti + ", " + periodiGiocati + ")");While technically it's not an error, it's really easy to introduce a bug into your code. There's no guarantee that the order of columns will always be the same as when you created the table. It's much better to do something like "insert into games (col1,col2,col3...) values(...)".
Similar Messages
-
I just used stickie notes on my desktop Mac and don't know where it went or how I can find it.
Assuming you are using a relatively recent version of OS X, click the folder Applications in the Dock, then look in the window that opens for an item named Stickies. Click it. Your stickie note should then be available.
-
When I try to uninstall iTunes I get a message saying iTunes 64 msi can not be located and I should enter an alternate path. How would I know where it it is? I get the same message when trying to install the update to iTunes 10.6.1.
Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
http://majorgeeks.com/download.php?det=4459
To install the utility, doubleclick the msicuu2.exe file you downloaded.
Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time? -
just ripped quite a few music albums. How do I know if they went into the cloud, and if they did not, how do I get them into the cloud
I assume you have iTunes Match turned on in iTunes?
You can create a smart playlist in iTunes that has "iCloud Status" is "Matched" or "Upload" - that will tell you what's in the cloud. -
How do you know where you quit editing your pictures in your organizer?
How do you know where you quit editing your pictures in your organizer. I have only used the program twice and now I am lost as to where I stopped. Thank you for any help in this matter.
hatstead wrote:
The properties dialog refers to a point in time
Exactly my point. If one has been using the Organizer to go through the images one at a time and editing them in the Editor; at a later date one would want to know where to begin editing additional images.
Ken -
Somebody stole my ipod touch 4G and i dont have the apps "found my ipod" how can i know where is my ipod? :( please help!
You do not need any app.
- If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
- You can also wipe/erase the iPod and have to iPod play a sound via iCloud.
- Change the passwords for all accounts used on the iPod and report to police
- There is no way to prevent someone from restoring the iPod (it erases it) using it.
- Apple will do nothing
Reporting a lost or stolen Apple product
- iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number -
How can i know where is my iphone from ??
How can i know where is my iphone from, i know only imei, and numbers from back of iphone
i have blocked iphone and i dont know where is it fromCall Apple and ask. There is no way to identify the origin of an iPhone from any of it's numbers. All iPhones are born equal.
-
Sorry. The crash report actually said that Quick Time had crashed, not Flash, but at the time the crash actually happened, the message said that "Silverlight" had crashed. I just want to know how I can tell where the problem is so that I can try to fix it.
That is a legitimate Mozilla newsletter. As it says in the email:
You're receiving this email because you subscribed to receive email newsletters and information from Mozilla. If you do not wish to receive these newsletters, please click the Unsubscribe link below.
Unsubscribe https://www.mozilla.org/en-US/newsletter/existing/ad9febcf-65ac-41fd-810b-798945f448f3/
Modify your preferences https://www.mozilla.org/en-US/newsletter/existing/ad9febcf-65ac-41fd-810b-798945f448f3/ " -
How do you know where you are in the Lion queue??
Can someone tell me how you know where you are in the queue for the Lion download? I am just left with the waiting signal over the lions head?
Look here ...
iCloud: iCloud storage and backup overview
https://www.apple.com/support/icloud/backup/ -
Hello i lost my phone to day how i can know where is it or do something whit it ?
ty for tack you time to read my question
i have lost my phone to day(26/5/2014 time + 7.00 at thailand.phuket) i don't know where is it and who get my phone have shat down it right now i can't call or do anything to contract him/her .yes i know it is my woung i want to know where is it my phone name is too long and not same any one it wright by my safe (not this name 'Divine' this name is my mother phone name :3)(stupid and idiont boy) i want it back how i can do ... ;A; it so bad day if i can't find can i do some thing whit it i have my iphone box it have a Past No. Serial No. and IMEI can you tell my when it tune on and where is it .
ty agina and very ty if you can help me T_TaIf you set up Find My iPhone, you can log in to icloud.com and you may be able to see where the phone was last located. You can use icloud.com to put the phone in Lost Mode or remotely erase it also.
Report the theft to the police and contact your carrier to have them blacklist the phone.
~Lyssa -
How do I know where I am in CardLayout?
Hi.
Does anyone know how I can possibly know where I am in CardLayout?
Like when I am controlling application with cardlayout, and go to next card..
I want the program to know where they are now so that they can hide 'next' button at the last page.You know the order of the cards so implement a tracking strategy that maintains an index of visible card, then increment/decrement it as you show or hide cards. when the index for the last card is shown disable the next button.
Give this a shot and post questions as you incounter problems.
Cheers
DB -
How do I know where my account is registered and how can I change that?
Hi,
Whenever I try to pay Acrobat XI, I get the message that the country of my registration is wrong. How do I know, in which country my account is registered and how can I change that?
It seems, that my account is registered in Austria, but I work now in the Netherlands. What is there to do?
Thanks for your help
Message was edited by: Michael KollerHi Michael ,
You can log in to Adobe.com with your credentials and you can change your region or country from the option "Change Region" at the bottom left of the page .
From there you can change your region and select the preferred one and make the payments.
Hope this will work .
Regards
Sukrit Dhingra -
I am having problems downloading my music library from my PC to my iphone. I have different apple id's for i-tunes and iphone5s. I did connect iphone to PC via USB and was able to sync and download, but do not know where it downloaded to. I looked under my music on iphone and nothing there.
You have Sync Music selected under the Music tab or selection for your iPhone sync preferences with iTunes on your PC?
-
How does Siri know where my office is
Ok I just got my iPhone 4s and I can't work out how to get Siri to remind me to do something when I get to the office.
How does Siri know when I'm at the office
How does Siri know I'm at home
How does Siri know I am at a particular place.
I know how to get Siri to do a reminder by using time, but the adverts say "office" so how does it know
Any help appreciated for a new 4s user :-)Put your office location in your contacts by itself with a label of office or work. Or associate it as office or work like you do with wife and kids and such.
-
i drag my app.to the dock , there is no icon, just the label and it works, don't know where it went
Hello, do you have a screen shot of that?
Is it possible it didn't quite make it to the dock & dropped on the Desktop?
Maybe you are looking for
-
When I try to buy either an app or a song via iTunes, I have just started getting the following message and I am unable to change the store location. "Account Not In This Store. Your account is not valid for use in the U.S. store. You must switch to
-
Different currency apperance in report
Hi all, when the currency has to appear different in the report what could be an easy or best way to handle it? The currency in the ERP is for each country available for example for company codes from Hungary, Malaysia, Japan, China is local currency
-
Can't Delete Oracle Database Job
i created an oracle database job and some of them is only a sample test job. i need to delete them but the delete option is not enabled. it looks like all the other oracle database job that i created can't be deleted. please advise thanks.
-
I have the WVC54GCA. Was working fine and then one day its not. Can not access through the Monitor, or via the TZo Web page. When I access through monitor, the camera isnt even listed in the camera status box. I tried unplugging the camera, that
-
Connect home and office Macs - how?
I have a two Mac Airport network at the office and a Mac at home; all 10.4.6. I now have a static IP addresses at each location (same ISP). I'd like to be able to log into my computer at the office (I am admin on both at the office) from home, open d