Insert into an Access DB

I'm trying toinsert in an access database and when I execute the Update it appears the error:
java.sql.SQLException: No row count was produced
the source code I use is:
<%@ page import="java.io.*"%>
<%@ page import="java.io.IOException"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%
int i=0;
int k,j;
String name="defecte";
String req="defecte";
String url="jdbc:odbc:avimar";
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String query="defecte";
String query2="defecte";
String query3="defecte";
String resultat = new String();
String resultat2 = new String();
Vector vector=new Vector();
Vector vec=new Vector();
Vector vec2=new Vector();
Vector vec3=new Vector();
Class.forName(driver);
Connection con= DriverManager.getConnection(url);
%>
<html>
<head>
<title>Registrar-se a Avimar.net</title>
</head>
<body bgcolor="#8C968C" text="#000000">
<%
String nom =request.getParameter("nom");
String cognoms =request.getParameter("cognoms");
String lg = request.getParameter("login");
String psw =request.getParameter("psw");
String rpsw =request.getParameter("rpsw");
String direccio =request.getParameter("direccio");
String poblacio =request.getParameter("poblacio");
String cpostal =request.getParameter("cpostal");
String telefon =request.getParameter("telefon");
String horaris =request.getParameter("horaris");
query3="INSERT INTO Usuari (id,STR_Login,STR_Psw,STR_Nom,STR_Cognoms,STR_Direccio,STR_Poblacio,STR_Cpostal,STR_Telefon,STR_Horaris,INT_Id_permis,BOOL_Flag_actiu) VALUES (2,'"+lg+"','"+psw+"','"+nom+"','"+cognoms+"','"+direccio+"','"+poblacio+"','"+cpostal+"','"+telefon+"','"+horaris+"',1,true)";
Statement select2=con.createStatement();
System.out.println(query3);
try{
select2.executeUpdate(query);
catch(SQLException ee)
System.out.println("ha petat en el executeUpdate");
ee.printStackTrace();
%> <jsp:forward page="registrat.html">
</jsp:forward>
</body>
<%
select.close();
con.close();
%>
</html>

No idea. You might try re-writing in java and see if it works that way.

Similar Messages

  • Error while inserting into ms access using jsp

    i am using the following code to insert values from textboxes into access database
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection(url);
              Statement stmt=con.createStatement();
              //ResultSet rs = null;
              //String sql = ("INSERT INTO co-ords VALUES ('" + nam + "','" + lat + "','" + lon + "','"+ latm +"','"+ lonm +"','"+ latmd +"','"+ lonmd +"','"+ latms +"','"+ lonms +"') ");
              String sql = "INSERT INTO co-ords (nam ,lat , lon , latm ,lonm , latmd , lonmd ,latms , lonms) VALUES ('" + nam + "','" + lat + "','" + lon + "','"+ latm +"','"+ lonm +"','"+ latmd +"','"+ lonmd +"','"+ latms +"','"+ lonms +"') ";
              out.println(sql);
              stmt.executeUpdate(sql);
    the output i get is
    INSERT INTO co-ords (nam ,lat , lon , latm ,lonm , latmd , lonmd ,latms , lonms) VALUES ('cck','28.656529681148545','77.23440170288086','28','77','39','14','23.508','3.8472') Exception:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    can somebody help me?

    Simple,
    Some error in your query right. Unable to understand Quotation stuff.
    Well understand it properly else error will follow forever :)
    Without String, Straight Away Values
    stmt1.executeUpdate("insert into Login_Details values('Example','Exmaple')");This is the query with Login_Id Pass_Word String containing the value
    stmt1.executeUpdate("insert into Login_Details values('"+Login_Id+"','"+Pass_Word+"')");Then storing sql as string and pass it in executeUpdate(sql)
    String sql="insert into Login_Details values ('example','example') "String + Values in String
    String sql="insert into Login_Details values ('"+example+"','"+example+"') "Just first it . Hope this reply solve ur SQL EXCEPTIONG
    Sachin Kokcha

  • Related to insertion into HASH access method

    Hi,
    I have four multi-threaded processes (2 writer and 2 reader processes), which make use of Berkeley DB transactional data store. I have multiple environments and the associated database and log files are located in separate directories.
    Database access method used is DB_HASH.
    When I looked into stack trace of the Writer process, following is observed:
    A] Indicates insertion into HASH database
    ffffffff7b9a84f4 _pwrite (65, fffffffea28bc6e0, 2000, 3e18000, 7358, 7357) + c
    ffffffff7c667bec __os_io (104c58c80, 3e18000, 104c9f140, 1f0c, 2000, 0) + 29c
    ffffffff7c650fb0 __memp_pgwrite (104c58c80, 104c9c250, fffffffea00e4d98, fffffffea28bc698, 0, 2000) + 200
    ffffffff7c650aa4 __memp_bhwrite (104c58c80, 104c9c250, fffffffea03829e8, fffffffea28bc698, 0, 100c559c0) + 454
    ffffffff7c64fa84 __memp_alloc (fffffffea00e4dc4, fffffffea00e4d98, 1852e6, 0, 104c58c80, fffffffea0000138) + 72c
    ffffffff7c65360c __memp_fget (104ca1a50, 104ca4b54, 0, fffffffea0384c18, 0, fffffffea0000138) + 1bdc
    ffffffff7c5909ac __ham_get_cpage (104ca4920, 0, 104ca4b60, 104ca1a50, 104ca4b40, 104ca14d0) + 1c4
    ffffffff7c57d334 __ham_lookup (104ca4920, fffffffe3e3fb140, 1bb5, 2, fffffffe3e3fa4dc, 104ca4b40) + 74
    ffffffff7c57badc __hamc_put (104ca4920, fffffffe3e3fb140, fffffffe3e3fb118, 34, fffffffe3e3fa4dc, 104ca4b40) + ec
    ffffffff7c603230 __dbc_put (104ca4920, 28, e, 104ca4920, 104ca4920, ffffffff7c794508) + db0
    ffffffff7c5f538c __db_put (104ca14d0, 19f388, 104ca15d8, fffffffe3e3fb140, fffffffe3e3fb118, 0) + 21c
    ffffffff7c60e00c __db_put_pp (104c58c80, 0, fffffffe3e3fb140, fffffffe3e3fb118, 0, 104ca14d0) + 244
    00000001001079f0 __1cLBDBDatabaseGinsert6MrknDstdEpair4CpCC2__IkIIII_v_ (104c9c3a0, 0, 4, 7, 74, 4) + 178
    00000001001b83cc __1cIIndexSetKwriteIndex6MrkirnDstdDmap4n0BEpair4CpCC4__CIn0BEless4n0C___n0BJallocator4n0BEpair4Ckn0C_CI___
    ____i_ (1009ecf80, 104ca7398, 1069fbee0, 74, 45f29f466a48b, 10084bcd0) + b8
    00000001000af1e8 __1cLIndexWriterOpProcessObject6MpnDstdDmap4n0BEpair4CpCC2__CIn0BEless4n0C___n0BJallocator4n0BEpair4Ckn0C_C
    I_______v_ (104ca7240, 1069fbee0, fffffff71e49eb29, 92b0e8920, 100572990, 49587449) + 214
    00000001000b156c __1cbJManagerProducerThreadConsumersModel4nDstdDmap4n0AEpair4CpCC1__CIn0AEless4n0B___n0AJallocator4n0AEpair
    4Ckn0B_CI_______OpDoProcessHook6M_v_ (104ca7240, 1069fbee0, 1003d1, 0, 1005729e0, 1003d120c) + 250
    00000001002bc224 __1cKThreadBaseKmDoProcess6M_v_ (104ca7240, 10043d000, 1000b131c, 104ca72a0, 10043dc6d, 10020e90c) + 1ac
    00000001002bbf44 __1cKThreadBaseQmThreadMainChild6Fpv_1_ (104ca7240, 100572000, 10043d, 0, 10043dbcb, 1005729e0) + ec
    ffffffff7eb17c9c lwpstart (0, 0, 0, 0, 0, 0)
    B] Does the below stack trace indicate the insertion into HASH database? I am getting this doubt because the above and below mentioned stack traces
    differ. Can this happen when the access method used is DB_HASH or is it something to do with application flag / config settings? Please suggest.
    ffffffff7b9a71f4 _pread (65, fffffffeae356140, 2000, 129c8000, 81e6, 81e5) + c
    ffffffff7c667acc __os_io (104c58c80, 129c8000, 104c9f140, 94e4, 2000, 0) + 17c
    ffffffff7c650bfc __memp_pgread (104c9c250, fffffffea0079c58, fffffffeae3560f8, 0, 0, 104c58c80) + 90
    ffffffff7c653928 __memp_fget (104c9c250, 0, fffffffeae3560f8, fffffffea03829e8, 1, fffffffea0000138) + 1ef8
    ffffffff7c5619e8 __bam_get_root (104d1cde0, 2, 20002, 1000, fffffffe3e7fa1e4, 0) + d8
    * ffffffff7c5606ec __bam_rsearch (104d1cde0, 104d1d32c, 3242, 1, 104c9c250, 3242) + 44*
    * ffffffff7c560438 __ram_add (104d1cde0, 104d1d32c, fffffffe3e7fb118, 2, 0, 104d1d200) + 44*
    * ffffffff7c55ecb4 __ramc_put (104d1cde0, fffffffe3e7fb140, fffffffe3e7fb118, e, 0, 0) + 64*
    ffffffff7c6032c0 __dbc_put (104c9f200, 28, e, 104c9f200, ffffffff7c55ec50, e) + e40
    ffffffff7c5f538c __db_put (104c9bc60, 19f388, 104c9bd68, fffffffe3e7fb140, fffffffe3e7fb118, 0) + 21c
    ffffffff7c60e00c __db_put_pp (104c58c80, 0, fffffffe3e7fb140, fffffffe3e7fb118, 0, 104c9bc60) + 244
    00000001001079f0 __1cLBDBDatabaseGinsert6MrknDstdEpair4CpCC2__IkIIII_v_ (104c95790, 0, 4, 7, 74, 4) + 178
    00000001001b83cc __1cIIndexSetKwriteIndex6MrkirnDstdDmap4n0BEpair4CpCC4__CIn0BEless4n0C___n0BJallocator4n0BEpair4Ckn0C_CI___
    ____i_ (1009ecf80, 104ca6ee8, 105f8a580, 74, 45f29f466b002, 10084bcd0) + b8
    00000001000af1e8 __1cLIndexWriterOpProcessObject6MpnDstdDmap4n0BEpair4CpCC2__CIn0BEless4n0C___n0BJallocator4n0BEpair4Ckn0C_C
    I_______v_ (104ca6d90, 105f8a580, fffffff71e49eb29, 92b0e8920, 100572990, 49587449) + 214
    00000001000b156c __1cbJManagerProducerThreadConsumersModel4nDstdDmap4n0AEpair4CpCC1__CIn0AEless4n0B___n0AJallocator4n0AEpair
    4Ckn0B_CI_______OpDoProcessHook6M_v_ (104ca6d90, 105f8a580, 1003d1, 0, 1005729e0, 1003d120c) + 250
    00000001002bc224 __1cKThreadBaseKmDoProcess6M_v_ (104ca6d90, 10043d000, 1000b131c, 104ca6df0, 10043dc6d, 10020e90c) + 1ac
    00000001002bbf44 __1cKThreadBaseQmThreadMainChild6Fpv_1_ (104ca6d90, 100572000, 10043d, 0, 10043dbcb, 1005729e0) + ec
    ffffffff7eb17c9c lwpstart (0, 0, 0, 0, 0, 0)
    Details about the application are as follows:
    For Writer / Reader:
    Environment flags : DB_CREATE | DB_INIT_MPOOL | DB_THREAD | DB_INIT_LOCK | DB_INIT_TXN
    Following are the parameters to db-&gt;open function call:
    WRITER*
    DB-&gt;open(DB *db,
    DB_TXN *txnid, =&gt; NULL
    const char *file, =&gt; file name
    const char *database, =&gt; NULL
    DBTYPE type, =&gt; DB_HASH
    u_int32_t flags, =&gt; DB_READ_UNCOMMITTED | DB_AUTO_COMMIT | DB_CREATE | DB_THREAD
    int mode =&gt; 0);
    Also, DB_DUP flag is set.
    READER_
    DB-&gt;open(DB *db,
    DB_TXN *txnid, =&gt; NULL
    const char *file, =&gt; file name
    const char *database, =&gt; NULL
    DBTYPE type, =&gt; DB_UNKNOWN
    u_int32_t flags, =&gt; DB_READ_UNCOMMITTED | DB_RDONLY | DB_AUTO_COMMIT | DB_THREAD
    int mode =&gt; 0);
    DB_CONFIG file contents are as follows:
    set_cachesize 0 536870912 1
    set_lg_bsize 10485760
    set_data_dir DATADIR
    set_lg_dir LOGDIR
    set_lk_max_locks 100000
    set_lk_max_lockers 100000
    set_lk_max_objects 100000
    set_flags DB_REGION_INIT
    set_tx_max 150
    mutex_set_increment 7500
    Thanks,
    Magesh

    Hi Nandish,
    DB statistics were collected using the following command:
    db_stat -d <database name>
    When db_stat and db_verify utilities were run during the application runtime, both of them failed for most of the databases.
    Please find below sample output for db_stat and db_verify utilities for 'SUBID_P1_S1_FF3' DB:
    Sun Jan 4 07:55:28 2009 Local time
    db_stat: page 44972: illegal page type or format
    db_stat: PANIC: Invalid argument
    db_stat: PANIC: fatal region error detected; run recovery
    db_stat: close: DB_RUNRECOVERY: Fatal error, run database recovery
    db_stat: File handles still open at environment close
    db_stat: Open file handle: /opt/vol1/data/SUBID_P1_S1_FF3
    db_stat: PANIC: fatal region error detected; run recovery
    db_stat: dbenv->close: DB_RUNRECOVERY: Fatal error, run database recovery
    db_verify: Page 44972: duplicate page of inappropriate type 13
    db_verify: Page 20769: record count incorrect: actual 285, in record 286
    db_verify: Page 9337: bad record count: has 867 records, claims 868
    db_verify: Page 44497: record count incorrect: actual 88, in record 81
    db_verify: Page 21317: bad record count: has 670 records, claims 663
    db_verify: Page 4524: record count incorrect: actual 273, in record 275
    db_verify: Page 1141: bad record count: has 2601 records, claims 2603
    db_verify: Page 40872: record count incorrect: actual 380, in record 382
    db_verify: Page 20150: bad record count: has 962 records, claims 964
    db_verify: Page 44984: duplicate page of inappropriate type 0
    db_verify: Page 43953: record count incorrect: actual 9, in record 8
    db_verify: Page 9877: bad record count: has 591 records, claims 590
    db_verify: Page 44994: duplicate page of inappropriate type 0
    db_verify: Page 41115: record count incorrect: actual 100, in record 101
    db_verify: Page 9279: bad record count: has 682 records, claims 683
    db_verify: Page 44975: duplicate page of inappropriate type 13
    db_verify: Page 44997: duplicate page of inappropriate type 0
    db_verify: Page 8113: item 0 hashes incorrectly
    db_verify: Page 8113: item 4 hashes incorrectly
    db_verify: Page 8113: item 8 hashes incorrectly
    db_verify: Page 8143: item 40 hashes incorrectly
    db_verify: Page 8143: item 42 hashes incorrectly
    db_verify: Page 8143: item 46 hashes incorrectly
    db_verify: Page 8143: item 60 hashes incorrectly
    db_verify: Page 8143: item 62 hashes incorrectly
    db_verify: Page 39405: hash page has bad prev_pgno
    db_verify: Page 8145: item 4 hashes incorrectly
    db_verify: Page 8145: item 10 hashes incorrectly
    db_verify: Page 8145: item 20 hashes incorrectly
    db_verify: Page 8145: item 22 hashes incorrectly
    db_verify: Page 8145: item 28 hashes incorrectly
    db_verify: Page 8145: item 32 hashes incorrectly
    db_verify: Page 8145: item 38 hashes incorrectly
    db_verify: Page 8145: item 40 hashes incorrectly
    db_verify: Page 8145: item 48 hashes incorrectly
    db_verify: Page 44993: duplicate page of inappropriate type 0
    db_verify: Page 42178: record count incorrect: actual 581, in record 582
    db_verify: Page 40166: btree or recno page is of inappropriate type 13
    db_verify: Page 40166: record count incorrect: actual 0, in record 62
    db_verify: Page 9206: bad record count: has 2909 records, claims 2972
    db_verify: Page 44985: hash page has bad prev_pgno
    db_verify: Page 21250: record count incorrect: actual 494, in record 491
    db_verify: Page 9834: bad record count: has 1076 records, claims 1073
    db_verify: Page 39247: duplicate page of inappropriate type 13
    db_verify: Page 44973: duplicate page of inappropriate type 13
    db_verify: Page 20460: btree or recno page is of inappropriate type 13
    db_verify: Page 20460: record count incorrect: actual 0, in record 9
    db_verify: Page 20390: bad record count: has 4656 records, claims 4665
    db_verify: Page 44696: unterminated leaf chain
    db_verify: Page 43989: record count incorrect: actual 22, in record 21
    db_verify: Page 8917: bad record count: has 604 records, claims 603
    db_verify: Page 44982: hash page has bad prev_pgno
    db_verify: Page 45000: hash page has bad prev_pgno
    db_verify: Page 44981: duplicate page of inappropriate type 13
    db_verify: Page 44990: hash page has bad prev_pgno
    db_verify: Page 38676: record count incorrect: actual 107, in record 106
    db_verify: Page 4486: bad record count: has 689 records, claims 688
    db_verify: Page 39602: record count incorrect: actual 127, in record 129
    db_verify: Page 9202: bad record count: has 709 records, claims 711
    db_verify: Page 21291: record count incorrect: actual 175, in record 176
    db_verify: Page 4585: bad record count: has 757 records, claims 758
    db_verify: Page 44897: record count incorrect: actual 219, in record 95
    db_verify: Page 2259: bad record count: has 3129 records, claims 3005
    db_verify: Page 44987: duplicate page of inappropriate type 0
    db_verify: Page 44979: duplicate page of inappropriate type 13
    db_verify: Page 9055: duplicate page of inappropriate type 13
    db_verify: Page 44980: hash page has bad prev_pgno
    db_verify: Page 44971: duplicate page of inappropriate type 13
    db_verify: Page 39405: hash page referenced twice
    db_verify: Page 44995: duplicate page of inappropriate type 0
    db_verify: Page 38457: hash page has bad prev_pgno
    db_verify: Page 44986: duplicate page of inappropriate type 0
    db_verify: Page 44179: btree or recno page is of inappropriate type 13
    db_verify: Page 44179: record count incorrect: actual 0, in record 582
    db_verify: Page 44999: btree or recno page is of inappropriate type 0
    db_verify: Page 44999: record count incorrect: actual 0, in record 2
    db_verify: Page 4709: bad record count: has 0 records, claims 584
    db_verify: Page 41333: record count incorrect: actual 55, in record 54
    db_verify: Page 9531: bad record count: has 637 records, claims 636
    db_verify: Page 44970: hash page has bad prev_pgno
    db_verify: Page 38400: record count incorrect: actual 132, in record 131
    db_verify: Page 9811: bad record count: has 714 records, claims 713
    db_verify: Page 40735: duplicate page of inappropriate type 13
    db_verify: Page 44996: duplicate page of inappropriate type 0
    db_verify: Page 44998: hash page has bad prev_pgno
    db_verify: Page 44991: hash page has bad prev_pgno
    db_verify: Page 44988: duplicate page of inappropriate type 0
    db_verify: Page 44516: hash page has bad prev_pgno
    db_verify: Page 44976: duplicate page of inappropriate type 13
    db_verify: Page 43273: record count incorrect: actual 289, in record 280
    db_verify: Page 1082: bad record count: has 2035 records, claims 2026
    db_verify: Page 42154: record count incorrect: actual 78, in record 79
    db_verify: Page 18214: bad record count: has 660 records, claims 661
    db_verify: Page 44992: duplicate page of inappropriate type 0
    db_verify: Page 42067: record count incorrect: actual 496, in record 487
    db_verify: Page 2266: bad record count: has 2824 records, claims 2815
    db_verify: Page 43694: record count incorrect: actual 23, in record 26
    db_verify: Page 9294: bad record count: has 605 records, claims 608
    db_verify: SUBID_P1_S1_FF3: DB_VERIFY_BAD: Database verification failed
    After restarting the application, db_stat and db_verify utilities worked fine. Without running db_recover, if these commands are working fine means it is not a genuine case of database corruption.
    Is it something to do with the way in which db_stat and db_verify utilities work?
    We will also try using -h option for db_stat and db_verify utilities.
    Thanks,
    Magesh

  • Inserting into MS Access Database - Wierd resultset!!

    I'm developing an application that takes in values from t1 in the database, performs operations on them and inserts them into t2. For this I have to check all records in t2 every time I'm about to make an insertion.. Strangely enough, rs1.beforeFirst() (rs1 is the resultset for t2) in my code refuses to put the cursor before the 1st row, and the code continues operations from the last row..Help!!
    Here's a sample of my code:
    rs1.beforeFirst();
                   if(rs1.next())
                        do
                             if(rs1.getInt("uid")!=i)
                             {     rs1.next();     }
                             else
                             {     break;
                        }while(!rs1.last());
                        if(rs1.isAfterLast())
                        {     n=1;
                             s1="Insert into t_urlinfo values('" + dt + "'," + i + ",'" + text + "'," + n + ")";
                             System.out.println(s1);
                             stmt2.executeUpdate(s1);
                        }

    Where, in that code, are you calling beforeFirst?
    Also, why do you feel it necessary to "check every row" before an insert? Is it to avoid duplicates? If so, does your table have a primary key or other unique field? If so, simply attempt to insert and then catch the SQLException.

  • Insert into Microsoft access 2010 Database on sharepoint using OLEDB

    Hi,
    want to insert data into a microsoft access web db using oledb object. but the i am unable to open the database.
        dbLoc = "http://XXXX.com/project/design/Test_Web_DB
        Dim strConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " & dbLoc
        Try
                con = New OleDb.OleDbConnection(strConnection)
                If con.State = ConnectionState.Closed Then con.Open()
        Catch ex As OleDbException
               MsgBox("OleDbException: Unable to Open DB")
        End Try
    it always go to the exception. is there any problem with the above code??

    Hey Bala,
    Browsing the link (as shown below) on the browser doesnt open the DB.
    http://XXXX.com/project/design/Test_Web_DB.accdb
    Instead, without ".accdb" works.
    my requirement is something like below, please recommend your suggestion
    1. i have a DB on access 2010, which gets updated on regular basis (currently db is on common location) by different VB.net application client my the network
    2. i want to create various reports out of the data and want them visible available on sharepoint.
    please help
    -Manash

  • Inserting data into Ms Access via jdbc odbc connectivity

    Can anyone help dictate what's wrong with this below method which is supposed to be adding new record(append) into my ms Access Table. This is giving me a hell of problem, I thought I have everything well. The module is branched via a Swing ui. Can you debug this ? and send a new code to try?
    public void Query3(){
    try{
    //while(rs.next() )
    stmt.executeUpdate("INSERT INTO pupRegister_Table1 " +
         "VALUES ('1001', 'Simpson', 'Mr.', 'Springfield', '2001')");
    //stmt.executeUpdate ("INSERT INTO pupRegister_Table1 " +
    //"VALUES(var_firstname)");
    // Close the result set, statement and the connection
    rs.close() ;
    stmt.close() ;
    conn.close() ;
    } catch( SQLException se )
    System.out.println( "SQL Exception:" ) ;
    Thanks. Note I have done all the DriverManager stuff already and other modules like for displaying the records, do work fine.

    Thanks a lot,
    that contribution really helped but I realised that I Missed adding the
    insertRow();
    that did the trick and it works fine now
    Thanks
    Yet another issue is about inserting the current date into the date field having data type as date. Hence I am using the Jdbc stuff. I am having problem here
    any further help?

  • Insert Time and Date into Microsoft Access from Lookout

    I have an SQLExec running to export data to Microsoft Access - I would like to get A) A time stamp also to insert and B) A time stamp with out / and : -- I have found it impossible (from my limited knowledge) to do any of these things.
    Dose anyone have a very basic SQL Statement that might guide me on my way?
    Thanks!

    Oracle stores date and time in a DATE column; it all depends on how you have your insert statement. The last insert I specified the date and time
    ex.
    insert into test_date values(1,sysdate);
    insert into test_date values(2,sysdate-10.9);
    insert into test_date values(3,sysdate-8.098 );
    insert into test_date values(4,sysdate-5.11 );
    insert into test_date values(5, trunc(sysdate));
    INSERT into test_date values(6, to_date('01-JAN-2004 19:30', 'DD-MON-YYYY HH24:MI') );
    select * from test_date ;
    ID DDATE
      1 25-FEB-04
      3 17-FEB-04
      4 20-FEB-04
      5 25-FEB-04
      2 14-FEB-04
      6 01-JAN-04I don't see the time because the NLS_DATE_FORMAT is set to DD-MON-YY, but if I
    Select id, to_char( ddate , 'DD-MON-YYYY HH24:MI:SS AM') from test_date;
    ID TO_CHAR(DDATE,'DD-MO
    1 25-FEB-2004 06:57:02
    3 17-FEB-2004 04:37:05
    4 20-FEB-2004 04:20:02
    5 25-FEB-2004 00:00:00
    2 14-FEB-2004 09:24:50
    6 01-JAN-2004 19:30:00

  • How to insert date into ms access database using sql query in servlet

    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
      plz help me
    thanx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    bhavishya wrote:
    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
    plz help me
    thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.

  • How to insert bulk data into ms-access

    Hi,
    I am trying to insert bulk data into ms-access. I used Statement it is
    working fine but not allowing to insert single quote. Then I tryed with
    PreparedStatement which is allowing single quote but not allowing bulk data. The following error i am getting.
    javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver]String data, right truncated (null)
    please help me..
    guru

    have u tried out the memo datatype in access?

  • Insert records into an Access

    I am trying to insert records into an Access document but
    when trying to execute the action page I get the following:
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Too few
    parameters. Expected 1.
    The error occurred in
    C:\ColdFusion8\wwwroot\ASK\AskAction.cfm: line 17
    15 :
    16 :
    17 : values ('#trim(form.qname)#', '#trim(form.email)#',
    #DateVariable2#, #Val(form.Mathques)#, '#(form.quest)#')
    18 :
    19 : </cfquery>
    SQLSTATE 07002
    SQL insert into table1 (qname,
    email,qdate,recipient,question) values ('bill', '[email protected]',
    13-Oct-08, 0, '45x9 ')
    VENDORERRORCODE -3010
    DATASOURCE ques
    Resources:
    Check the ColdFusion documentation to verify that you are
    using the correct syntax.
    Search the Knowledge Base to find a solution to your problem.
    Browser Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;
    SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506;
    InfoPath.2)
    Remote Address 0:0:0:0:0:0:0:1
    Referrer
    http://localhost:8500/ask/ASKform.cfm
    Date/Time 13-Oct-08 09:07 PM
    Stack Trace (click to expand)
    thanks,
    Steve

    what are your data types for the recipient and qdate columns?
    - you could try putting quotes around the date object, i always
    forget if they're needed or not with date objects

  • Date/Time Field in Access 2000 - INSERT INTO ... syntax error

    I am using Labview 6.1 Professional with the Database Connectivity Toolkit. When I execute this SQL Command "INSERT INTO PRODUCTION (Part, Passed, Date) VALUES ('Part#1', 2, '10/10/2003 10:10:10 AM')" I get a Run-Time Syntax Error. If I remove the Date Label and Date Value it works. What is the proper Format of the Date/Time Type Field in ACCESS 2000 for Labview 6.1 SQL? I have seen and tried all of the solutions already posted like MSG 1ZNAJHJ6.

    Well, if it's any consolation handling dates is a pain regardless of which database you use. In any case, I created a table with the following definition:
    CREATE TABLE testing
    (item1 INTEGER,
    item2 DATE)
    I them did the following insert:
    INSERT INTO testing
    VALUES (1, '18/11/1953 04:20:00');
    And everything worked fine. Note that in the date (my Bday, BTW) the format is DD/MM/YYYY followed by the time.
    What exactly is the error you're getting? Can you post the exact text of the error message. Also, I ran my test using the examples that come with LabSQL--not the toolkit.
    Mike...
    Oops, just noticed something. You have a column name that is probibly a reserved word "Date". Try your insert as:
    INSERT INTO PRODUCTION
    VALUES
    ('Part#1', 2, '10/10/2003 10:10:10 AM')
    If there is only those three columns and they the order the data appears is the same as the column order, you don't need the column list. If this works (and it should--I just tried it) I would only view it as a temporary patch. The column name should be changed.
    This is also a good reason to not use the Access GUI to create tables. If you tried creating a table like that in SQL you would have gotten an error message. Learning to build tables in SQL code isn't hard and it adds an extra layer of error checking that the GUI apparently doesn't think is important.
    If you're interested let me know and I can send you the info on a really good book on SQL...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Problem inserting into access database.

    I am using the following code to create a table and insert values into an access database. Problem is that it only inserts the first 3 values no matter what order they are in. Any help is appreciated, and thanks in advance.
          stmt.executeUpdate("CREATE TABLE HardDrive (HardDriveID VARCHAR(10),"           + " HardDriveName VARCHAR(30), HardDriveSize VARCHAR(6), Price CURRENCY)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD3000HLFS','Western Digital VelociRaptor','300 GB',229.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST31000528AS','Seagate Barracuda','1 TB',99.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('ST3250310AS','Seagate Barracuda','250 GB',47.99)");       stmt.executeUpdate("INSERT INTO HardDrive VALUES ('WD10EADS','Western Digital Caviar Green','1 TB',89.99)");

    What did I tell you about not using Access?
    This is exactly why. This is an Access related issue, and one that has been discussed many times previously on this site.
    Choose. Another. Database.

  • Servlet not inserting into Access Databse. help please

    I have the following code which is inserting three fields into a database. The database name is contacts.mdb, and the table is contacts. I have setup the ODBC connection on the server, of which I have both IIS and Tomcat running. The form.html that I am accessing is on the tomcat server root and that code is below as well. After hitting the submit button on the form I get forwarded to the servlet, and the page is blank. However, when I open the database, no updates have occured. Please help. I hope I have provided enough detail. Thanks so much.
    -------- servlet code start --------------
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class WebServlet
    extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
    IOException {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = "jdbc:odbc:terry_web_contacts";
    Connection databaseConnection = DriverManager.getConnection(sourceURL);
    Statement stmt = databaseConnection.createStatement();
    String jname = request.getParameter("Name");
    String jemail = request.getParameter("Email");
    String jcomments = request.getParameter("Comments");
    String sqlInsertString ="INSERT INTO contacts (name, email, comments) VALUES ('" + jname +"', '" jemail "', '" + jcomments + "')";
    stmt.executeUpdate(sqlInsertString);
    databaseConnection.close();
    catch(ClassNotFoundException cnfe)
    System.err.println("Error loading Driver");
    catch (SQLException sqle){
    System.err.println("SQL Error");
    ---------- servlet code end ---------------------
    ---------- html form code start ------------------
    <HTML>
    <HEAD>
    <TITLE>Example</TITLE>
    </HEAD>
    <BODY BGCOLOR="WHITE">
    <TABLE BORDER="2" CELLPADDING="2">
    <TR><TD WIDTH="275">
    <H2>I'm a Simple Form</H2>
    <FORM METHOD="POST" ACTION="/servlet/WebServlet">
    <p>
    <INPUT NAME="Name" TYPE="TEXT" id="Name" SIZE=30>
    </p>
    <p>
    <INPUT NAME="Email" TYPE="TEXT" id="Email" SIZE=30>
    </p>
    <p>
    <textarea name="Comments" id="Comments"></textarea>
    </p>
    <P>
    <INPUT TYPE="SUBMIT" VALUE="Click Me">
    <INPUT TYPE="RESET">
    </FORM>
    </TD></TR>
    </TABLE>
    </BODY>
    </HTML>
    ------------- html code end ------------------

    Okay, here is my modified code. However, I catch a sql error. It prints out "sql error". If I try to isolate the different lines of code with try catch blocks, the compiler says it does not recognize the symbols for example stmt, or databaseConnection. Arggh, what can I do? Help please.
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class WebServlet
        extends HttpServlet {
      public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException,IOException
         PrintWriter out = response.getWriter();
         String jname = (String) request.getParameter("Name");
         String jemail = (String) request.getParameter("Email");
         String jcomments = (String) request.getParameter("Comments");
    try
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(ClassNotFoundException e)
         out.println("class error");
    try
         Connection databaseConnection = DriverManager.getConnection("jdbc:odbc:terrycontacts");
         Statement stmt = databaseConnection.createStatement();
         String sqlInsertString ="INSERT INTO contacts(name,email,comments) VALUES('"+jname+"','"+jemail+"','"+jcomments+"')";
         stmt.executeQuery(sqlInsertString);
         databaseConnection.commit();
         databaseConnection.close();
    catch(SQLException e)
         out.println("sql error");
         out.close();
    }

  • I can insert data into an access database, but I need to querry the database for specific information. How do I do it?

    I can insert data into an access database, now I need to do some simple querries such as selecting all records that are greater than a certain value or = a certain value. How can I return only the selected records?

    If you don't want to spend any money, then instead of ActiveX, I would recomend LabSQL from Jeffrey Travis. I use it instead of the Connectivity toolkit and have had no problems. Besides being free, you have the advantage of being able to use it with any database. ActiveX ties you to Access and you upgrade your version of Access and find the properties and methods are different, you've got a lot of reprogramming to do.

  • UPDATE/INSERT INTO with Connection with access DB

    Hello,
    I am trouble getting the update statement working when connecting to my database. The "Select" statement works fine but i am using:
    result2= stmt2.executeUpdate("INSERT INTO Table1 VALUEs('1', '1')");
    and i get the error incompatiable types...found int but expected java.sql.resultset
    I am not sure what i am doing wrong. Can anyone help?

    since you're using Access, be sure to close both your Statement and the Connection you used after your INSERT/UPDATE. It's well known that changes won't show up in Access unless you do.
    %

Maybe you are looking for