Why do I get this SQLException?

Hello!
I got two questions
1)
I'm using Mysql, I can insert without any problems but I can't do "UPDATE" then I get this error:
("key" is my primary key)
----------------------------------------- ERROR ------------------------------------------
java.sql.SQLException: Syntax error or access violation, message from server: "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 'key = '2'' at line 1"
My syntax looks like:
---------------------------------- SYNTAX ------------------------------------------------
public void setUpdate(String i) throws IOException{
try{
Class.forName(driverName);
catch(ClassNotFoundException cfn){
System.out.println(cfn);
try{
Connection con = DriverManager.getConnection(fileURL,"", "");
Statement updateStatement=con.createStatement();
int noOfRows=updateStatement.executeUpdate("UPDATE tider SET fut1='"+getNamntag()+"', eut1='"+getNamntag2()+"', fut2='"+getMednamntag()+"', eut2='"+getMednamntag2()+"',grupput='"+getGrupput()+"', ledig='"+false+"' WHERE key = '"+i+"'");
catch(SQLException sqe){
System.out.println(sqe);
2)
I've got a table with "users" and their passwords"
When I'm searching in my table if the password is correct, given "firstname" and "secondname" I get an error which looks like: (it occurs when there are more rows than 1 in my table "spelare")
-----------------------------------------ERROR ------------------------------------------------------
java.sql.SQLException: After end of result set
     at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:3626)
     at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1772)
     at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1837)
     at inlamning.KollBeanId.kontroll(KollBeanId.java:331)
     at org.apache.jsp.start$jsp._jspService(start$jsp.java:130)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)java.sql.SQLException: After end of result set
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
     at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
     at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
     at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
     at java.lang.Thread.run(Thread.java:536)
My syntax looks like:
public void kontroll(){
String anv="";
String pass="";
String fileURL = "jdbc:mysql://localhost/tider?user="+anv+"&password="+pass;
String driverName ="com.mysql.jdbc.Driver";
try{
Class.forName(driverName);
catch(ClassNotFoundException cfn){
System.out.println(cfn);
try{
String fnamn="";
String enamn="";
String p="";
Class.forName(driverName);
Connection con = DriverManager.getConnection(fileURL,"","");
Statement selectStatement = con.createStatement();
String query = "SELECT * FROM spelare";
ResultSet rs = selectStatement.executeQuery(query);
while (rs.next()||!korrekt) {
fnamn= rs.getString("fnamn");
enamn = rs.getString("enamn");
p = rs.getString("passw");
if(fnamn.equals(fnamnkontr)&&enamn.equals(enamnkontr)&&p.equals(password)){
korrekt = true;
spelarefinns=true;
player=new Player();
player.pnr=rs.getString("pnr");
player.fnamn=fnamn;
player.enamn=enamn;
player.passw=p;
player.division=rs.getString("division");
player.email=rs.getString("email");
player.tel=rs.getString("tel");
player.mobtel=rs.getString("mobtel");
else{korrekt=false;}
selectStatement.close();
con.close();
rs.close();
catch(Exception evt){
System.out.println(evt);
evt.printStackTrace();
Thanks for helping me !

your problem probably stems from the fact that key is a reserved word in MySQL. meaning you shouldn't have used it for a column name.
to fix your query try either of the following... both should work.
String sql2 = "UPDATE tider SET fut1='test', eut1='test', fut2='test', eut2='asdf',grupput='1', ledig='false' WHERE `key` = '6'";
String sql2 = "UPDATE tider SET fut1='test', eut1='test', fut2='test', eut2='asdf',grupput='1', ledig='false' WHERE tider.key = '6'";for more on MySQL reserved words see this http://www.mysql.com/doc/en/Reserved_words.html

Similar Messages

  • Why am I getting this error?

    Hello,
    I am trying to call my Java class from a JSP page. I am getting this error:
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\em\jsp\Test_0005fSummarySBU_0005fscreen$jsp.java:82: Wrong number of arguments in constructor.
    strQuery=new ListReturn(strEssUser, strProcessingMonth, strProcessingYear);
    I don't understand why I am getting this error as I pass three paramters to the Java class, and I accept three parameters in the constructor.
    JSP:
    <!-- META TAG is necessary to ensure page recompiles--------------->
    <META Http-Equiv="Expires" Content="0">
    <META Http-Equiv="Pragma" Content="no-cache">
    <HTML>
    <!-- The two Java Classes used to build the AlphaBlox query -->
    <%@ page import="com.home.tool.reporting.*" %>
    <%@ page errorPage="run_error.jsp" %>
    <%@ page import="java.util.List,
                     java.util.Collection,
                java.net.URLDecoder" %>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE>Economic Model - Summary SBU Report</TITLE>
    <!--Run the onload here, re-retrieve params BM and Breport, pass to onload---------->
    <BODY bgcolor=#ffffff>
    <%
                    Collection strQuery = null;
                    String strEssUser = "test";
                    String strProcessingMonth = "JUL";
                    String strProcessingYear = "2002";
                    strQuery=new ListReturn(strEssUser, strProcessingMonth, strProcessingYear);
                    System.out.println(strQuery);
    %>
    </BODY>
    </HTML>Java class:
    package com.home.tool.reporting;
    import java.net.URL;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class ListReturn extends ReportQueryBuilder
            public void ListReturn()
            public Collection ListReturn(String userID, String pMonth, String pYear)
                throws ReportQueryBuilderException
                //declare Collection store Value-Object pairs
                Collection c = new ArrayList();
                //declare and initialize variables
                CallableStatement cs = null;
                ResultSet rs = null;
                // declare call for stored procedure to pass in three parameters
                String pass = "{Call dbo.p_rep_srSbuList(?, ?, ?)}";
                try
                    //open CallableStatement using JDBC connection to SQL database
                    cs = con.prepareCall(pass);
                    //set IN parameters
                    cs.setString(1, userID);
                    cs.setString(2, pMonth);
                    cs.setString(3, pYear);
                    //execute call and return result set
                    rs = cs.executeQuery();
                    //loop through result set storing each record as a Value-Object pair
                    while(rs.next())
                        c.add(new ListBoxValueObjects(rs.getString(1), rs.getString(2)));
                catch (SQLException sqle)
              throw new ReportQueryBuilderException(replaceToken("Problems executing query: "+sqle.getMessage(), "'", "\\'"));
                finally
                    try
                        //close the Result Set and CallableStatement
                        rs.close();
                        cs.close();
                    catch(Exception e)
                        System.out.print("\nFATAL   : " + e);
                        System.out.print("\nFATAL   : " + e);
                return c;
    }Does anyone see whay I am getting this error??
    I can't figure out the problem!

    change this:
    <%
         Collection strQuery = null;
         String strEssUser = "test";
         String strProcessingMonth = "JUL";
         String strProcessingYear = "2002";
         strQuery=new ListReturn(strEssUser, strProcessingMonth, strProcessingYear);
         System.out.println(strQuery);
    %>To this:
    <%
         Collection strQuery=null;
         String strEssUser="test";
         String strProcessingMonth="JUL";
         String strProcessingYear="2002";
         lr=new ListReturn(strEssUser, strProcessingMonth, strProcessingYear);
         System.out.println(lr.getQuery())
    %>Then make a new public method in your Java called getQuery()
    public Collection getQuery();Do what you need to do to process it and return the value in getQuery. You will also probably need to make private variables in you declaration to do the processing on.

  • TS1702 "The feature you are trying to use is on a network resource that is unabailable" Why am I getting this message when I try to updaate itunes or quicktime?

    The feature you are trying to use is on a network resource that is unabailable" Why am I getting this message when I try to updaate itunes or quicktime?

    Before trying the update again, use Microsoft's Fix it solution at http://support.microsoft.com/mats/Program_Install_and_Uninstall. Use it to uninstall iTunes and Quicktime. It bypasses this not uncommon problem. When the solution finishes, the selected program will be uninstalled. It can take several minutes and I have seen as much as half an hour.
    After iTunes & Quicktime are uninstalled, try the update again.

  • I get missing plug-in error when opening my online bill which is in PDF format. I am using a 2010 Macbook with the latest version of Safari and Adobe suite installed in my computer. Why do I get this error? What should I do?

    I get missing plug-in error when opening my online bill which is in PDF format. I am using a 2010 Macbook with the latest version of Safari and Adobe suite installed in my computer. Why do I get this error? What should I do?

    In relation to my previous inquiry regarding inability to view a pdf file using Safari...
    Is it possible that I can view other online bills from other website but not this particular bill from one specific website?
    Sorry if I missed any important point in this article -->Apple Safari 5.1 and Adobe Reader/Acrobat Advisory
    Thanks again!

  • Why do I get this error message when I open Organizer in Photoshop Elements 11 "Elements Organizer has stopped working"? My only option is to Close Program so I am effectively locked out of my photo catalogue.  I have reinstalled the program to no avail.

    Why do I get this error message when I open Organizer in Photoshop Elements 11 "Elements Organizer has stopped working"? My only option is to Close Program so I am effectively locked out of my photo catalogue. I have tried reinstalling the program but it made no difference to the error message.
    Could someone help please?  Steph

    Hi,
    Please give a try to Photoshop Elements (PSE) knowledge base. steps mentioned on this and see if it works.
    Regards
    Kishan

  • Why do I get this error when trying to use my bluetooth headset as a listening device? There was an error connecting to your audio device. Make sure it is turned on and in range. The audio portion of the program you were using may have to be restarted.

    Why do I get this error when trying to use my bluetooth headset as a listening device? There was an error connecting to your audio device. Make sure it is turned on and in range. The audio portion of the program you were using may have to be restarted.

    I may have already resolved this issue buy removing the device from my computer and re-pairing it. It is currently working just fine.

  • I received an error "iTunes requires 64-bit mode" says to go into my iTunes application and 'uncheck' the 'open in 32-bit mode' checkbox - i went into the application and the box was not checked anyway so why am i getting this prompt?  Never happened b4

    i received an error message "iTunes requires 64-bit mode" says to go into my iTunes application and 'uncheck' the 'open in 32-bit mode' checkbox - i went into the application and the box was not checked anyway so why am i getting this prompt?  Never happened before. yesterday did the sofware update for maverick.

    Thank you for your response, Chris. But I'm afraid I have to disagree. There are native 64 bit versions of iTunes available for OSX and Windows.
    In a 64 Bit Windows environment native 64 Bit Applications install the DLL's in a directory called "Program Files" and a directory called "Program Files (x86)" (32 Bit applications only use the ladder).
    iTunes 9 is consistent with this behavior - and it identified itself to the system as a 64 bit application (meaning it's process appears without a "*32" tag on it).

  • More than maximum 5 filtered album lists trying to register. This will fail,Why i am getting this error when i pick video from Photo library.

    I am able to pick 4 videos from the Photo library in my iPhoneAPP but when i try to pick 5th one it throws an error:
    "More than maximum 5 filtered album lists trying to register. This will fail,Why i am getting this error when i pick video from Photo library."

    Hello Tate r Bulic
    I don't have any idea how to remove this error,can i pick more than 5 videos from the photo library...
    If it's then please help me and gimme idea..Thanks

  • According to my network provider (Amaysim/Optus) Tethering is enabled, so why do I get this error message "to enable personal hotspot on this account, contact OPTUS"

    According to my network provider (Amaysim/Optus) Tethering is enabled, so why do I get this error message "to enable personal hotspot on this account, contact OPTUS"
    Amysim/Optus support can not help.
    I can not check or change any network settings (no APN settings)
    I have synced phone using latest itunes (10.5.3).
    Phone software is up to date (5.0.1).
    Network settings have been reset.
    SIM card has been taken out and put back in.
    Phone has been switched off/on again.
    Another sim card from virgin works ok (hotspot option is visible and can be turned on/off as required)
    The Amaysim/Optus SIM card can be put into another phone (android) and tethering/hotspot works fine.
    Can anyone provide solution to this nightmare?

    I am having the same issue although i have an iphone 5. I have contacted Live connected numerous times an tried everything imaginable to solve the issue. Is it possibly a handset issue? I cant recieve any help from optus as im with live connected, they cant help me and apple keep telling me to contact your carrier ( live connected). Seems to make me want to switch providers pretty shortly..
    please let me know if you can solve your issue and maybe it can help me too..

  • Why do I get this errorThe server responded with "502" to operation CalDAVAccountRefreshQueueableOperation.

    Why do I get this message in iCal
    The server responded with
    “502”
    to operation CalDAVAccountRefreshQueueableOperation.
    And then it disappears it is very annoying, also for the mail program it gets password rejected by server. I have checked all the settings they are correct. What's the deal ATT says its me.

    Hi, is this Mail the old defunct MobileMe perchance?
    If so, do you have an iCloud account yet?
    I understand .mac mail will still come through. Do not delete the old account yet.
    You cannot use .mac or MobileMe as type of Account, you have to choose IMAP when setting up, otherwise Mail is hard coded to change imap.mail.me.com to mail.me.com & smtp.mail.me.com to smtp.me.com, no matter what you try to enter.
    iCloud Mail setup, do not choose .mac or MobileMe as type, but choose IMAP...
    On second step where it asks "Description", it has to be a unique name, but you can still use your email address.
    IMAP (Incoming Mail Server) information:
    • Server name: imap.mail.me.com
    • SSL Required: Yes
    • Port: 993
    • Username: [email protected] (use your @me.com address from your iCloud account)
    • Password: Your iCloud password
    SMTP (outgoing mail server) information:
    • Server name: smtp.mail.me.com
    • SSL Required: Yes
    • Port: 587
    • SMTP Authentication Required: Yes
    • Username: [email protected] (use your @me.com address from your iCloud account)
    • Password: Your iCloud password
    Also, you must upgrade your password to meet the new criteria:  8 characters, including upper and lower case and numbers.  If you have an older password that does not meet these criteria, when you try to setup mail on your mac, using all of the IMAP criteria listed above, it will still give a server error message.  Go to   http://appleid.apple.com         then follow directions to change your password, then go back to setting up your mail using the IMAP instructions above.
    Thanks to dpepper...
    https://discussions.apple.com/thread/3867171?tstart=0

  • Why am I getting this message Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch Server at

    Various websites say that they can not be found at the "Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch Server at ..................."
    There are many other reports on the forum from Yahoo and other sites.

    Why am I getting this message Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch Server at
    Various websites say that they can not be found at the "Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch Server at ..................."
    because I can not open my website Karimwebmall.com at this time could please fixed the problem thanks.

  • I thought that I have a yearly subscription. Why did I get this email "Expiration of your Adobe Acrobat Pro Subscription"?

    Why did I get this email "Expiration of your Adobe Acrobat Pro Subscription"?
    I'm supposed to have a yearly subscription to Adobe Acrobat Pro.

    Hi jksjcg,
    Kindly contact our chat support:http://helpx.adobe.com/x-productkb/global/service-b.html
    Regards,
    Florence

  • There was an error opening the database for the library "/Users/stacia134/Pictures/Aperture Library.aplibrary".  Why am I getting this message and how do I correct it so that I can open Aperture????  any suggestions would be most appreciated

    There was an error opening the database for the library “/Users/stacia134/Pictures/Aperture Library.aplibrary”.  Why am I getting this message and how do I correct it so that I can open Aperture????  any suggestions would be most appreciated

    Then I'd check the system drive, if it has problems.
    To check your System drive boot into the Recovery Partition, see: OS X Lion: About Lion Recovery
    Restart your Mac and hold down the Command key and the R key (Command-R), and keep holding them until the Apple icon appears, indicating that your Mac is starting up.
    You will see a panel, where you can use Disk Utility to check your System Drive.

  • Why am I getting this App Store message for the new OS: The product distribution file could not be verified. It may be damaged or was not signed.

    Why am I getting this App Store message:
    The product distribution file could not be verified. It may be damaged or was not signed.

    I had the same problem. Spoke to Apple support who directed me to Itunes support.  Frustrating to say the least.  Some have said remove virus barrier.  I did and still nothing.  Some posts have said to delete App store.  DON'T DO IT.. App store is tuff to get back.  This did work for me. Go to Finder, then go, pick go to folder, type in, /var/folder, and delete (send to trash).  There were 2 folders I had to delete, KX & XX, and as soon as I sent them to the trash they returned but I was able to download & intall Mountain Lion and working well.  Good luck..

  • Why did I get this stupid emails about missing payment of my Adobe CC ???

    Hi, I have get this email from Adobe:
    what we have here payment for your account could not be loaded. So there will be no interruptions in your use of the Creative Cloud , please update your billing information shortly .
    account Management
    If you have decided not to renew your subscription , no further action is required on your part. You have until the end of the current billing period unlimited access to your Creative Cloud membership. Then your paid membership in a free Creative Cloud membership is converted . If you use this time more than 2 GB Creative Cloud storage , you may not be able to access some of your files . In this case it is recommended to delete some files, so you are below the memory limit of 2 GB , which is included in a free Creative Cloud membership.
    If you change your mind , we are always happy to activate your paid subscription again .
    Thank you for your confidence.
    The Creative Cloud Team
    Why did I get this stupid email, because my banking dates are the same as before and creditcard is everytime paying ??????? So what's going on?

    Hi.  I checked on the order and it says the order is currently being processed and I should check back tomorrow. I'm mostly just concerned because I got an email saying the order was on hold, and I want to make sure it actually does go through and I'm not just waiting for a delivery that's not going to come. I'm still confused as to why I'd get an email saying I had to call the fraud department only to be told I shouldn't have called the fraud department.

Maybe you are looking for

  • How can I fix having to "save" before I can even open a PDF?

    I have Adobe Acrobat 9 Pro (9.5.5) and when a recent update came thru I am no longer able to simply click and view the PDF sent, but now am required to save it before viewing.  Is there any simple way to correct this back to the old way?  I don't wan

  • I have problem in my MACbook

    I have a problem in my computer MACbook (OX.10.6.8) , i can't update software, also i have files in the desktop  do you think that files will be effect or not after update, I mean what about my files Am I going to lose them after update,also what abo

  • SOAP to SOAP principal propagation with logon tickets

    I have configured a scenario using soap sender to soap receiver with an integrated configuration on PI 7.1. It is synchronous CE 7.11<->PI 7.10<->ECC 6.0. The scenario works with basic authentication. If I enable principal propagation on the sender s

  • IPhoto update deleted my photo library

    Recently i was asked to update iPhoto to 9.5.1 by software update. I unfortunately did so. When I try to open iPhoto now there is an error message that says that I do not have access rights to my iPhoto library. I cannot find the library anymore and

  • Client triggers Web Service servlet

    Hi, I'm new to java enterprise app. I have to develop a web service which listens to incoming soap info and triggers a servlet to be displayed on the screen where the web service is installed. And the servlet must show the message received from soap.