Insert values to access through checkboxes

hi,
i need to get insert values into the ms-access database through clicking checkboxes.let me tell in detail.
iam writing jsp source for inserting data into the msaccess. when i insert text data type those records are inserting but, when i write checkbooxes in the form and submit to access. it is giving as datatype mismatch cretirial. i donot know how to do. i am giving that code. please help me. thanks
i need the code for using bean with jsp. ie, business logic should be saved in java bean . and properties in the jsp. idonot know how to use bean to insert update database(ms-access) with jsp. kindly giv e code for the bean and jsp.when i go google search those are not executing.anybody can give that code please
thanks<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%! Connection conn;
   PreparedStatement stmtSelect;
   PreparedStatement stmtInsert;
   PreparedStatement stmtUpdate;
public void jspInit() {
    try{
      String url  = "jdbc:odbc:databaseone";
      String id   = "myID";
      String pass = "myPass";
      String sqlSelect 
        = "SELECT * FROM garden1 WHERE(LOWER(Genus) " +
          "LIKE ? OR LOWER(Species) LIKE ?) ORDER BY id";
      String sqlInsert="INSERT INTO garden1(id,family,Genus,Species,id_code,author,commonname) VALUES (?,?,?,?,?,?,?)";
   String sqlUpdate="UPDATE garden1 SET id=?, family =?, Genus = ?, Species= ?, id_code = ?,author=?,commonname=? WHERE id= ?";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      conn = DriverManager.getConnection(url, id,pass);
      stmtSelect = conn.prepareStatement(sqlSelect);
      stmtInsert = conn.prepareStatement(sqlInsert);
      stmtUpdate = conn.prepareStatement(sqlUpdate);
    }catch(SQLException e){}
    catch(ClassNotFoundException e){}
  public void jspDestroy() {
    try {
       stmtSelect.close();
     stmtInsert.close();
     stmtUpdate.close();
       conn.close();
    } catch(SQLException e) {}
%>
<% if (request.getParameter("action")== null) { %>
<%
java.sql.Connection con;   
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
java.util.Properties props = new
java.util.Properties();
con =
DriverManager.getConnection("jdbc:odbc:databaseone","myID","myPass");
java.sql.Statement stmt;
java.sql.ResultSet rs;
java.sql.ResultSetMetaData metaData;
int numCols;
stmt = con.createStatement();
rs = stmt.executeQuery("Select * from garden1");
metaData = rs.getMetaData();
numCols = metaData.getColumnCount();
%> <h4 align=left >TABLE OF employee</H4>
<TABLE BORDER="1" ALIGN=CENTER>
<THEAD>
<TD><B>ID</B></TD>   
   <TD><B>FAMILY</B></TD>
   <TD><B>GENUS</B></TD>
<TD><B>SPECIES</B></TD>
<TD><B>ID-CODE</B></TD>
<TD><B>AUTHOR</B></TD>
<TD><B>COMMON-NAME</B></TD>
</THEAD>
<TR>
<% while(rs.next()) { %>
<% for(int i=1; i <= numCols; i++)  { %>
   <TD><%= rs.getString(i) %></td>
<%   
}  //  end of for loop
out.println("</tr>");
}  //  end of while loop
rs.close();
%>      
<HTML>  <HEAD><TITLE>Add/UpdateDatabase</TITLE></HEAD><body>
<FORM METHOD="post"  ACTION="<%= request.getRequestURI()%>">
  <INPUT TYPE="hidden" NAME="action" VALUE="form">
  <INPUT TYPE="submit" name=newentry VALUE="New Entry"><BR>  <BR>   </FORM> </BODY> </HTML>
<% } else if
(request.getParameter("action").equals("form")) { %>
<% String id="", family="", Genus ="",Species="";
       String id_code="",author="";
       String commonname="";
  if (request.getParameter("query") != null) {
      String searchVar =request.getParameter("query");
        try{
            ResultSet rset = null;
           synchronized(stmtSelect){ stmtSelect.setString(1, "%" + searchVar +"%");
                        stmtSelect.setString(2, "%" + searchVar +"%");
                        rset = stmtSelect.executeQuery();
         if (rset.next()) {
         if (rset.getString("id") != null) id =   rset.getString("id");
                if (rset.getString("family") != null)family=  rset.getString("family");
                if (rset.getString("Genus") != null)Genus =  rset.getString("Genus");
                if (rset.getString("Species") != null)Species =rset.getString("Species");
                if (rset.getString("id_code") != null)id_code =rset.getString("id_code");
                if (rset.getString("author") != null)author =rset.getString("author");
                if (rset.getString("commonname") != null)commonname =   rset.getString("commonname");
      if (rset.next())
out.print("<SCRIPT>alert(\"The search you made hasmore than one result! Use your browser's back buttonto refine search.\")</SCRIPT>");
    } catch(SQLException e){}
%> <HTML> <HEAD> <TITLE>Database Entry</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <H2>Database Entry:</H2>
<FORM METHOD="post" ACTION="<%=request.getRequestURI() %>">
    <TABLE WIDTH="400" BORDER="0"><TR> <DIV ALIGN="right">
     <TD>   ID:  </TD>  <TD> <INPUT TYPE="text" NAME="id" VALUE="<%= id%>"> </TD></tr><tr>
     <TD> family:</TD><TD>   <INPUT TYPE="checkbox" NAME="family" VALUE="<%=family %>">  </TD></tr><tr>
     <TD> genus:</TD><TD><INPUT TYPE="text" NAME="Genus" VALUE="<%=Genus %>"> </TD> </tr><tr>
     <TD> species:</TD><TD> <INPUT TYPE="text" NAME="Species"VALUE="<%= Species %>"> </TD></tr><tr>
     <TD>idcode:</td><TD><INPUT TYPE="text" NAME="id_code"VALUE="<%= id_code%>"> </TD></tr><tr> 
     <TD>author:</TD><TD><INPUT TYPE="text" NAME="author"  VALUE="<%= author%>">   </TD></tr><tr>
     <TD>commonname:</TD><TD><INPUT TYPE="checkbox" NAME="commonname" VALUE="<%= commonname%>"> </TD> </TR></div>
        <TR>  <TD WIDTH="100">    <INPUT TYPE="submit" NAME="Submit"VALUE="Submit"> </TD>
        <TD WIDTH="300">   <INPUT TYPE="reset" NAME="Reset"VALUE="Reset">
      <% if (id != ""){ %>
         <INPUT TYPE="hidden" NAME="action"VALUE="update">
      <% } else { %>
         <INPUT TYPE="hidden" NAME="action"VALUE="insert">
         <INPUT TYPE="hidden" NAME="action"VALUE="select">  
      <%}  %>       </TD>     </TR>   </TABLE> </FORM> </BODY> </HTML>
<% } else if
(request.getParameter("action").equals("insert")) { %>
<%
try{
     synchronized(stmtInsert){
      stmtInsert.setString(1,request.getParameter("id"));
       stmtInsert.setString(2,request.getParameter("family")); 
       stmtInsert.setString(3,request.getParameter("Genus"));
       stmtInsert.setString(4,request.getParameter("Species"));
       stmtInsert.setString(5,request.getParameter("id_code"));
       stmtInsert.setString(6,request.getParameter("author"));
       stmtInsert.setString(7,request.getParameter("commonname"));
       stmtInsert.executeUpdate(); 
   out.print("Record Successfully Entered. <BR><A HREF=\"" + request.getRequestURI() +
           "\">Return</A>");
   } catch (SQLException e){
     out.print("Record Entry Failed! <BR><A HREF=\"" + request.getRequestURI() +
           "\">Return</A>");
     out.print("<br>" + e.getMessage());
} else if
(request.getParameter("action").equals("update")) {
  try{
     synchronized(stmtUpdate){
      stmtUpdate.setString(1,request.getParameter("id"));
          stmtUpdate.setString(2,request.getParameter("family")); 
          stmtUpdate.setString(3,request.getParameter("Genus"));
          stmtUpdate.setString(4,request.getParameter("Species"));
          stmtUpdate.setString(5,request.getParameter("id_code"));
          stmtUpdate.setString(6,request.getParameter("author"));
          stmtUpdate.setString(7,request.getParameter("commonname"));
       stmtUpdate.executeUpdate();
   out.print("Record Successfully Updated. <BR>" +
           "<A HREF=\"" + request.getRequestURI() +
           "\">Return</A>");
   } catch (SQLException e){
     out.print("Record Update Failed! <BR>" +
           "<A HREF=\"" + request.getRequestURI() +
           "\">Return</A>");
     out.print("<br>" + e.getMessage());
%>
<% } %>

Oh...also...
It seems that you haven't sufficiently normalized the problem (I've seen absolutely zero problems that, when sufficiently normalized, require 1000 columns).
Perhaps you should think about doing two tables, one with "Machines" and the other with "MachineData". The Primary Key from the Machines table could be a foreign key into the MachineData table, in which all of your data is stored.
If you're serious about using an RDBMS for problems more complex than tracking your home music library, I'd recommend reading up on at least a bit of database theory (but I'm an admitted nerd, and find it interesting anyhow).
I'd heartily recommend "Fundamentals of Database Systems" by Navathe and Elmasri as a starting point.

Similar Messages

  • Can constant values be accessed through EL?

    I am trying to redo some pages that have used a lot of embedded java and replace that with JSTL and EL. Does EL provide a way to access the value of a constant? If I have a class named MyDefines, and I want to access the value of the constant MY_VALUE, is there a way to access this using EL, or would I just need to use a java scriptlet?
    For example
    <c:set var="val" value="MyDefines.MY_VALUE" />or
    <c:set var="val" value="<%= MyDefines.MY_VALUE %>" />I know that the second way works, but I didn't know if the spec provided for a way to access the value of constants in a similar way to the first code sample or not.

    See if this will help you
    http://forum.java.sun.com/thread.jsp?forum=45&thread=508847

  • Error when inserting Adhoc characteristic value next time through SDK

    Hi,
    while inserting an adhoc characteristic value to person through algorithm with different effective dates its working fine
    for the first time but for the second time its showing error like "morethan one row matches the specified criteria"
    --while entering manually through front-end  its allowing to insert two values for the same characteristic type with different effective dates but if we edit any one of them its showing same error ......
    can any one help me out in this? Is there any restriction that there should be only one characteristic value for one characteristic type in an entity?
    thanks
    sivaram

    Suggestions for your ODP.NET code.
    1.
    using Oracle.DataAccess.Types;
    OracleBlob myBlob = new OracleBlob(con);
    myBlob.Write(myByteArray, 0, count); //where myByteArray is populated by a file stream and count is the number of bytes to be written to myBlob
    cmd.Parameters[0].Value = myBlob;
    2. Check only when it's not null then dispose blob object, command object, and connection object. (No need to close connection before dispose)
    This is not relevant to the issue.
    Edited by: shsu on Jan 12, 2012 4:16 PM

  • I want to access multiple checkbox  value(its true or false when clicked)

    dear sir
    i want to access multiple checkbox value whether its true or not from one jsp to another jsp.how i can do this. because based upon checkboxes records are deleted and added.
    when i check on checkboxes and click on delete button the records are deleted onlybased upon checks.and these request forward to another jsp.so plz tell me about this.
    for example in gmail yahoomail or other mail various checkboxes are there. and if we check them and click on delete button then all checks mail are deleted.
    i will be very thankul to u sir..
    plz tell me.in this time i m in problem of this type.

    Disabled fields and unselected checkboxes/ radio buttons/ list elements are not tranmitted when a form is submitted. So when you try to getParameter() you'll only get the selected fields or you'll get a null if the field was disabled/ not selected.
    When you use this for a set of checkboxes/ radio button, you'll only get the selected ones. If nothing was selected, you'll get null. Work on your logic with this in mind.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • Inserting values using merge

    Hi everyone,
    I need help with inserting values using merge.
    * I need to check all the units in a parent category. For example, NF_ARTICLECATEGORYID = 7462 is a parent category.
    * Im going to compare all the units in the parent category(7642) to the units in a subcategory (8053).
    * If the units in parent category(7642) is not present in the subcategory(8053) then the units will be inserted in the same table.
    table structure:
    Table name : ARTICLECATEGORYACCESS
    Fields: IP_ARTICLECATEGORYACCESSID
    NF_ARTICLECATEGORYID
    NF_UNITID
    NF_USERID
    N_VIEW
    N_EDIT
    Sample data:
    CREATE TABLE articlecategoryaccess (
    IP_ARTICLECATEGORYACCESSID NUMBER(5),
    NF_ARTICLECATEGORYID NUMBER (10),
    NF_UNITID NUMBER (10),
    NF_USERID NUMBER (10)
    N_VIEW INT,
    N_EDIT INT);
    INSERT INTO articlecategoryaccess VALUES (255583, 7642, 29727, NULL, 1 ,1);
    INSERT INTO articlecategoryaccess VALUES (243977,7642,29728, NULL, 1 ,1);
    INSERT INTO articlecategoryaccess VALUES (240770,7642,29843, NULL, 1 ,1);
    INSERT INTO articlecategoryaccess VALUES (243413,7642,29844, NULL, 1 ,1);
    INSERT INTO articlecategoryaccess VALUES (274828,7642,44849, NULL, 1 ,1);
    INSERT INTO articlecategoryaccess VALUES (274828,8053,44849, NULL, 1 ,1);
    Units ID 29727, 29728, 29843, 29844, 44849 has access to parent category 7642.
    The units id 29727, 29728, 29843, 29844 dont have access to subcategory 8053.
    29727, 29728, 29843, 29844 should be inserted in the same table and will have an access to 8053.
    After they are inserted, it should look like this
    IP_ARTICLECATEGORYACCESSID     NF_ARTICLECATEGORYID     NF_UNITID NF_USERID N_VIEW N_EDIT
    255583     7642     29727 null 1 1
    243977     7642     29728 null 1 1
    240770     7642     29843 null 1 1
    243413     7642     29844 null 1 1
    274828     7642     44849 null 1 1
    new value     8053     44849 null 1 1
    new value     8053     29843 null 1 1
    new value     8053     29844 null 1 1
    new value     8053     29728 null 1 1
    new value     8053     29727 null 1 1
    NOTE: IP_ARTICLECATEGORYACCESSID is a sequence and it should be unique
    DECLARE
    BEGIN
    MERGE INTO articlecategoryaccess b
    USING (SELECT *
    FROM articlecategoryaccess c
    WHERE nf_articlecategoryid = 7642
    MINUS
    SELECT *
    FROM articlecategoryaccess c
    WHERE nf_articlecategoryid = 8053) e
    ON (1 = 2)
    WHEN NOT MATCHED THEN
    INSERT (b.ip_articlecategoryaccessid, b.nf_articlecategoryid, b.nf_unitid, b.NF_USERID, b.N_VIEW, b.N_EDIT)
    VALUES (articlecategoryaccessid_seq.nextval, 8053, e.nf_unitid, null, 1, 1);
    END;
    i got an error after running the script:
    *Cause:    An UPDATE or INSERT statement attempted to insert a duplicate key.
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    *Action:   Either remove the unique restriction or do not insert the key.
    why would it be duplicated? its a sequence and its unique.. I dont know, maybe there is something wrong my script..
    Any help is appreciated..
    Ed

    Ed,
    1. What is the current value of the Sequence? Does the current value of sequence exist in the table? If yes, then increment the sequence to a value that is not present in the Table.
    2. Do you have any unique constraint on any of the columns that you are inserting?
    I have to ask you again, Why are you insisting on Merge statement when a simple Insert can do the job for you? Don't you feel that the below specified Merge statement is making things look more Complicated than they actually are, do you?
    Think on it and then proceed. I hope these pointers help you to resolve the issue.
    Regards,
    P.

  • How to receive parameters from a form and insert values in db using servlet

    Hi friends,
    My first question here.
    I'm trying to create a Servlet that takes input from a form and process it and insert it in database.tablename.
    My MAIN ISSUE IS WITH THE NUMBER OF COLUMNS THAT WOULD BE DYNAMIC AND THUS CANT RECEIVE THE PARAMETERS IN STATIC CODE.
    Here is the form code
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <form action="Test" method="post" />
    <table width="90%" border="1" cellspacing="1" cellpadding="1">
    <tr>
    <th scope="col">Student Name</th>
    <th scope="col">RollNo</th>
    <th scope="col">Java</th>
    <th scope="col">J2ee</th>
    </tr>
    <tr>
    <td><input type="text" name="studentname" /></td>
    <td><input type="text" name="rollno" /></td>
    <td><input type="text" name="java" /></td>
    <td><input type="text" name="j2ee" /></td>
    </tr>
    <tr>
    <td><input type="text" name="studentname" /></td>
    <td><input type="text" name="rollno" /></td>
    <td><input type="text" name="java" /></td>
    <td><input type="text" name="j2ee" /></td>
    </tr>
    <tr>
    <td><input type="text" name="studentname" /></td>
    <td><input type="text" name="rollno" /></td>
    <td><input type="text" name="java" /></td>
    <td><input type="text" name="j2ee" /></td>
    </tr>
    </table>
    <input type ="submit" value="insert values in the database now"/>
    </form>
    </html>
    And here is the Servlet
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    public class Test extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Module: Process Result Values from previous page";
    out.println("<html>\n" +
    "<head><title>" + title + "</title></head>\n" +
    "<body>");
              try
                   Class.forName("com.mysql.jdbc.Driver");
                   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/","root", "root");
                   Statement s = con.createStatement();
    ResultSet res = s.executeQuery("SELECT * FROM dbname.tablename");
    ResultSetMetaData rmeta=res.getMetaData();
    int noofcolumns=rmeta.getColumnCount();
                   if(!con.isClosed())
              catch(Exception e)
    System.out.println("Exception"+e);
    out.println(e);
    if(connectionFlag==1)
    out.println("</body></html>");
    doGet(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    This is the basic code structure and I'm trying to figure out this special case with handling the multiple parameters:
    1. I dont' want to use String []a=request.getParameterValues("studentname"); as hard code. The reason being the number of rows will be diyamic and I would like to get the column name and then then use an array of string to take values. But how can I connect these to form a query so that the rows goes on inserted one after other.
    Thanks,
    Mashall

    Thank you for your help.
    I'm something close to it but this segment of code throws a NullPointerException Error. I counted number of rows and columns using the methods getColumnCount() and getColumnName(i).
    ResultSetMetaData md = res.getMetaData(); //Get meta data for the resultset
    int noofcolumns=md.getColumnCount();
    out.println("<br />Number of columns in table (including name and roll number) :::: "+noofcolumns+"<br />");
    for(int i=1;i<=noofcolumns;i++) // access column 1....n
    String columnname = md.getColumnName(i); // get name of column 1....n
    out.println("<br />Current column name ::: "+columnname+"<br />"); //check if the name appear correct.
    String []columndata = request.getParameterValues(columnname); //Get raw value in array
    for(int j=1;j<=rows;j++) // here rows is number of rows in each column
    out.println("To be inserted: <b>"+columndata[j]+"</b> in Row ::: "+j+"<br />");
    //The line above thows null pointer exception.
    }

  • How can I insert values from table object into a regular table

    I have a table named "ITEM", an object "T_ITEM_OBJ", a table object "ITEM_TBL" and a stored procedure as below.
    CREATE TABLE ITEM
    ITEMID VARCHAR2(10) NOT NULL,
    PRODUCTID VARCHAR2(10) NOT NULL,
    LISTPRICE NUMBER(10,2),
    UNITCOST NUMBER(10,2),
    SUPPLIER INTEGER,
    STATUS VARCHAR2(2),
    ATTR1 VARCHAR2(80),
    ATTR2 VARCHAR2(80),
    ATTR3 VARCHAR2(80),
    ATTR4 VARCHAR2(80),
    ATTR5 VARCHAR2(80)
    TYPE T_ITEM_OBJ AS OBJECT
    ITEMID VARCHAR2(10),
    PRODUCTID VARCHAR2(10),
    LISTPRICE NUMBER(10,2),
    UNITCOST NUMBER(10,2),
    SUPPLIER INTEGER,
    STATUS VARCHAR2(2),
    ATTR1 VARCHAR2(80),
    ATTR2 VARCHAR2(80),
    ATTR3 VARCHAR2(80),
    ATTR4 VARCHAR2(80),
    ATTR5 VARCHAR2(80)
    TYPE ITEM_TBL AS TABLE OF T_ITEM_OBJ;
    PROCEDURE InsertItemByObj(p_item_tbl IN ITEM_TBL, p_Count OUT PLS_INTEGER);
    When I pass values from my java code through JDBC to this store procedure, how can I insert values from the "p_item_tbl" table object into ITEM table?
    In the stored procedure, I wrote the code as below but it doesn't work at all even I can see values if I use something like p_item_tbl(1).itemid. How can I fix the problem?
    INSERT INTO ITEM
    ITEMID,
    PRODUCTID,
    LISTPRICE,
    UNITCOST,
    STATUS,
    SUPPLIER,
    ATTR1
    ) SELECT ITEMID, PRODUCTID, LISTPRICE,
    UNITCOST, STATUS, SUPPLIER, ATTR1
    FROM TABLE( CAST(p_item_tbl AS ITEM_TBL) ) it
    WHERE it.ITEMID != NULL;
    COMMIT;
    Also, how can I count the number of objects in the table object p_item_tbl? and how can I use whole-loop or for-loop to retrieve values from the table object?
    Thanks.

    Sigh. I answered this in your other How can I convert table object into table record format?.
    Please do not open multiple threads. It just confuses people and makes the trreads hard to follow. Also, please remember we are not Oracle employees, we are all volunteers here. We answer questions if we can, when we can. There is no SLA so please be patient.
    Thank you for your future co-operation.
    Cheers, APC

  • 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

  • How to insert data from access to sql server ?

    How to insert data from access to sql server ?
    Please help me
    thanks

    phamtrungkien wrote:
    How to insert data from access to sql server by JAVA?The first four words of my last post:
    masijade wrote:
    JDBC with two connectionsGet a resultset from the jdbc-odbc bridge access connection, cycle through it and add batch insert commands to the jdbc connection to sql server. Give it a try and if the code has an error, then post your code ans ask a question.
    The real question, though, is why you think it absolutely necessary to use Java for this.

  • Getting error ORA-01401: inserted value too large for column

    Hello ,
    I have Configured the scenario IDOC to JDBC .In the SXMB_MONI am getting the succes message .But in the Adapter Monitor am getting the error message as
    ORA-01401: inserted value too large for column and the entries also not inserted in to the table.I hope this is because of the date format only.In Oracle table date field has defined in the format of '01-JAN-2005'.I am also passing the date field in the same format only for INVOICE_DATE and INVOICE_DUE_DATE.Please see the target structure .
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns:INVOICE_INFO_MT xmlns:ns="http://sap.com/xi/InvoiceIDoc_Test">
    - <Statement>
    - <INVOICE_INFO action="INSERT">
    - <access>
      <INVOICE_ID>0090000303</INVOICE_ID>
      <INVOICE_DATE>01-Dec-2005</INVOICE_DATE>
      <INVOICE_DUE_DATE>01-Jan-2005</INVOICE_DUE_DATE>
      <ORDER_ID>0000000000011852</ORDER_ID>
      <ORDER_LINE_NUM>000010</ORDER_LINE_NUM>
      <INVOICE_TYPE>LR</INVOICE_TYPE>
      <INVOICE_ORGINAL_AMT>10000</INVOICE_ORGINAL_AMT>
      <INVOICE_OUTSTANDING_AMT>1000</INVOICE_OUTSTANDING_AMT>
      <INTERNAL_USE_FLG>X</INTERNAL_USE_FLG>
      <BILLTO>0004000012</BILLTO>
      <SHIPTO>40000006</SHIPTO>
      <STATUS_ID>O</STATUS_ID>
      </access>
      </INVOICE_INFO>
      </Statement>
      </ns:INVOICE_INFO_MT>
    Please let me know what are all the possible solution to fix the error and to insert the entries in the table.
    Thanks in Advance!

    Hi muthu,
    // inserted value too large for column
    When your oracle insertion throws this error, it implies that some value that you are trying to insert into the table is larger than the allocated size.
    Just check the format of your table and the respective size of each field on your oracle cleint by using the command,
    DESCRIBE <tablename> .
    and then verify it with the input. I dont think the problem is with the DATE format because if it is not a valid date format, you would have got on error like
    String Literal does not match type
    Hope this helps,
    Regards,
    Bhavesh

  • Inserted value too large for column Error

    I have this table:
    CREATE TABLE SMt_Session
         SessionID int NOT NULL ,
         SessionUID char (36) NOT NULL ,
         UserID int NOT NULL ,
         IPAddress varchar2 (15) NOT NULL ,
         Created timestamp NOT NULL ,
         Accessed timestamp NOT NULL ,
         SessionInfo nclob NULL
    and this insert from a sp (sp name is SMsp_SessionCreate):
         Now := (SYSDATE);
         SessionUID := SYS_GUID();
         /*create the session in the session table*/
         INSERT INTO SMt_Session
                   ( SessionUID ,
                   UserID ,
                   IPAddress ,
                   Created ,
                   Accessed )
         VALUES           ( SMsp_SessionCreate.SessionUID ,
                   SMsp_SessionCreate.UserID ,
                   SMsp_SessionCreate.IPAddress ,
                   SMsp_SessionCreate.Now ,
                   SMsp_SessionCreate.Now );
    It looks like the param SessionUID is the one with trouble, but the length of sys_guid() is 32, and my column has 36.
    IPAddress is passed to the sp with value '192.168.11.11', so it should fit.
    UserID is 1.
    I am confused, what is the column with problem ?

    CREATE OR REPLACE PROCEDURE SMsp_SessionCreate
         PartitionID IN      INT ,
         UserID IN      INT ,
         IPAddress IN      VARCHAR2 ,
         SessionID IN OUT      INT,
         SessionUID IN OUT      CHAR,
         UserName IN OUT      VARCHAR2,
         UserFirst IN OUT      VARCHAR2,
         UserLast IN OUT      VARCHAR2,
         SupplierID IN OUT      INT,
         PartitionName IN OUT      VARCHAR2,
         Expiration IN      INT ,
         RCT1 OUT      GLOBALPKG.RCT1
    AS
         Now DATE;
         SCOPE_IDENTITY_VARIABLE INT;
    BEGIN      
         Now := SYSDATE;
         -- the new Session UID      
         SessionUID := SYS_GUID();
         /*Cleanup any old sessions for this user*/
         INSERT INTO SMt_Session_History
                   ( UserID ,
                   IPAddress ,
                   Created ,
                   LastAccessed ,
                   LoggedOut )
         SELECT
                   UserID,
                   IPAddress,
                   Created,
                   Accessed,
                   TO_DATE(Accessed + (1/24/60 * SMsp_SessionCreate.Expiration))
         FROM SMt_Session
         WHERE     UserID = SMsp_SessionCreate.UserID;
         --delete old     
         DELETE FROM SMt_Session
         WHERE UserID = SMsp_SessionCreate.UserID;
         /*create the session in the session table*/
         INSERT INTO SMt_Session
                   ( SessionUID ,
                   UserID ,
                   IPAddress ,
                   Created ,
                   Accessed )
         VALUES           ( SMsp_SessionCreate.SessionUID ,
                   SMsp_SessionCreate.UserID ,
                   SMsp_SessionCreate.IPAddress ,
                   SMsp_SessionCreate.Now ,
                   SMsp_SessionCreate.Now );
         SELECT SMt_Session_SessionID_SEQ.CURRVAL INTO SMsp_SessionCreate.SessionID FROM dual;
         --SELECT SMt_Session_SessionID_SEQ.CURRVAL INTO SCOPE_IDENTITY_VARIABLE FROM DUAL;
         --get VALUES to return
         SELECT u.AccountName INTO SMsp_SessionCreate.UserName FROM SMt_Users u WHERE u.UserID = SMsp_SessionCreate.UserID;
         SELECT u.SupplierID INTO SMsp_SessionCreate.SupplierID FROM SMt_Users u WHERE u.UserID = SMsp_SessionCreate.UserID;
         SELECT u.FirstName INTO SMsp_SessionCreate.UserFirst FROM SMt_Users u WHERE u.UserID = SMsp_SessionCreate.UserID;
         SELECT u.LastName INTO SMsp_SessionCreate.UserLast FROM SMt_Users u WHERE u.UserID = SMsp_SessionCreate.UserID;
         BEGIN
              FOR REC IN ( SELECT
                   u.AccountName,
                   u.SupplierID,
                   u.FirstName,
                   u.LastName FROM SMt_Users u
         WHERE     UserID = SMsp_SessionCreate.UserID
              LOOP
                   SMsp_SessionCreate.UserName := REC.AccountName;
                   SMsp_SessionCreate.SupplierID := REC.SupplierID;
                   SMsp_SessionCreate.UserFirst := REC.FirstName;
                   SMsp_SessionCreate.UserLast := REC.LastName;
              END LOOP;
         END;
         BEGIN
              FOR REC IN ( SELECT PartitionName FROM SMt_Partitions
         WHERE     PartitionID = SMsp_SessionCreate.PartitionID
              LOOP
                   SMsp_SessionCreate.PartitionName := REC.PartitionName;
              END LOOP;
         END;
         /*retrieve all user roles*/
         OPEN RCT1 FOR
         SELECT RoleID     FROM SMt_UserRoles
         WHERE     UserID = SMsp_SessionCreate.UserID;
    END;
    this is the exact code of the sp. The table definition is this:
    CREATE TABLE SMt_Session
    SessionID int NOT NULL ,
    SessionUID char (36) NOT NULL ,
    UserID int NOT NULL ,
    IPAddress varchar2 (15) NOT NULL ,
    Created timestamp NOT NULL ,
    Accessed timestamp NOT NULL ,
    SessionInfo nclob NULL
    The sp gets executed with this params:
    PARTITIONID := -2;
    USERID := 1;
    IPADDRESS := '192.168.11.11';
    SESSIONID := -1;
    SESSIONUID := NULL;
    USERNAME := '';
    USERFIRST := '';
    USERLAST := '';
    SUPPLIERID := -1;
    PARTITIONNAME := '';
    EXPIRATION := 300;
    if I ran the code inside the procedure in sql+ (not the procedure), it works. when i call the sp i get the error
    inserted value too large for column
    at line 48

  • JDBC Bulk Insert to MS Access

    I am trying to do bulk insert to MS Access database from text file. One of the solutions recommended by bbritta is as follows
    import java.sql.*;
    public class Test3 {
      public static void main(String[] arghs) {
        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          String filename = "C:/DB1.mdb";
          String database =
              "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/DB1.MDB";
          Connection con = DriverManager.getConnection(database, "", "");
          Statement statement = con.createStatement();
          statement.execute("INSERT INTO Table1 SELECT * FROM [Text;Database=C:\\;HDR=YES].[TextFile.txt]");
          statement.close();
          con.close();
        } catch (Exception e) { e.printStackTrace(); }
    }Whenever I try to use that approach, I get error message
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
    Fields in Access destination tables are exactly the same as in text field and I still get an error message. I could manually import to Access from same file without any problem.
    I was wondering if someone out there could suggest another approach.

    >
    1) Is there a type-4 JDBC connector available to
    connect directly to MS Access databases and if so
    would it be difficult to implement or migrate to?
    This is important because dbAnywhere does not appear
    to be supported on Windows 2000, which is the
    platform we are migrating to. We need to eliminate
    dbAnywhere if possible.
    By definition no such driver can exist. A type 4 driver is java only and connects directly to the database. Excluding file writes the only connection method is via sockets and there is nothing for a socket to connect to in a MS Access database - MS Access doesn't work that way.
    You can look into type 3 driver. I believe there are a number of them. They use an intermediate server. Search here http://industry.java.sun.com/products/jdbc/drivers
    You could implement your own using RmiJdbc at http://www.objectweb.org/. However I personally would think that that would require a serious long look at security issues before exposing a solution to the internet.

  • Problem Inserting Values in resultset

    Hi Friends,
    Any help regarding this would be welcomed.
    Please Help me.I am new to J2EE Programming.Our web project which we deploy on Tomcat 5.0.28 works perfectly fine when connected to Sybase ASA Database we have a new client requirement for which we have to connect it using Oracle 9i as the database.For doing the same i installed Oracle 9i(i have also tried with 8i)on my system copied the JDBC driver to the correct directory in Tomcat it got connected and is retriving data from the database perfectly.But when we try to insert a colum in the datbase using a result set it fails .The ResultSet rs is created properly(No Exception Thrown there) then the statement rs.moveToInsertRow(); also goes ahed without a problem but after taking the values when rs.insertRow(); is executed it throws an exception i.e. ORA-01732: data manipulation operation not legal on this view which I think is an exception from the oracle side whereas we are not manipulating any views we are inserting directly into the database tables. I would like to mention that to connect to oracle we are using the classes12.jar driver and the path for the same in the code is oracle.jdbc.driver.OracleDriver i have also tried it with the thin driver but same error reported.

    Yes, inserts into MS Access work.
    There doesn't appear to be anything wrong with your code.
    So something besides what you have posted is the problem:
    -autocommit
    -wrong database
    -ignoring errors
    -something else.

  • RFC to insert values to a table.

    Hello ABAP Experts-
    I am pretty new to ABAP devlopment. Recently, I got access where I can develop ABAP program.
    Can any one give me steps in writing a program to insert values to Ztable. I want to use this ABAP program in File to RFC scenarion in XI.
    I really appreciate your help.
    Thanks,
    Raj.

    Hi...
    check this code.
    DATA : wa1 type Ztable.
    Here it_tab and wa_tab are your internal table and work area.
    loop at it_tab into wa_tab.
    move wa_tab-vbeln to wa1-vbeln.
    insert Ztable from wa1.
    Please get back to me if you have any concerns.
    Thank you.
    Regards,
    Lokeswari.

  • Accessing HTMLB checkbox in javascript

    Hi,
    I have the following scenario:
    1) jsp "main.jsp" has a checkbox with id="chkBoxId"
    2) In this "main.jsp" at the end, there is a jsp include
       including another jsp "buttons.jsp" - which contains a
       SUBMIT button.
    3) On this SUBMIT button, I am calling a javascript
       function "check()" in the "onClientClick" attribute.
    4) In this "check()" function I want to access the
       checkBox (present in "main.jsp")
    Now when I try doing this using the following code in the check() function, it gives me a "Undefined is null or not an object".
    function check(chkBoxId) {
    var funcName = htmlb_formid+"_getHtmlbElementId";
    func = window[funcName];
    var chkBox1 = eval(func(chkBoxId));
    // The checkbox is obtained
    if (chkBox1)
      alert("Not Checked");
    Plzz help me !!!
    regards,
    Jitendra

    HI,
    U can write the javascript function in the header tag or create a .js file in which u write the javascript code.
    the javascript code can be like
    function ValidateForm()
    if(document.form1.s_material.value=="")
    alert("enter material");
    return false;
    return true;
    where form1 is id of form and s_material is iD of input field.
    In your coding for button onClientClick like :
    <htmlb:button  id="s_but_submit"
                                       width="20"
                                       onClick="submit"
                                       onClientClick="if(!ValidateForm(this))htmlbevent.cancelSubmit=true;"
    Regards,
    Siddhartha

Maybe you are looking for

  • Apple TV started having streaming issues with Netflix

    Several days ago my Apple TV is no longer providing consistent streaming throught Netflix. Before that, I had great streaming through all content for many months. Issues, configuration and some actions already taken: Video quality starts suffering, t

  • TWO clips snap together after deleting the one between them without command

    Hi, Someone at an Apple store workshop asked today about a gap in a timeline which one usually closes by clicking "close gap", but in this case, the gap is closing immediately after the deletion without a command being entered. Does anyone know if th

  • Problems with builded app and shared variables

    I got connection error message (Invalid server: cannot connect to server) when selecting a shared variable using dashboard. The app is running on a Win7 PC. I have no problem connecting the PC's IP at my dashboard indicator, even, I can select the sh

  • Upload a pdf form

    I'd like to upload form saved as a pdf file into adobe forms but it says I need to make changes to the format?

  • HT5022 what about mountain lion?

    exact same problem only cannot install the utility on mountain lion, can anyone help?