How to Insert Hastables Into Database Through JDBC

hi all,
I have place the Data from the Hashtables Into the Database.I can place it by Iterating through the Hastables.I would Like to Place the Entire Hashtable Itself Into the Database.
Can Any one tell me how?
bye.

Hi,
Can anyone help me out how to insert image into
database using struts...with dao n dto classes?If it matters whether or not you are using struts then you might have something wrong.
Make sure you separate the database logic out.
I know these types of questions are asked frequently, you might want to search the forum for additional examples.
Here is a good one:
http://forum.java.sun.com/thread.jspa?threadID=620455&messageID=3495899

Similar Messages

  • Its very urgent:how to insert data into database tables

    Hi All,
    I am very new to oaf.
    I have one requirement data insert into database tables.
    here createPG having data that data insert into one custom table.
    but i dont know how to insert data into database tables.
    i wrote the code in am,co as follows.
    in am i wrote the code:
    public void NewoperationManagerLogic()
    ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
    OADBTransaction oadbt=getOADBTransaction();
    if(!vo1.isPreparedForExecution())
    vo1.executeQuery();
    Row row=vo1.createRow();
    vo1.insertRow(row);
    in createPG processrequest co:
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.NewoperationManagerLogic();
    process form request:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    if(pageContext.getParameter("Submit")!=null)
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.getOADBTransaction().commit();
    please help with an example(sample code).
    its very urgent.
    thanks in advance
    Seshu
    Edited by: its urgent on Dec 25, 2011 9:31 PM

    Hi ,
    1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
    2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
    3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
    You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
    Thanks
    Pratap

  • Inserting ordimage in database through jdbc

    I want to insert an image of type ordimage to database through jdbc but not finding to which jdbc type i should map this when setting parameter in callableStatement. Kindly help me.

    Hi,
    There is a [url http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10779/toc.htm]specific Java API for the multimedia types (of which ORDIMAGE is one).
    John

  • How to insert Date into Database from workbench.

    Hi
    I have requirement where  I need to  insert the currentDate and Time to the database.   Here I am using  as
    At SQL Statement Info Editor ,have like these :
    Type     value
    Date     parse-dateTime(current-dateTime())
    At DB I have Datatype  as DateTime( Using MySQL). Here i am getting error like :
    Caused by: com.adobe.idp.dsc.jdbc.exception.JDBCIllegalParameterException: Type mismatch is found when preparing SQL statement. Expecting type 'date', but got type 'String'.
    Could  any one tell me where I can find  detailed log say hibernate type... where exatly we are  getting error.(Expect jboss's server log).
    Please tell how to  insert the date into the DB ASAP.
    Thanks
    Praveen

    Thanks for   all replies.
    Eventually I  got  the solution  the post
    From the Form (Using DatePicker) , we will get the DateTime  datatype to the Workbench. All  we need to  do is assign the  same to DateTime variable in the workbench and inserting the data to the DB.
    It works.
    Thanks
    Praveen.

  • How to insert date into database table

    Hi,
    i used date navigator in htmlb. i want toupdate date into the database table ystudetn_inf. and also please tell me how to insert that date into table.give me small example in stepby step.

    Hi,
      I am sure you have used htmlb:dateNavigator as follows
    <htmlb:dateNavigator id             = "myDateNavigator"
                               monthsPerRow    = "1"
                               onNavigate      = "myOnNavigate"
                               onDayClick      = "myOnDayClick"
                               onWeekClick     = "myOnWeekClick"
                               onMonthClick    = "myOnMonthClick">
          </htmlb:dateNavigator>
    Trap the onDayClick event in oninputprocessing
    date_event ?= cl_htmlb_manager=>get_data(
                                        request = runtime->server->request
                                             name     = 'inputField'
                                             id       = 'mydate'  ).
    date = datenavigator_event->day.
    and use date value to update your table.
    If found helpfull rewards points.
    Regards,
    Albert

  • How to insert data into database table from a servlet? Help please.

    From a servlet I want to insert a message with some servlet parameters into an oracle database table by writing 'insert into tablename'. How shall I write the sql statement?

    simple suppose u wanned to insert user name and password into table user_info then this is a simple example .....
    Best Regds
    bondzoro
    [email protected]
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class tester extends HttpServlet {
    Connection con = null;
    public void init(ServletConfig sc){
    super.int(sc);
    Class.forName("oracle.jdbc.driver.OracleDriver");
    public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOE
    try {
    con=DriverManager.getConnection("jdbc:oracle:thin:@database_URL:1521:ORA8","username","pa
    String user = req.getParameter("username");
    String pass = req.getParameter("pass");
    PreparedStatement pst = con.prepareStatement("insert into user_info values(?,?)");
    pst.setString(1,user);
    pst.setString(2,pass);
    pst.executeQuery();
    pst.close();
    con.close();
    }catch(Exception _e){
    _e.printStackTrace(System.err);
    ~

  • How to insert data into database. Please help me(Struggling Very much)

    Hi i am having a jsp page which contains some textfields and one button. I have a database table and i have added to my page. The first column of Database table is ID which is of NUMERIC type and it has been set into primary key. And rest of fields are CHAR type. I am using SQL Server 2000. I have to enter the data into text fields and when i submit the add button it must add to the database table. But i am getting error like
    Exception Details: java.lang.IllegalArgumentException SRNI.TABLE1.NAME
    Please i am trying this one from two months. but it is not getting. I have tried alot by studying all tutorials in Java Studio Creator. I have posted many times but i have followed everyones suggestion. Please give me some instances of writing code to the corresponding requirements i have mentioned above.Please explain step by step including simple one also.
    Thanking You in Advance.

    Hi Srinivasan,
    Please check out the Database projects available at:
    http://blogs.sun.com/sakthi/entry/flavors_of_crud_tutorial_projects
    These have been exercised using this tutorial against different databases:
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    HTH,
    Sakthi

  • How to insert field to database through module pool.

    Hi All,
    I am working on module pool,i have taken the itab with header line and structures also.
    inorder to update  fields to different tbales what is the logic i need to right.
    i have taken move command i have written move scree-fields to structure
    then  have modify dbtable from structure.but no result only current record is updating
    please help me.

    Hi Saroja,
    INSERT INTO scarr values scarr_wa
    If you use above statement, it updates only one record.
    INSERT INTO scarr FROM TABLE itab.
    If you use above statement, it updates all records available in itab.
    Choose which one u want to use and update the table.
    Thanks
    Venkat.O

  • Error inserting data into database

    Hello I am having error inserting data into database through a servlet.Please I am very new to Java Technology and need your immediate help. beloww is the codea nd the error
    Apache Tomcat/4.0.3
    ERROR: Problems with adding new entry
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2525)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
         at Register.insertIntoDB(Register.java:71)
         at Register.doPost(Register.java:53)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
         at java.lang.Thread.run(Thread.java:536)
    COde:
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class Register extends HttpServlet
         public static Statement statement;
         private Connection DBConn;
         public void init(ServletConfig config) throws ServletException
              super.init(config);
              try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   DBConn=DriverManager.getConnection("jdbc:odbc:Challenge");
              catch(Exception e) {
                   e.printStackTrace();
                   DBConn=null;
         public void doPost(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException
                   String user_id,FirstName,LastName, Email, Login, Password;
              FirstName = req.getParameter("FirstName");
              LastName = req.getParameter("LastName");
              Email = req.getParameter("Email");
              Login = req.getParameter("Login");
              Password = req.getParameter("Password");
              PrintWriter output = res.getWriter();
              res.setContentType("text/html");
              if (user_id.equals("")||
              FirstName.equals("") ||
                   LastName.equals("") ||
                   Email.equals("") ||
                   Login.equals("") ||
                   Password.equals(""))
                        output.println("<H3>Please click back " + "button and fill in all " + "fileds.</H3>");
                        output.close();
                        return;
                   boolean success = insertIntoDB("'" + FirstName + "','" + LastName + "','" + Email + "','" + Login + "','" + Password + "'");
                   if (success)
                        output.print("<H2>Thank You " + FirstName + " for registering.</H2>");
                        res.sendRedirect("file:///Register.html");
                   else
                        output.print("<H2>An error occured. " + "Please try again later.</H2>");
                        output.close();
              private boolean insertIntoDB(String stringtoinsert)
                   try
                        statement = DBConn.createStatement();
                        statement.execute("INSERT INTO Users(user_id,FirstName,LastName,Email,Login,Password) values (" + stringtoinsert + ");");
                        statement.close();
                   catch (Exception e)
                        System.err.println("ERROR: Problems with adding new entry");
                        e.printStackTrace();
                        return false;
                   return true;
              public void destroy()
                   try
                        DBConn.close();
                   catch(Exception e)
                        System.err.println("Problem closing the database");
    Your Help will be very much appreciate.I am using SQL Server database

    The error concerns these two lines:
    boolean success = insertIntoDB("'" + FirstName + "','" + LastName + "','" + Email + "','" + Login + "','" + Password + "'");
    statement.execute("INSERT INTO Users(user_id,FirstName,LastName,Email,Login,Password) values (" + stringtoinsert + ");");
    In the first line above, you have a string which represents the VALUES which you are inserting. There are 5 values. However in the second line above this is your actual SQL execution you are specifying 6 columns of data. If the column "user_id" is an identity or auto-incrementing field in the database, just remove it from this line. If not then you need to supply the "UserID" into the VALUES.
    This should fix the problem.

  • How to insert data in database table

    Hi experts,
                   How to insert data into database table using internal table from function module.

    Hi,
    As per my understanding are you looking for the complete API feature of data insertion into the database using the Locking Mechanism? If yes, then you need to create a Lock Object using the Primary keys of the Primary Table and Secondary Tables. You need to call the lock object first and then you need to make the entry into the table. This principle is based on  'All or None Concept'.
    For the insert Statement Key word you can have a look at the following link:
    http://help.sap.com/abapdocu/en/ABAPINSERT_SOURCE.htm
    Hope this helps.
    Thanks,
    Samantak.

  • How to eliminate inserting  Duplicate rows into database using JDBC Adapter

    File->Xi->JDBC
    In above Scenario if the file has two rows their values are identical, then how can we eliminated inserting  Duplicate rows into database using JDBC Adapter

    Database is a consumer of a SERVICE (SOA!!!!!!).
    Database plays a business system role here!!!!
    Mapping is part of an ESB service
    Adaptor is a technology adapted to ESB framework to support specific protocol.
    ESB accomplish ESB duties such as transformation, translation, routing. Routing use a protocol accepted by the consumer. In a JDBC consumer it is JDBC protocol and hence it a JDBC adaptor.
    There is clear separation on responsibilities among business system and ESB. ESB do not participate in business decision or try to get into business system data layer.
    So who ever are asking people to check duplicate check as part of mapping (an ESB service) may not understand integration practice.
    Please use an adaptor module which will execute the duplicate check with business system in a plug and play approach and separate that from ESB service so that people can build integration using AGILE approach.
    Thanks

  • Inserting files in to Oracle 8i database through JDBC - Only 4k data file

    Hi,
    I need to insert a files(images or excel files, doc files etc..) in to oracle 8i database through JDBC program. But i am not able to store more than 4k data files in to files. can any body give me solutions regarding this.
    My code is like this...
    String fileName ="Sample.jpg";
                                  String dataSource = "jdbc/oracle";
                   File file=null;
                   FileInputStream fis = null;
                   Context initCtx=null;
                   DataSource ds = null;
                   Connection con = null;
                   try
                        initCtx = new InitialContext();
                        ds = (DataSource)initCtx.lookup(dataSource);
                        con = ds.getConnection();
                      try
                         file = new File(fileName);
                         fis = new FileInputStream(file);
                        catch(FileNotFoundException fe)
                             out.println("File Not Found");
                                            PreparedStatement pstmt = con.prepareStatement("insert into bfiles values(?,?)");
                        pstmt.setString(1, fileName);
                        pstmt.setBinaryStream(2, fis, (int)file.length());
                        pstmt.executeUpdate();
                        out.println("Inserted");
                        fis.close();
                        pstmt.close();
                        con.close();
                        out.println("closed");
                   catch(Exception e)
                        out.println(e);
               }     in Oracle bi i have created a table like this :
    CREATE TABLE BFILES
      FILENAME     VARCHAR2(100)                    DEFAULT NULL,
      FILECONTENT  BLOB                             DEFAULT EMPTY_BLOB()
    )Please help me ourt to solve this problem.
    i got struck in this problem.
    its urgent
    thanks in advance
    djshivu

    Hi Shanu.
    Thanks for your help...
    By Using THIN driver also we can insert any files more than 4k and and retrive same. Fallowing codes worked fine for me using thin Driver .
    Following are the 2 programs to write and read.
    we can insert and retrieve any format of files ( jpg, gif, doc, xsl, exe, etc...)
    =======================================================
    // Program to insert files in to table
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    import java.sql.*;
    import java.io.*;
    import java.awt.image.*;
    import java.awt.*;
    * @author  Shivakumar D.J
    * @version
    public class WriteBlob{
    public static void main(String[] args){
    String filename = "018-Annexure-A.xls";
    Connection conn = null;
    try{
        Class.forName("oracle.jdbc.driver.OracleDriver");
        conn=DriverManager.getConnection("jdbc:oracle:thin:@test:1521:orcl","modelytics","modelytics");
        conn.setAutoCommit(false);
        Statement st = conn.createStatement();
        int b= st.executeUpdate("insert into bfiles values('"+filename+"', empty_blob())");
        ResultSet rs= st.executeQuery("select * from bfiles for update");
        rs.next();
        BLOB blob=((oracle.jdbc.driver.OracleResultSet)rs).getBLOB(2);
        FileInputStream instream = new FileInputStream(filename);
        OutputStream outstream = blob.getBinaryOutputStream();
        int chunk = blob.getChunkSize();
        byte[] buff = new byte[chunk];
        int le;
        while( (le=instream.read(buff)) !=-1)
            outstream.write(buff,0,le);
        instream.close();
        outstream.close();
        conn.commit();
        conn.close();
        conn = null;
        System.out.println("Inserted.....");
       catch(Exception e){
            System.out.println("exception"+e.getMessage());
            e.printStackTrace();
       }//catch
    }=======================
    // Program to retrieve files from database
    [import java.sql.*;
    import java.io.*;
    import java.awt.*;
    public class ReadImage
    public static void main(String a[])
        String fileName ="018-Annexure-A.xls";
        try
              Driver driver = new oracle.jdbc.driver.OracleDriver();
              DriverManager.registerDriver(driver);
              Connection con = DriverManager.getConnection("jdbc:oracle:thin:@test:1521:orcl", "modelytics", "modelytics");
            File file = new File("C:/Documents and Settings/USERID/Desktop/dump.xls");
              FileOutputStream targetFile=  new FileOutputStream(file); // define the output stream
              PreparedStatement pstmt = con.prepareStatement("select filecontent from bfiles where filename= ?");
              pstmt.setString(1, fileName);
               ResultSet rs = pstmt.executeQuery();
               rs.next();
               InputStream is = rs.getBinaryStream(1);
              byte[] buff = new byte[1024];
               int i = 0;
               while ((i = is.read(buff)) != -1) {
                    targetFile.write(buff, 0, i);
                   System.out.println("Completed...");
            is.close();
            targetFile.close();
            pstmt.close();
           con.close();
        catch(Exception e)
              System.out.println(e);
    }====================
    Table Structure is like this
    CREATE TABLE BFILES
      FILENAME     VARCHAR2(100)                    DEFAULT NULL,
      FILECONTENT  BLOB                             DEFAULT EMPTY_BLOB()
    )========================================================
    i hope above codes will helpful for our future programmers
    thanks shanu...
    regards
    djshivu...(javashivu)

  • Insert multiple records into database through internal table

    Hi
      please help me how to insert multiple records into database through internal table

    Hi,
    Welcome to SCN.
    Press F1 on INSERT statement and you will teh syntax as well the docu for the same.

  • How  to  insert data into custom database table from an hcsf

    i want to insert data into database table that i have created from an hcsf.
    example :
    say i have created a table in oracle database and i hav created a hcsf file.now i want that when somebody fills in that hcsf and click submit ,i want that entries should be updated in my database table.
    plzzz reply ASAP(it's urgent)

    you'll need a bit of Java code... extract the data during a check-in filter, and insert it into the database.
    check out the "DataAccess" component in the HowToComponents for query-running examples, and the "DynamicPrefix" component for a check-in filter example.
    I have older copies here:
    http://bezzotech.com/library

  • How to insert data into the mysql table by giving as a text file

    Hi,
    Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
    Thanks:)

    At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).

Maybe you are looking for

  • Converting a paper document to ADOBE Page

    hi guys,         I have a task like this To convert a paper document to ADOBE page and i should edit that page also. I have converted a doc to ADOBE page and when i open that doc in ADOBE Life cycle designer, it opens as an image (so we cant edit tha

  • IPD files and backing up??

    Tried backing up my BB, it successfully saved the back-up file however it's in IPD format. I read online that it's not possible to open IPD files on a PC? So does this mean that it's backed-up already on my PC? then if ever I just accidentally lose m

  • Unable to install 64-bit virtual machine on 870A Fuzion w/AMD Phenom X6 proc

    Unable to get resolution from support after numerous attempts. I've enabled SVM feature from bios and also updated to latest version with no luck. Installed Win 7 and running VMworkstation 7 - whenever installing 64bit VMs (eg. W2k8 R2) keep getting

  • Portfolio gallery from Bridge

    Hey Adobe-er's, I need some help. I've created a photo gallery in Adobe Bridge and I want to include that as an individual page on my Flash site.  How do I embed my Bridge portfolio gallery into Flash!? I really appreciate any insight on this. Thanks

  • Nested table type in object view on 8.1.7

    Object views seem to be the ideal way to deliver XML datagrams from database queries with nested data. I need to create a datagram that contains nested data within another nested set of data eg. a family has many people, each person may have many hob