SQL Exception from simple query

java.sql.sqlexception: [microsoft][odbc microsoft access driver] Too few parameters. Expected 1.
I dont understand why im getting this because i think my sql statement is correct but here it is
String query = "SELECT User FROM Users WHERE Password = pass";
and the exception also points out this line
ResultSet result = stat.executeQuery(query);

I see no parameters, and in the abstract that SQL ought to work.
However, I halfway suspect that either User, Users, Password, or pass is a reserved word and somebody is getting confused. Try renaming your columns and table...

Similar Messages

  • SQL exception from servlet

    Can anyone suggest why i get an sql expection from my servlet? Or suggest another way performing this. I just get a my table but no results becuase of an sql exception in tomcat server console. degree id is the parameter from the html page
    try{
         conn = DriverManager.getConnection(url, user, password);
         String selectSQL = "SELECT * from book2readinglist WHERE readinglist = " + degreeid + ""; // change * to book_id or whatever it is
         System.err.println("DEBUG: Query: " + selectSQL);
         Statement stmt = conn.createStatement();
         ResultSet rs1 = stmt.executeQuery(selectSQL);
         //print out html head element
         out.println("<head>"+
              "<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">" +
              "<title>books</title>" +
              "</head>");
         // print out table header
         out.println("<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">" +
              "<tr><th><h4>Title</th></h4><th><h4>Author</th></h4><th><h4>Category</th></h4><th><h4>Cover</th></h4><th><h4>Publisher</th></h4><th><h4>Price</th></h4><th></th></tr>");
         //print out table rows one for each row returned in rs1
         while(rs1.next()){
              String selectSQL2 = "SELECT book from book2readinglist WHERE readinglist = " + degreeid + "";
              System.err.println("DEBUG: Query: " + selectSQL2);
    Statement stmt2 = conn.createStatement();
    ResultSet rs2 = stmt2.executeQuery(selectSQL2);
              while(rs2.next()){
              String selectSQL3 = "SELECT * from books WHERE idcol = " + rs2.getString("book") + ""; /
              System.err.println("DEBUG: Query: " + selectSQL3);
    Statement stmt3 = conn.createStatement();
    ResultSet rs3 = stmt3.executeQuery(selectSQL3);
         out.print("<tr>");
         out.print("<td><h5>" + rs3.getString("title") + "</td>");
         out.print("<td><h5>" + rs3.getString("author") + "</td>");
         out.print("<td><h5>" + rs3.getString("category") + "</td>");
         out.print("<td><img src=\"/assignment1/img/" + rs3.getString("cover") + "\" /></td>");
         out.print("<td><h5>" + rs3.getString("publisher") + "</td>");
         out.print("<td><h5>" + rs3.getString("price") + "</td></h5>");
    Thanks
    Nick

    i am afraid, exception stack trace would help us a lot in identifiyin wat, where, why an exception occured...

  • Best design for Boolean function from simple query

    Hello,
    what is the most efficient, shorter, readable, simple way to make a boolean function that simply return true or false from a simple query that return 0 or 1 to n records?
    Is this solution using a cursor's the best (working...):
       FUNCTION is_date_present (p_date IN DATE)
          RETURN BOOLEAN
       IS
          CURSOR chk_cursor
          IS
             SELECT COUNT (*)
               FROM target_dates
              WHERE target_date = p_date;
          nb   NUMBER := 0;
       BEGIN
          OPEN chk_cursor;
          FETCH chk_cursor
           INTO nb;
          CLOSE chk_cursor;
          IF nb >= 1
          THEN
             RETURN TRUE;
          ELSE
             RETURN FALSE;
          END IF;
       END;Performance, clarity and simplicity are important...
    Thanks

    Well, I prefer (not tested):
    FUNCTION is_date_present (p_date IN DATE)
    RETURN BOOLEAN
    IS
    nb NUMBER := 0;
    BEGIN
    SELECT COUNT (*)
    INTO nb
    FROM target_dates
    WHERE target_date = p_date;
    IF nb >= 1 THEN
    RETURN TRUE;
    LSE
    RETURN FALSE;
    IF;
    END;Regards,
    MiguelWhy count multiple records when you only care if you get at least 1 occurrence? Just wasted cycles.
    FUNCTION is_date_present (p_date IN DATE)
    RETURN BOOLEAN
    IS
    nb NUMBER := 0;
    BEGIN
      SELECT COUNT (*)
      INTO nb
      FROM DUAL
      WHERE EXISTS
          SELECT NULL 
          FROM target_dates
          WHERE target_date = p_date
      IF nb >= 1 THEN
         RETURN TRUE;
      ELSE
         RETURN FALSE;
      END IF;
    END;Or you could just add a ROWNUM = 1 on to yours, either way.

  • Class Cast Exception on Simple query

    Hi,
    I am getting the following exception on a very simple code
    When I execute the query on sql tool it gives me one result.
    PersonEntity obj = (PersonEntity)em.createNativeQuery("Select * from person where person_id = ''90").
    getSingleResult();
    java.lang.ClassCastException: org.eclipse.persistence.internal.helper.NonSynchronizedVector cannot be cast to com.entitites.Person
    Also I have the following two warnings in my logs
    WARNING: Found unrecognized persistence provider "org.eclipse.persistence.jpa.PersistenceProvider" in place of OpenJPA provider. This provider's properties will not be used.
    WARNING: Found unrecognized persistence provider "org.eclipse.persistence.jpa.PersistenceProvider" in place of OpenJPA provider. This provider's properties will not be used.
    Any ides?
    A.B

    Hello,
    createNativeQuery is a native SQL query which will return the raw data from the database, not the Entity. You can use createNativeQuery("Select * from person where person_id = ''90", PersonEntity.class) to return managed PersonEntity objects, or just use JPQL queries such as createQuery("Select p from PersonEntity p where p.persion_id = 90");
    As for the warnings; I have been told its caused by OpenJPA being used internally by Weblogic and that there is a bug filed for it, but I don't have the number for it. I believe they can be ignored if the entityManager you are getting in your application is from EclipseLink (em.getDelegate() should return an EclipseLink EntityManagerImpl).
    Best Regards,
    Chris

  • Sql exception from java

    Hi,
    When running the below query from sqlyog it works OK but when running from java I got exception.
    What can cause this difference ?
    The query :
    create temporary table TempTable1 SELECT salaries.salary AS `salary`,salaries.emp_no AS `emp_no`,salaries.from_date AS `from_date`,MAX(salaries.salary) AS `func` FROM `salaries` WHERE salaries.to_date = '9999-01-01'
    The exception:
    com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'salary' cannot be null
    Thanks

    Below is the code.
    When run from sqlyog is works OK.
    Thanks
    The code :
    package client;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class test {
         * @param args
         * @throws ClassNotFoundException
         * @throws IllegalAccessException
         * @throws InstantiationException
         * @throws SQLException
         public static void main(String[] args) throws InstantiationException,
                   IllegalAccessException, ClassNotFoundException, SQLException {
              String username = "root";
              String password = "";
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              java.sql.Connection connection = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/employees-thin", username,
                        password);
              Statement statement = connection.createStatement();
              statement
                        .execute("create temporary table TempTable1 SELECT salaries.salary AS `salary`,salaries.emp_no AS `emp_no`,salaries.from_date AS `from_date`,MAX(salaries.salary) AS `func` FROM `salaries` WHERE salaries.to_date = '9999-01-01'");
    Exception in thread "main" com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'salary' cannot be null
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)

  • Sql statement from abap query

    is there any chance to get the sql statement (not program) from any abap query created via SQ01?
    I can get the code of program that generated by system, but I cannot get pure sql statement.
    any answer will be appreciated

    I see no parameters, and in the abstract that SQL ought to work.
    However, I halfway suspect that either User, Users, Password, or pass is a reserved word and somebody is getting confused. Try renaming your columns and table...

  • How to Run a .sql file from simple java class

    How to execute a .sql file consisting of Complex Queries,procedures through simple java class.
    The queries may have different delimiters,queries independant of each other.
    I am able to do with Specific De-limiter.But I need in such a way that there should not be any
    Constraints. Since My .sql may Contain different De-limiters.
    If any one can Suggest Some Solution.
    It will be Great Help.
    regards
    Anil

    Check out ibatis script runner, it' a third party library but quite handy for running sql files...
    m

  • How to get SQL statement from (Collection) query.execute();

    We have a JDO Persistence class ClassName that execute query using following code. After this statement get executed, record does not get updated in the DB. Is there a way to check what SQL statement got submitted in the (Collection) query.execute(); ??? <br><br>
    Extent extent = pm.getExtent(ClassName.class, false); <br>
    Query query = null; <br>
    try { <br>
    query = pm.newQuery(extent, filter); <br>
    Collection results = (Collection) query.execute();<br>
    Iterator i = results.iterator();<br>
    if (i.hasNext()) {<br>
    ...<br>
    }<br>

    You can always find out the names of tables that are views, using java.sql.DatabaseMetaData and its getTables() method.
    This tends to be a nice source of examples:
    javaalmanac.com
    However, if you're asking for the underlying SQL used to CREATE VIEW, I don't see anything in the API that will give you that. After all, JDBC shouldn't have to know if it's dealing with an ordinary table or a view. I think you'd have to ask your DBA for the underlying SQL.
    Once you have it, what do you plan to do with it?
    %

  • Limiting results from simple query

    Hi all can you help.
    WITH trt AS
    (SELECT 7501 chart_id, 8 transaction_type from dual union all
    SELECT 7501 chart_id, 44 transaction_type from dual union all
    SELECT 12 chart_id, 44 transaction_type from dual
    )select distinct chart_id from trt
    where transaction_type IN (8,44)I have the above table, and would like to return only the chart_id which matches both IN transaction_types. i.e ONLY chart_id 7501
    Thanks for your time
    David

    Christian Balz wrote:
    Hello,
    Try this,Maybe not..
    SQL> WITH trt AS (SELECT 7501 chart_id,  8 transaction_type from dual union all
      2               SELECT 7501 chart_id, 44 transaction_type from dual union all
      3               SELECT   12 chart_id, 44 transaction_type from dual)
      4  SELECT CHART_ID
      5    FROM (SELECT CHART_ID,
      6                 ROW_NUMBER() OVER(PARTITION BY CHART_ID ORDER BY CHART_ID) NUM
      7            FROM TRT
      8           WHERE TRANSACTION_TYPE IN (8, 44, 55))
      9   WHERE NUM >= 2
    10
    SQL> /
      CHART_ID
          7501
    SQL> ed
    Wrote file afiedt.buf
      1  WITH trt AS (SELECT 7501 chart_id,  8 transaction_type from dual union all
      2               SELECT 7501 chart_id, 44 transaction_type from dual union all
      3               SELECT   12 chart_id, 44 transaction_type from dual)
      4  SELECT CHART_ID
      5    FROM (SELECT CHART_ID,
      6                 ROW_NUMBER() OVER(PARTITION BY CHART_ID ORDER BY CHART_ID) NUM
      7            FROM TRT
      8           WHERE TRANSACTION_TYPE IN (44))
      9*  WHERE NUM >= 2
    SQL> /
    no rows selected
    SQL>Both give results I wouldn't expect. The first should have given no rows and the second should have given both chart_id's

  • SQL Insert from "Select Query" Not Work when use Order By

    Hai every body...
    I have a problem with T-SQL. I use SQL Server 2012 Express with SP2 on Windows 7 32-bit SP1.
    This is the problem
    -- first, create table
    create table dtoth.tableA (
    id_data TINYINT PRIMARY KEY,
    kd_data VARCHAR(20),
    nm_data VARCHAR(200)
    -- then, insert values
    INSERT INTO dtoth.tableA VALUES (0,'100.001','KAS');
    INSERT INTO dtoth.tableA VALUES (1,'110.001','BANK');
    INSERT INTO dtoth.tableA VALUES (2,'120.001','PIUTANG DAGANG');
    INSERT INTO dtoth.tableA VALUES (3,'121.001','PIUTANG GIRO');
    INSERT INTO dtoth.tableA VALUES (4,'130.001','PERSEDIAAN BARANG DAGANGAN');
    -- then, i create a temporary table
    create table dtoth.temp_tableA (
    kd_data VARCHAR(20),
    nm_data VARCHAR(200)
    -- then, i create a store procedure to call data from temporary table
    CREATE procedure dtoth.report
    AS
    BEGIN
    DELETE FROM dtoth.temp_tableA;
    INSERT INTO dtoth.temp_tableA SELECT kd_data, nm_data FROM dtoth.tableA ORDER BY kd_data desc;
    SELECT * FROM dtoth.temp_tableA;
    END
    GO
    When i execute the the store procedure with
    EXEC dtoth.report;
    the result is not accurate like this (kd_data not sorted desc):
    I want the column "kd_data" sort descending because i use ORDER BY kd_data DESC in insert statement on the store procedure.
    By the way, if i execute code like :
    SELECT kd_data, nm_data FROM dtoth.tableA ORDER BY kd_data desc;
    the result is correct like this
    So, what solution for my code in the store procedure ?
    Thanks.

    to get the data sorted, you should order by in your select in the stored procedure
    sorting while inserting does not guarenatee order..
    remove the order by in insert statement and put that in the select statement
    so, your procedure should be 
    -- then, i create a store procedure to call data from temporary table
    CREATE procedure dtoth.report
    AS
    BEGIN
    DELETE FROM dtoth.temp_tableA;
    INSERT INTO dtoth.temp_tableA SELECT kd_data, nm_data FROM dtoth.tableA;
    SELECT * FROM dtoth.temp_tableA ORDER BY kd_data desc;
    END
    GO
    Hope it Helps!!

  • Error in result set from join query

    I get a SQL exception from the JDBC thin driver when I make a getXXX( "string" ) call on a result set object when the query is a join. Aliases don't seem to help.
    Below is the stack trace.
    Anybody have any ideas?
    matt
    ResultSet.findColumn
    java.sql.SQLException: Invalid column name: get_column_index
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:427)
    at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java, Compiled Code)
    at oracle.jdbc.driver.OracleResultSet.findColumn(OracleResultSet.java:680)
    at person.PersonMgr.getForEdit(PersonMgr.java:114)
    at person.PersonMgr.getForView(PersonMgr.java:168)
    at person.PersonMgr.getPersonForView(PersonMgr.java:164)
    at nwsession.NWSession.login(NWSession.java:224)
    at jsp.dologin._jspService(dologin.java:241)
    at com.livesoftware.jsp.HttpJSPServlet.service(HttpJSPServlet.java:31)
    at com.livesoftware.jsp.JSPServlet.service(JSPServlet.java:129)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.livesoftware.jrun.JRun.runServlet(JRun.java, Compiled Code)
    at com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java:116)
    at com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(JRunProxyServiceHandler.java, Compiled Code)
    at com.livesoftware.jrun.service.ThreadConfigHandler.run(ThreadConfigHandler.java, Compiled Code)

    Your reference to NS.REQDATE is too deep. Oracle will only allow you to reference a column from the main query one level deep.
    I think you can just change that query into this:
    (Select AVG(((cpath.REQUESTDATETIME)- NS.REQDATE)*1440) AvgTime
    FROM usersessiondetails cpath
    Where cpath.Userkey=(Select Userkey from ods_user where userid=NS.UserId and namespace=NS.Namespace)
       and cpath.acctnum=aCCTNUM
       and cpath.transactionname IN (AUTH_LOGOFF' )
       and cpath.REQUESTDATETIME = NS.REQDATE )You do not need the extra query level to do the AVG.

  • Sql exception :too few paprameters to update

    I am getting an sql exception in this query below.
    It says too few parameters :expected 1
    String query = "UPDATE INR SET " + month+ " = " + mnt+ " where (IT = '" + initial + "') AND (new = '" + later+ "' ) AND (number = '" + num + "' ) AND (code = '" + Id + "')";
    I am just passing 1 telling it to update month column with mnt .
    Thanks,

    Here is my code with JDBC connecting to an Access Table
    String data ="jdbc:odbc:MonthUpdateTable";
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");     
         Connection conn = DriverManager.getConnection(data, "", "");
         Statement st = conn.createStatement();
         String query = "UPDATE INR SET " + month+ " = " + mnt+ " where (IT = '" + initial + "') AND (new1 = '" + later+ "' ) AND (number = '" + num + "' ) AND (code = '" + Id + "')";
         System.out.println(query);
         st.executeUpdate(query);
         st.close();
              conn.close();
    catch(Exception e) {System.out.println("UpdateError: " + e.toString()
               + e.getMessage());}
    Thanks,

  • SQL Query works in MS Access but caused SQL exception

    Hi all,
    I've got this query that works if I run it in MS Access but caused an SQL Exception if I run in my Java programme.
    The query
    SELECT Count(*) AS countPlayerMax FROM (SELECT Count(*) AS countSent, sent.mobileno FROM sent WHERE (((sent.date_sent) Between #2002-3-1# And #2002-3-8#)) GROUP BY sent.mobileno HAVING (((Count(*))>100)))
    The exception is
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
    I've done nested queries before but this one doesn't work. Any ides why??
    thanks

    Thanks for your suggestion
    I tried it but it still gives the same error, now the SQL looks like this
    SELECT Count(*) AS countPlayerMax FROM (SELECT Count(*) AS countSent, sent.mobileno FROM sent WHERE sent.date_sent Between #2002-3-1# And #2002-3-8# GROUP BY sent.mobileno HAVING Count(*)>100)
    the exception is the same
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

  • Running a SQL Stored Procedure from Power Query with Dynamic Parameters

    Hi,
    I want to execute a stored procedure from Power Query with dynamic parameters.
    In normal process, query will look like below in Power Query. Here the value 'Dileep' is passed as a parameter value to SP.
        Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData 'Dileep'"]
    Now I want to pass the value dynamically taking from excel sheet. I can get the required excel cell value in a variable but unable to pass it to query.
        Name_Parameter = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
        Name_Value = Name_Parameter{0}[Value],
    I have tried like below but it is not working.
    Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData Name_Value"]
    Can anyone please help me with this issue.
    Thanks
    Dileep

    Hi,
    I got it. Below is the correct syntax.
    Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData '" & Name_Value & "'"]
    Thanks
    Dileep

  • Unknown SQL Exception 208 occurred. Additional error information from SQL Server is included below.Invalid object name 'Webs'.

    SP 2013 Server + Dec 2013 CU. Upgrading from SharePoint 2010.
    We have a web application that is distributed over 7-8 content databases from SharePoint 2010. All but one database are upgradable. However, one database gives:
    Invalid object name 'Webs'.
    while running Test-SPContentDatabase or Mount-SPContentDatabase.
    EventViewer has the following reporting 5586 event Id:
    Unknown SQL Exception 208 occurred. Additional error information from SQL Server is included below.Invalid object name 'Webs'.
    After searching a bit, these links do not help:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/fd020a41-51e6-4a89-9d16-38bff9201241/invalid-object-name-webs?forum=sharepointadmin
    we are trying PowerShell only.
    http://blog.thefullcircle.com/2013/06/mount-spcontentdatabase-and-test-spcontentdatabase-fail-with-either-invalid-object-name-sites-or-webs/
    In our case, these are content databases. This is validated from Central Admin.
    http://sharepointjotter.blogspot.com/2012/08/sharepoint-2010-exception-invalid.html
    Our's is SharePoint 2013
    http://zimmergren.net/technical/findbestcontentdatabaseforsitecreation-problem-after-upgrading-to-sharepoint-2013-solution
    Does not seem like the same exact problem.
    Any additional input?
    Thanks, Soumya | MCITP, SharePoint 2010

    Hi,
    “All but one database are upgradable. However, one database gives:
    Invalid object name 'Webs'.”
    Did the sentence you mean only one database not upgrade to SharePoint 2013 and given the error?
    One or more of the following might be the cause:
    Insufficient SQL Server database permissions
    SQL Server database is full
    Incorrect MDAC version
    SQL Server database not found
    Incorrect version of SQL Server
    SQL Server collation is not supported
    Database is read-only
    To resolve the issue, you can refer to the following article which contains the causes and resolutions.
    http://technet.microsoft.com/en-us/library/ee513056(v=office.14).aspx
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

Maybe you are looking for

  • Where shoould i specify about my target system in XI.

    Hi all! Xi sends XML file to my J2EE application.I am using HTTP adapter as receiver. I have given the following info in outbound HTTP communication channel:what else to be specified in ID Adapter type: HTTP Message protocol: Xi payload in HTTP body

  • Problem with Linksys PAP2T-eu

    Hello. First, sorry for my english I bought pap2teu today, configuration with my VoIP provider - OK, everything is working ok. But in SYSTEM -> User Password I wrote password and I can't now login into my device. How can i reset my device  or what mu

  • Limiting DB connections from IAS to DB

    I'm using IAS 9.0.2.2.1 connecting to an 8.1.7 DB using modplsql. I'm experiencing problems with IAS overloading the Database during periods of high usage.What setting(s) on the IAS machine control the number of connections that IAS (modplsql) makes

  • Pages "Ipad APP" no export via epub??

    Greetings Folks, I wanted to take a look at the ebook I'm working on. I went to "export as an epub" and found the option not avail. Is it me or is it not avail in the iPad App version? Many Thanks, twinetop

  • Copying a project into development component project

    hiii, I have a webdynpro project called DP_OrderEntry developed in NWDS 7.0.9. I need to copy it into development component dc_OrderEntry in NWDS 7.0.14. Can anyone tellme the steps for doing it? Can any error can crop up due to the difference in the