Pleasse help me with this error in SQL statement

Please tell me the error in this query:
the Error given is
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
given :
Databse is MS Access
In the databse :
account - text
number - text
date - date/time
vendor - text
Connection connection = t.getConnection();
/* t - some object containing a connection*/
Statement stmt = connection.createStatement();
stmt.executeUpdate("INSERT INTO Bills (account, number, date, vendor)
VALUES ('vai', '23', 10/12/2006, 'jaadya')");

I would imagine the problem is with the date. Different DBs have different date formats. To avoid that problem, use a PreparedStatement.
java.sql.Date date = ...;
PreparedStatement ps = con.prepareStatement("INSERT INTO Bills (account, number, date, vendor) VALUES (?, ?, ?, ?)");
ps.setString(1, "vai");
ps.setString(2, "23);
ps.setDate(3, date);
ps.setString(4, "jaadya");
ps.executeUpdate();This saves you from having to deal with vendors' various date formats, keeps you from having to escape special characters in strings, and prevents SQL injection.

Similar Messages

  • Could someone help me with this error: java.sql.SQLException: Closed Connec

    My code:
    <%@ include file="../setupcache.jsp"%>
    <%
    if(connectionPool_dig==null){
    %>
    <p>Could not connect to database. Please try again, thank!</p>
    <%          
         return ;
    Connection con = connectionPool_dig.getConnection();
    if(con==null){
    %>
    <p>Could not connect to database. Please try again, thank!</p>
    <%          
         return;
         String file = request.getParameter("m_FILE");
              file = "a";
         String sql = " SELECT *"+
              " FROM "+
              " FILEUPLOAD, SUBJECT"+
              " WHERE "+
              " FILEUPLOAD.SUBJECTCODE = SUBJECT.CODE AND UPPER(FILEUPLOAD.FILENAME) LIKE(UPPER(?))";
         PreparedStatement stmt = con.prepareStatement(sql);
         stmt.setString(1,"%"+file+"%");
         ResultSet rs = stmt.executeQuery();
         while(rs.next()){
              out.println("<br>"+rs.getString(1));
              out.println("<br>"+rs.getString(2));
              out.println("<br>"+rs.getString(3));
              out.println("<br>"+rs.getString(4));
         rs.close();
         stmt.close();
    try{
         con.close();
    }catch(SQLException e){}
    %>
    it usualy generate that error (once wrong then right then wrong....), but if I don't close connection (con.close), it work well. Could some one help me!

    Hi,
    I think that it should be better that returning the Connection
    instance back to the Connection Pool. The connection
    should not be close by you. it should controlled by the
    connection pool mechanism. So I think that you should
    check out your connection pool usage document for the
    right usage.
    If your code is the case, the connection in connection
    pool will get less and your connection pool mechanism
    may need to reallocate a new one for application. I
    don't think that it is right.
    good luck,
    Alfred Wu

  • PLEASE help me with this error java.sql.SQLException

    The code
    public void getInitialQuery() {         try {             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");             con = DriverManager.getConnection("jdbc:odbc:PDefApp1");             sta = con.createStatement();             System.out.println(SQLQuery);             res = setupSQLConnection(SQLQuery);             getRecordSet(res);
    private void getRecordSet(ResultSet r) {                try {             jTextRecordNumberField.setText(String.valueOf(r.getInt("id")));             jTextFirstNameField.setText(r.getString(2));             jTextMiddleNameField.setText(r.getString(3));             jTextLastNameField.setText(r.getString(4));             jTextDateOfBirthField.setText(r.getString(5));             jTextAKAField.setText(r.getString(6));             jComboBoxChargingDocument.setSelectedItem(r.getString(7));             jTextAreaChargingNumber.setText(r.getString(8));             jComboBoxDecision.setSelectedItem(r.getString(9));             jComboBoxDefendentStatus.setSelectedItem(r.getString(10));             jComboBoxOriginatingUnit.setSelectedItem(r.getString(11));             jTextFieldApplicationDate.setText(r.getString(12));             jTextFieldDecisionDate.setText(r.getString(13));             jTextFieldDeliveryDate.setText(r.getString(14));             jTextAreaComments.setText(r.getString(15));         } catch (Exception e) {             System.err.println("getRecordSet Exception: " + e.getMessage());             e.printStackTrace();         }             }
    The crash occurs in getRecordSet(ResultSet r) method and it occurs on ANY line. I've commented each line to see where it occurs.
    The crash says the following
    run: SELECT * FROM Table1 ORDER BY id ASC setupSQLQuery: SELECT * FROM Table1 ORDER BY id ASC getRecordSet Exception: [Microsoft][ODBC Driver Manager] Invalid cursor state java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)         at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3907)         at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5698)         at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:354)         at publicdesktopapplication.PublicDesktopView.getRecordSet(PublicDesktopView.java:1411)         at publicdesktopapplication.PublicDesktopView.getInitialQuery(PublicDesktopView.java:1377)         at publicdesktopapplication.PublicDesktopView.<init>(PublicDefenderView.java:89)         at publicdesktopapplication.PublicDesktopApplication.startup(PublicDesktopApplication.java:19)         at org.jdesktop.application.Application$1.run(Application.java:171)         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    I am very confused why this is crashing on me. It didnt crash in the older version of this application.
    Please help!

    Don't do this either
    SELECT * FROM Table1 Explictly name the columns in the order that you are going to fetch them. This makes your code easier to follow later and as side benefit prevents any changes in the column ordering from blowing your code to smitheens.
    And I do hope your table is not in fact called Table1.

  • Please help me with this error: "Apple application support was not found... Error 2"

    Can anyone please help me with this error: "Apple application support was not found... Error 2"
    I've followed the instructions by removing all Apple files from my laptop, but when I reinstall the iTunes software it still comes up with this message:
    "Apple application support is required to run iTunesHelper. Please uninstall iTunes, then install iTunes again. Error 2"
    Thank you

    iTunes "Apple Application Support is required... Error 2" and possible fix.
    I know this is a bit late but I came accross this thread trying to resolve this same problem and came up with a solution that worked for me, so thought I would share it here too. I hope it helps someone else.
    I just resolved this on Win Vista (should apply equally for Win7 too). Please uninstall iTunes before proceeding though. I'll walk you through the process I followed, if you like you can jump straight to the Solution section.
    Problems:
    The initial error during the installation of iTunes was:
    An error occurred during the installation of assembly 'Microsoft.VC80.CRT,version="8.0.50727.4053",type="win32",publicKeyToken='1fc8b 3b9a1e18e3b",processorarchitecture="x86". Please refer to Help and Support for more information. HRESULT:0x8007054F
    The error (after installing iTunes) when trying to run iTunes was:
    Apple Application Support is required to run iTunes. Please uninstall iTunes, then install iTunes again. Error 2 (Windows error 2).
    After trying various fixes around the forums I came across this MSKB article, which relates to the first installation error:
    http://support.microsoft.com/kb/2688946
    This lead me to trying to install MS Visual C++ but I received the following error trying to install that:
    Error 1935.An error occurred during the installation of assembly ‘Microsoft.VC80.ATL,type=”win32”,version=”8.0.50727.762”,publicKeyToken=”1fc8b3 b9a1e18e3b”,processorArchitecture=”amd64”’. Please refer to Help and Support for more information. HRESULT: 0x80070BC9. Assembly interface: IassemblyCacheItem, function: Commit, component: {837BF1EB-D770-94EB-A01F-C8B3B9A1E18E}
    Note: The installation of VC++ rolls back when it fails.
    Solution:
    Through this error I found this MSKB article:
    http://support.microsoft.com/kb/946414
    The Automated MS "Fix It" msi package didn’t work.
    Note: Please backup your registry first (see the above MSKB article for instructions).
    I opened the registry and (as instructed in the MSKB article) deleted the following keys:
    HKEY_LOCAL_MACHINE\COMPONENTS\
    PendingXmlIdentifier
    NextQueueEntryIndex
    AdvancedInstallersNeedResolving
    Reboot and reinstall iTunes.
    If it helps you please like this so others can find it.

  • How do I save a website created on IWeb 08 on one computer, so that I can open and adjust it on Iweb 08 on a other computer? pleas help me with this.

    How do I save a website created on IWeb 08 on one computer, so that I can open and adjust it on Iweb 08 on a other computer? pleas help me with this.

    Ernst ~ Welcome to the Support Communities. See this post:
    Editing my iWeb page from another computer

  • Itunes could not connect to the iphone an unknown error occurred 0xE8000003 please help me with this error any one have idea ?

    itunes could not connect to the iphone an unknown error occurred 0xE8000003 please help me with this error any one have idea ?

    http://support.apple.com/kb/ts3221

  • Please help me with this error I keep getting for attachments

    please help me with my error message as I can't download attachments

    Some information would be helpful...  operating system, email client, Reader version, error message, ...

  • HELP Needed with this error:   Exception in thread "main" java.lang.NoClass

    Folks,
    I am having a problem connecting to my MSDE SQL 2000 DB on a WindowsXP pro. environment. I am learning Java and writing a small test prgm to connect the the database. The code compiles ok, but when I try to execute it i keep getting this error:
    "Exception in thread "main" java.lang.NoClassDefFoundError: Test1"
    I am using the Microsoft jdbc driver and my CLASSPATH is setup correctly, I've also noticed that several people have complained about this error, but have not seen any solutions....can someone help ?
    Here is the one of the test programs that I am using:
    import java.sql.*;
    * Microsoft SQL Server JDBC test program
    public class Test1 {
    public Test1() throws Exception {
    // Get connection
    DriverManager.registerDriver(new
    com.microsoft.jdbc.sqlserver.SQLServerDriver());
    Connection connection = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://LAPTOP01:1433","sa","sqladmin");
    if (connection != null) {
    System.out.println();
    System.out.println("Successfully connected");
    System.out.println();
    // Meta data
    DatabaseMetaData meta = connection.getMetaData();
    System.out.println("\nDriver Information");
    System.out.println("Driver Name: "
    + meta.getDriverName());
    System.out.println("Driver Version: "
    + meta.getDriverVersion());
    System.out.println("\nDatabase Information ");
    System.out.println("Database Name: "
    + meta.getDatabaseProductName());
    System.out.println("Database Version: "+
    meta.getDatabaseProductVersion());
    } // Test
    public static void main (String args[]) throws Exception {
    Test1 test = new Test1();

    I want to say that there was nothing wrong
    with my classpath config., I am still not sure why
    that didn't work, there is what I did to resolved
    this issue.You can say that all you like but if you are getting NoClassDefFound errors, that's because the class associated with the error is not in your classpath.
    (For future reference: you will find it easier to solve problems if you assume that the problem is your fault, instead of trying to blame something else. It almost always is your fault -- at least that's been my experience.)
    1. I had to set my DB connection protocol to TCP/IP
    (this was not the default), this was done by running
    the
    file "svrnetcn.exe" and then in the SQL Server Network
    Utility window, enable TCP/IP and set the port to
    1433.Irrelevant to the classpath problem.
    2. I then copied all three of the Microsoft JDBC
    driver files to the ..\jre\lib\ext dir of my jdk
    installed dir.The classpath always includes all jar files in this directory. That's why doing that fixed your problem. My bet is that you didn't have the jar file containing the driver in your classpath before, you just had the directory containing that jar file.
    3. Updated my OS path to located these files
    and....BINGO! (that simple)Unnecessary for solving classpath problems.
    4. Took a crash course on JDBC & basic Java and now I
    have created my database, all tables, scripts,
    stored procedures and can read/write and do all kinds
    of neat stuff.All's well that ends well. After a few months you'll wonder what all the fuss was about.

  • Pleasse help me with this subquery

    HI all,
    I,ve a question.I,ve 2 tables.one has to do with jobs where there are many duties.(see table 1).The other table has to do with jobseekers where they want specific dutie(see table 2)
    table 1"jobs"
    job_id duties compagny
    1 wash dishes kersten
    1 sell Kersten
    2 cook burger king
    2 clean burger king
    table 2"jobseekers"
    jobseeker_id duties name
    1 clean caroline
    1 sell caroline
    2 cook reena
    2 wash dishes caroline
    The output has to be this
    dutienr dutie compagny jobseekername
    1 clean Kersten Caroline
    2 sell Kersten Caroline
    1 cook burger king Reena
    2 wash dishes burger king Caroline
    The idea is that I must write a subquerie
    which will find all the jobseekers with the same dutie as wich the job ask for
    select jobseekers_id,jobseekersname,dutie from jobseekers where duties in (select duties from jobs where compagny ="kersten')
    But I have to split the duties like the output above and I don't know how to do that.
    Can someone pleasse help me.
    Caroline

    Caroline wrote:
    which will find all the jobseekers with the same dutie as wich the job ask forBased on what you say there...
    This sounds like you have companies that are requesting jobseekers who can do all the duties that they require. So kersten requires someone who can do both "wash dishes" and "sell" and burger king require someone who can do both "cook" and "clean".
    If I expand the jobseekers data a little, this can be shown as follows...
    SQL> with jobs as (select 1 as job_id, 'wash dishes' as duties, 'kersten' as compagny from dual union all
      2                select 1, 'sell', 'kersten' from dual union all
      3                select 2, 'cook', 'burger king' from dual union all
      4                select 2, 'clean', 'burger king' from dual)
      5      ,jobseekers as (select 1 as jobseeker_id, 'clean'as duties, 'caroline' as name from dual union all
      6                      select 1, 'sell', 'caroline' from dual union all
      7                      select 2, 'cook', 'reena' from dual union all
      8                      select 2, 'clean', 'reena' from dual union all
      9                      select 2, 'cook', 'caroline' from dual union all
    10                      select 1, 'wash dishes', 'caroline' from dual)
    11  -- end of sample data
    12  select jobs.compagny, jobs.duties, jobseekers.name
    13  from jobs, jobseekers
    14     , (select compagny, count(*) cnt from jobs group by compagny) jobs2 -- the number of duties required by the compagny
    15     , (select compagny, name, count(*) cnt from jobs, jobseekers where jobs.duties = jobseekers.duties group by compagny, name) jobseekers2 -- the number of skills each jobseeker has for each compagny
    16  where jobs2.compagny = jobs.compagny
    17  and   jobseekers2.compagny = jobs.compagny
    18  and   jobseekers2.name = jobseekers.name
    19  and   jobseekers2.cnt = jobs2.cnt          -- pick the person if they can do all the duties the compagny requires
    20  and   jobs.duties = jobseekers.duties
    21  order by compagny, name, duties
    22  /
    COMPAGNY    DUTIES      NAME
    burger king clean       caroline
    burger king cook        caroline
    burger king clean       reena
    burger king cook        reena
    kersten     sell        caroline
    kersten     wash dishes caroline
    6 rows selected.
    SQL>So, from my test data, caroline and reena can both do cooking and cleaning so they could both work at burger king, but only caroline can do selling and washing dishes so is the only one suitable for kersten.
    Is that a little closer to what you are after?

  • Can someone help me with this Error ?

    When I start up my Thinkpad 600E it shows 301 on the first screen and then it goes to the diagnostic/Test screen.
    I run a test on the system board and it comes up with this :
    FRU 0086
                 22
             0010
    I know that there is some issue with the Harddisk. The trackpoint is broke so I have disabled and use an external mouse.
    When I do the keyboard test, the key for F8 keeps blinking (even without pressing it). Could this be an issue ? Is there a work around like disabling the keyboard and using an external one ?
    Or could it be because of the hard disk ?
    Pls help
    Thanks
    Alex

    Is your datacontrol being called? I'd pad it with logs and see if maybe that's throwing an exception and causing a jsf error stack to be generated.

  • Can anyone help me with this error?

    http://prntscr.com/5uou9e
    Getting this error trying to use an intro template. Help?

    Layer 4, 3, and 6 have expressions that are not written correctly. If you select those layers and press the U key twice to reveal all properties, then expand the expressions so we can read them maybe we can figure out the error and help you correct it. The error is telling you that the first line is the problem so the first line is probably pointing to something with the wrong name. Without the details of the expressions it's impossible to tell what's wrong.

  • Please help me with this error message on my lost Crashed Thread:  1  Dispatch queue: NSOperationQueue Serial Queue  Exception Type:  EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000

    I was organizing my contatcs when suddenly it disappeared and got this error message.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if iTunes crashed, you would enter "iTunes" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

  • Help me with this error please. 0xe800065

    This error drives me nuts. When i plug in my iphone 4s the error 0xe800065 pops up in the itunes saying it cant connect. My iphone is also in a bad shape because it just updated from ios 6.0.1 to 6.1 without me knowing it. My iphone needs to activate with wifi connection but then it fails every time or connect with itunes but....  Can somebody please help me?

    There are troubleshooting steps for 0xE errors here: http://support.apple.com/kb/TS3221.

  • Help me with this error: .cfr appears to be malformed or contain errors.

    Hello All,
    I am so new in ColdFusion. I'm trying to move one website (coldfusion) to another hosting.
    I have a problem in cfr pages. I don't know how do I have to see them?
    I couldn't open them in any editor?
    Do I have to install any spesefic software in the destination hosting in order to run them?
    this is the error that I got :
    "some address in the hosting ex: d:/file:report/fff.cfr"  .cfr appears to be malformed or contain errors.
    If any one can help me, I really appreasiate
    thanks you in advansed
    bahar

    I had this issue with some CFR reports that were developed under CF7 and recently (now using CF9/10) we wanted to change a column heading and doing so resulted in this error.
    I made a copy of the file, opened it with Report Builder, ran the Report Wizard which re-styles the report using the in-built styling themes, but then select everything in all the report bands and delete - so now you essentially have a blank report. Then open the original CFR and copy and paste the content of each report band back into the respective bands in the new document and save.
    This got the file working for me. I had to tweak a couple of margins and sizes to make it look the same as the original, but I was back up and running in less than 30 minutes.
    Hope this helps.

  • Can someone help me with this error i keep geting?

    hello, ive been using photoshop for a while and then today i try to open it ad get this error:
    can anyone help me?

    Is there any chance you've copied plug-ins or any other components from an older version of Photoshop into your current installation?
    Do you have 3rd party plug-ins installed, and have you made a change in plug-ins recently?
    It might be helpful if you'd go into Help - System Info, copy that data, and paste it in a post here.
    -Noel

Maybe you are looking for

  • HP High Definition Audio Device Code 10 Error -- Causing HDMI Sound Problem

    Hey guys, my laptop is an HP ENVY TouchSmart m7-j010dx Notebook PC, running Windows 8.1. When I connect my laptop to my LG Smart TV through HDMI, I cant change the playback device to play the sound from the TV. The HDMI option does not appear in ¨Sou

  • ADAPTER.JAVA_EXCEPTION: Sender soap adapter PI 7.11

    Hi I am using the following URL to post a soap message using Sender Soap channel. (We have SAP PI 7.11 (EHP1) sp0) http://<hostname>:50000/XISOAPAdapter/MessageServlet?channel=:Business_Sysytem:Channel. I am getting following exception.. I have searc

  • Photoshop CS4 & Snow Leopard

    I have heard of a number of issues with PS CS4 & SL.  Not all like mine of course but mine is really becoming a nuisance.  I can load and use both PS and Illustrator CS4 with SL but after a period of using PS, my short key functions just stop working

  • ITunes not opening automatically

    iTunes are not opening automatcially while I connect my iPhone?

  • Messed up playback

    iTunes palys all of my purchased audios with a strange echo (as if the batter is low on a cassette player). I'm on Mac OS 10.3.9 Using iTunes 7.1.1 (S) What's wrong? Any help is greatly appreciate it.