Insert data into DB in my jsp page.

Hello !
some information about my system: OS: Debian; Tomcat 5.5.0; JAVA 5
and the problem:
In my JSP i want to connect me to the database and insert data :
<%
  // on r�cup�re les donn�es
     String nomCentre=(String)request.getAttribute("nomCentre");
     String idCentre= (String)request.getAttribute("idCentre");                    
     String nomPreleveur = (String)request.getAttribute("nomPreleveur");
     String datePrelev=(String)request.getAttribute("datePrelev");        
        String numFinFiche=(String)request.getAttribute("numFinFiche");
     if(nomCentre==null) nomCentre="nomCentre";
        if(idCentre==null) idCentre="idCentre";
     if(nomPreleveur==null) nomPreleveur="nomPreleveur";
     if(datePrelev==null) datePrelev="datePrelev";
     if(numFinFiche==null) datePrelev="numFinFiche";
%>
<%@ page language="java" import="java.sql.*,germande.Connexion" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<html>
  <head>
     <title>Fiche r&eacute;pitulative - formulaire</title>
   </head>
   <body>
     <table col="2" row="3" ALIGN="CENTER" width="50%">
          <tr>
          <TD rowspan="2"><img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande"></img></TD>
               <TD width="80%" bgcolor="#DDDDDD">
                    <b>Fiche R&eacute;capitulative des pr&eacute;l&egrave;vements </b>
                    (au moins une fiche par &eacute;tablissement contr&ocirc;l&eacute;)
               </TD>
          </tr>
     </table>
       <hr>
         <table   width="60%">
           <tr>
              <td>Centre hospitalier/Clinique: </td>
               <td ><%= nomCentre%></td>
          <td>Pr&eacute;leveur </td>
               <td><%= nomPreleveur%></td>
             </tr>       
          <tr>
              <td>Date de pr&eacute;l&egrave;vement: </td>
               <td><%= datePrelev%></td>
             </tr>
          <tr>
              <td>Heure d&acute;arriv&eacute;e: </td>
               <td><input name="heureArrivee" type="text" size="8"></td>
              <td>Heure de d&eacute;part: </td>
               <td><input name="heureDepart" type="text" size="8"></td>
             </tr>
           <tr>
          </table>
     <br><br>
     <b>Codification des &eacute;chantillons pr&eacute;lev&eacute;s<b>
     <TABLE cols="3" colspan="3" width="55%">
     <%
          String un="<TR><TD width=\"40%\"align=\"left\">";
          String trois="</TD><TD width=\"10%\" align=\"center\"> &agrave;</TD><TD width=\"40%\" align=\"right\">";               
          String cinq="</TD></TR>";
          String variable="<SELECT name=\"nomPreleveur\"><OPTION value=\"vide\" selected></OPTION><OPTION value=\"EBM\">EBM</OPTION><OPTION value=\"Nicolas\">Nicolas</OPTION><OPTION value=\"Pierre-Alain\">Pierre-Alain</OPTION></SELECT>";
          String borneDEBUT="1."+variable+datePrelev+"."+idCentre+"."+numFinFiche;
          String borneFIN=variable+datePrelev+"."+idCentre+"."+numFinFiche;
     for(int repetition=0; repetition<=9;repetition++){
          String reslt=un+borneDEBUT+trois+borneFIN+cinq;
          out.println(reslt);
     %>
       <br><br>
     <TABLE cols="1" colspan="3">
               <TR>
               <b>Flacon de PV</b>
               </TR>
               <TR>
               <TD>Nlot</TD>
               <TD><INPUT type="text" name="Nlot"></TD>
               </TR>
               <TR>
               <TD>Fournisseur</TD>
               <TD><INPUT type="text" name="Fournisseur"></TD>
               </TR>
               <TR>
               <TD>Date expiration</TD>
               <TD><INPUT type="text" name="DateExpiration"></TD>
               </TR>
          </TABLE>
          <TABLE cols="2" CELLPADDING="10">
               <TR>
               <TH ALIGN="CENTER"><b>Signature Technicien Pr&eacute;leveur</b></TH>
               <TH ALIGN="CENTER"><b>Etablissement control&eacute;</b></TH>
               </TR>
               <TR>
               <TD> </TD>
               <TD><b>Nom:</b></TD>
               <TD><INPUT type="text" name=nomEtablissement"></TD>
               </TR>
               <TR>
               <TD> </TD>
               <TD><b>Fonction:</b></TD>
               <TD><INPUT type="text" name=fonctionEtablissement"></TD>
               </TR>
               <TR>
               <TD> </TD>
               <TD><b>Signature:</b></TD>
               <TD> </TD>
               </TR>
               <TR>
               <TD> </TD>
               <TD><b>Tampon:</b></TD>
               <TD> </TD>
               </TR>
          </TABLE>
          <p>
          D&eacute;lai d&acute;acheminement > &agrave; 8 heures
          Oui : <INPUT type="checkbox" name="reponse" value="O">
          Non : <INPUT type=checkbox name="reponse" value="N">
          </p>
          <p>
          *La temp&eacute;rature doit &ecirc;tre suivie:
          <TABLE cols="2" colspan="3" CELLPADDING="5">
               <TR>
               <TD>T&deg; avant ouverture</TD>
               <TD><INPUT type="text" name="TempsOuverture"></TD>
               <TD>Date arriv&eacute;e au laboratoire</TD>
               <TD><INPUT type="text" name="Datearrivee"></TD>
               </TR>
               <TR>
               <TD>T&deg; arriv&eacute;e avant d&eacute;chargement</TD>
               <TD><INPUT type="text" name="TempsArrivee"></TD>
               <TD>Heure d&acute;arriv&eacute;e au laboratoire</TD>
               <TD><INPUT type="text" name="HeureArrivee"></TD>
               </TR>
               <%!
               Connexion com = new Connexion();
               try{
               String nEtude=datePrelev+"."+idCentre+"."+numFinFiche;
               //serveur,login,pwd,database
               com.loadDriverAndConnect("127.0.0.1","3306","root","root","");
               com.executeQuery("INSERT INTO 'BIOTECH'.'RECAP' (NEtude ,NomCentre ,idCentre,nomPreleveur,datePrelev) " +
                         "values ('"+nEtude+"','"+nomCentre+"','"+idCentre+"','"+nomPreleveur+"','"+ datePrelev + "');") ;
               com.affiche();
               com.close();
               catch(Exception ex) {
               System.err.println("\n*** SQLException caught in main()");               
               %>
          </TABLE>
          </p>
   </body>
</html>and the message error:
org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP:
JSP FileName:/reponseRecap.biotech.jsp
Java FileName:/var/lib/tomcat5.5/work/Catalina/localhost/germande//org/apache/jsp/reponseRecap_biotech_jsp.java
Une erreur s'est produite � la ligne: 152 dans le fichier jsp: /reponseRecap.biotech.jsp
The constructor Connexion() is not visibleSo i don't know how to call my class connexion (which serve me to connect to the DB) in my jsp
Any ideas please ?
The class connexion is in the package germande. I try to insert data in ther servlet code but nothing was added in my DB ...
Thanks U !!

First, you should move all of your java code out of the .jsp, and into a servlet. With that said, the error message is telling you that the compiler cannot find the constructor "Connexion()".
The constructor Connexion() is not visibleDid you write a no parameters constructor in the class? If so, what is the visibility of the constructor? If not, did you create a constructor that takes parameters?
You need to post the code for the Connexion class.

Similar Messages

  • Problem with inserting data into mySQL database with jsp

    I have a jsp page that collects infromation about a users vehicle and puts the data into a mySQL database. Iv'e been messing around with it for ages & i can't seem to get it to work even though i cannot see anything wrong with the code, which can be seen below.
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="Connections/connection.jsp" %>
    <%
    // *** Restrict Access To Page: Grant or deny access to this page
    String MM_authorizedUsers="";
    String MM_authFailedURL="login_form.jsp";
    boolean MM_grantAccess=false;
    if (session.getValue("MM_Username") != null && !session.getValue("MM_Username").equals("")) {
      if (true || (session.getValue("MM_UserAuthorization")=="") ||
              (MM_authorizedUsers.indexOf((String)session.getValue("MM_UserAuthorization")) >=0)) {
        MM_grantAccess = true;
    if (!MM_grantAccess) {
      String MM_qsChar = "?";
      if (MM_authFailedURL.indexOf("?") >= 0) MM_qsChar = "&";
      String MM_referrer = request.getRequestURI();
      if (request.getQueryString() != null) MM_referrer = MM_referrer + "?" + request.getQueryString();
      MM_authFailedURL = MM_authFailedURL + MM_qsChar + "accessdenied=" + java.net.URLEncoder.encode(MM_referrer);
      response.sendRedirect(response.encodeRedirectURL(MM_authFailedURL));
      return;
    String vehicle_details__registration = null;
    if(request.getParameter("txt_registration") != null){ vehicle_details__registration = (String)request.getParameter("txt_registration");}
    String vehicle_details__make = null;
    if(request.getParameter("txt_make") != null){ vehicle_details__make = (String)request.getParameter("txt_make");}
    String vehicle_details__model = null;
    if(request.getParameter("txt_model") != null){ vehicle_details__model = (String)request.getParameter("txt_model");}
    String vehicle_details__colour = null;
    if(request.getParameter("txt_colour") != null){ vehicle_details__colour = (String)request.getParameter("txt_colour");}
    String vehicle_details__tax_class = null;
    if(request.getParameter("select_tax_class") != null){ vehicle_details__tax_class = (String)request.getParameter("select_tax_class");}
    String vehicle_details__chasis_num = null;
    if(request.getParameter("chasis_num") != null){ vehicle_details__chasis_num = (String)request.getParameter("chasis_num");}
    String vehicle_details__status = null;
    if(request.getParameter("radio_status") != null){ vehicle_details__status = (String)request.getParameter("radio_status");}
    String owner_details__MMColParam = "1";
    if (session.getValue("MM_Username") !=null) {owner_details__MMColParam = (String)session.getValue("MM_Username");}
    Driver Drivervehicle_details = (Driver)Class.forName(MM_connection_DRIVER).newInstance();
    Connection Connvehicle_details = DriverManager.getConnection(MM_connection_STRING,MM_connection_USERNAME,MM_connection_PASSWORD);
    PreparedStatement vehicle_details = Connvehicle_details.prepareStatement("INSERT INTO vehicle_man_db.vehicle_details (registartion, make, model, colour, tax_class, chasis_num) VALUES ('"+ String vehicle_details__registration + "', '"+ String vehicle_details__make + "', '"+ String vehicle_details__model + "', '"+ String vehicle_details__colour + "', '"+ String vehicle_details__tax_class + "', '"+ String vehicle_details__chasis_num + "', '"+ String vehicle_details__status + "')");
    vehicle_details.executeUpdate();
    %>
    <form name="add_vehicle_form" id="add_vehicle_form">
      <p>Registration mark:
        <input name="txt_registration" type="text" id="txt_registration">
    </p>
      <p>Make:
        <input name="txt_make" type="text" id="txt_make">
    </p>
      <p>Model:
        <input name="txt_model" type="text" id="txt_model">
    </p>
      <p>Colour:
        <input name="txt_colour" type="text" id="txt_colour">
      </p>
      <p>Tax Class:
        <select name="select_tax_class" id="select_tax_class">
          <option value="AAA">Band AAA (up to 100g/km)</option>
          <option value="AA">Band AA (101 - 120g/km)</option>
          <option value="A">Band A (121 - 150g/km)</option>
          <option value="B">Band B (151 - 165g/km)</option>
          <option value="C">Band C (166 - 185g/km)</option>
          <option value="D">Band D (Over 185g/km)</option>
        </select>
      </p>
      <p>Chasis Number:
        <input name="txt_chassis_num" type="text" id="txt_chassis_num">
    </p>
      <p>Status: active:
        <input name="radio_status" type="radio" value="1" checked>
        off-road
        <input name="radio_status" type="radio" value="0">
      </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    <%
    Connvehicle_details.close();
    %>This is the error I am getting from the server
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 3 in the jsp file: /add_vehicle_form.jsp
    Generated servlet error:
    C:\Servers\Tomcat 5.0\work\Catalina\localhost\Assignment\org\apache\jsp\add_005fvehicle_005fform_jsp.java:113: ')' expected
    PreparedStatement vehicle_details = Connvehicle_details.prepareStatement("INSERT INTO vehicle_man_db.vehicle_details (registartion, make, model, colour, tax_class, chasis_num) VALUES ('"+ String vehicle_details__registration + "', '"+ String vehicle_details__make + "', '"+ String vehicle_details__model + "', '"+ String vehicle_details__colour + "', '"+ String vehicle_details__tax_class + "', '"+ String vehicle_details__chasis_num + "', '"+ String vehicle_details__status + "')");
    ^
    1 error
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Any help would be much appreciated.
    Thanks

    use this ...
    PreparedStatement vehicle_details =
    Connvehicle_details.prepareStatement("INSERT INTO
    vehicle_man_db.vehicle_details (registartion, make,
    model, colour, tax_class, chasis_num) VALUES
    vehicle_details .setString(1,String
    vehicle_details__registration );
    vehicle_details setString(2,String
    vehicle_details__make );
    vehicle_details .setString(3,String
    vehicle_details__model );
    vehicle_details .setString(4,vehicle_details__colour
    vehicle_details .setString(5,String
    vehicle_details__tax_class);
    vehicle_details .setString(6,String
    vehicle_details__chasis_num );
    vehicle_details .executeQuery();Even you need a screwing up... what's the point putting that String inside. That's the bloody error.

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • How can i insert data into DB from my page programatically in Oracle ADF..?

    Hai, this is praveen.
    I have created  an EO and VO, when i have inserted data by dragging and dropping from DataControl -->Operations-->Create. I have successfully inserting data. But how can i do it programatically. What are the pre-defined steps that i can use over there to insert data into table programatically. Could u plz help me?

    Hi,
    You have to create an action Listener in the bean for any button.
    Then call an AM method.
    In that you have to do the following
    ViewObject yourVO = getYourVO();
    Row r = yourVo.createRow();
    r.setAttribute("Column1", value1); //the name of column should be as it is in your vo attribute.
    yourVO.insertRow(r);
    this.getDbTransaction().commit();
    Thanks

  • Problem inserting data into database (increment problem)

    I have a servlet page that gets various data from a bean and executes multiple SQL statements to store this data. Beacuase i want to insert data into a number of tables that are related with a one to many relationship I am not using the auto increment function in mySQL. Instead i have created a counter bean that increments each time the servlet is involked. I am using this counter to set the primary key ID in the quesiton table that i insert data into and I am alos inserting it into another table as a foreign key which relates a number or records in the outcomes table to one record in the question table. I am havin a few problems getting it to work.
    Firstly the bean counter works but when the tomcat server is shutdown the counter is reset which will cause conflicts in the database no doubt and secondly even though i have not shut my server down i seem to be getting the following error saying there is a duplicate key even though there is no data in the database.
    Here is the exception.
    javax.servlet.ServletException: Duplicate entry '4' for key 1     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    org.apache.jsp.authoring.question_005fmanager.process_005fquestion_jsp._jspService(process_005fquestion_jsp.java:469)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.sql.SQLException: Duplicate entry '4' for key 1
    com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
    com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)     com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1366)     com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:952)     com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1974)     com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1897)     com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1758)     org.apache.jsp.authoring.question_005fmanager.process_005fquestion_jsp._jspService(process_005fquestion_jsp.java:140)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    My code is here
    // gets the feedback string parameters
         if(request.getParameterValues("feedbackBox") != null)
                   String[] feedbackList = request.getParameterValues("feedbackBox");
                   questionData.feedback = feedbackList;
         //gets the session username variable
         String insertQuestion1__username = null;
         if(session.getValue("MM_Username") != null){ insertQuestion1__username = (String)session.getValue("MM_Username");}
         //Creates a new mySQL date
         java.sql.Date currentDate = new java.sql.Date((new java.util.Date()).getTime());
         //goes thorugh each element of the scores array and calculates maxScore 
         questionData.maxScore = 0;
         for (int i = 0; i < questionData.scores.length; i++) {
                   questionData.maxScore = questionData.maxScore + questionData.scores;
         //increments count;
         synchronized(page) {
    appCounter.increaseCount();
         int counter = appCounter.count;
         Driver DriverinsertQuestion = (Driver)Class.forName(MM_connQuestion_DRIVER).newInstance();
         Connection ConninsertQuestion1 = DriverManager.getConnection(MM_connQuestion_STRING,MM_connQuestion_USERNAME,MM_connQuestion_PASSWORD);
         questionData.numOutcomes = questionData.choices.length;
         while (counter != 0)
              int questionID = counter;
              PreparedStatement insertQuestion1 = ConninsertQuestion1.prepareStatement("INSERT INTO Question.question (Question_ID, Topic_ID, Description, Image, Author, Created_Date, Max_Score, Question_Type) VALUES (" + questionID + ", '" + questionData.topicID + "', '" + questionData.questionText + "', '" + questionData.questionImage + "', '" insertQuestion1__username "', '" + currentDate + "', " + questionData.maxScore + ", '" + questionData.questionType + "') ");
              insertQuestion1.executeUpdate();          
         Driver DriverinsertQuestion2 = (Driver)Class.forName(MM_connAnswer_DRIVER).newInstance();
         Connection ConninsertQuestion2 = DriverManager.getConnection(MM_connAnswer_STRING,MM_connAnswer_USERNAME,MM_connAnswer_PASSWORD);
         PreparedStatement insertQuestion2 = ConninsertQuestion2.prepareStatement("INSERT INTO Answer.question (Question_ID, Question_Description, Question_Type, Topic, Number_Outcomes, Question_Wording) VALUES ('" counter "', '" questionData.questionLabel "', '" questionData.questionType "', '" questionData.questionType "', '" questionData.topicID "', '" questionData.numOutcomes "', '" questionData.questionText "' ) ");
         insertQuestion2.executeUpdate();
         Driver DriverinsertOutcomes = (Driver)Class.forName(MM_connAnswer_DRIVER).newInstance();
         Connection ConninsertOutcomes = DriverManager.getConnection(MM_connAnswer_STRING,MM_connAnswer_USERNAME,MM_connAnswer_PASSWORD);
         for (int i=0; i < questionData.numOutcomes; i ++)
         PreparedStatement insertOutcomes = ConninsertOutcomes.prepareStatement("INSERT INTO Answer.outcome (Question_ID, Outcome_Number, Outcome_Text, Score, Feedback) VALUES ( '" counter "', '" i "', '" +questionData.choices[i]+ "', '" +questionData.scores[i]+ "', '" +questionData.feedback[i]+ "' ) ");
         insertOutcomes.executeUpdate();
    Does anyone know where i am going wrong or how to fix this problem. I would like to know wheter i am doing this the right way. Is thjis the most practical way to use a counter bean or is there a better safer way to do it.
    Suggestions would be mcuh appreciated
    Thanks

    hi Narendran,
        i declared itab as follows
    DATA:      tb_final TYPE STANDARD TABLE OF ztable,
                       wa_final TYPE ztable.    "work area
    i am populating tb_final as follows:
                 wa_final-vkorg = wa_ycostctr_kunwe-vkorg.
                  wa_final-vtweg = wa_ycostctr_kunwe-vtweg.
                  wa_final-spart = wa_ycostctr_kunwe-spart.
                  wa_final-kunwe = wa_ycostctr_kunwe-kunwe.
                  wa_final-kondm = wa_ycostctr_kunwe-kondm.
                  wa_final-kschl = wa_ycostctr_2-kschl.
                  wa_final-hkont = wa_ycostctr_2-saknr.
                  wa_final-kostl = wa_ycostctr_kunwe-kostl.
            APPEND wa_final TO tb_final.
                  CLEAR wa_final.
    here i am not populating Mandt field.
    finally in tb_final am not getting the proper data .
    kindly help me.
    Thanks,
    Praveena

  • How do you access a web service to insert data into table?

    Ok I have a simple html/jsp survey form to host on our web site. Because of firewall issues I cannot do a direct connect to the database and insert the data from the form. So I need to take the data from the survey form, and pass it to an existing web service, or create a web service that will insert this information for me into the database table?
    Thanks again.
    orozco

    Thanks for the reply shanu. Well, because of firewall issues, as a work around we use a web service to insert data into the database table. Since the Web Service already exist, we just thought it would be easy enough just to pass the parameters to it, and have it do the insert. So really all I need is just to communicate with the already existing web service. I will be honest though I have not really worked with web services before.
    orozcom

  • 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).

  • 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 data into po_lines_archive_all

    I',m making a web app. using the Jdev (RUP4) with OA Extension.
    I need to be clear about if i'm allowed to insert data into for instance the po_lines_archive_all table without using any API's (assuming that I'm following the described approch within the framework)?
    In the case I'm not allowed, where do I locate the API which could do the trick?

    hi Jaco Verheul and tapashray
    first of all it's not po_lines_archive_all, but PO_lines_all (sorry that's my mistake)
    If you look at the mentioned version of the Oracle Order Management Open Interface APIs page 2-151 then you find the following sample code:
    Create Operation Example 2
    Inserting a new line into an existing order.
    Warning: You cannot insert new lines (or, process any other
    entity) belonging to different orders in one process order call
    -- NEW LINE RECORD
    l_line_tbl(1) := OE_ORDER_PUB.G_MISS_LINE_REC;
    -- Primary key of the parent entity (If not passed, this will be retrieved
    from the parent record, p_header_rec, if it was also passed to process order
    else there will be an error in the processing of this line).
    l_line_tbl(1).header_id := 1000;
    -- Attributes for the new line
    l_line_tbl(1).inventory_item_id := 311;
    l_line_tbl(1).ordered_quantity := 1;
    -- Indicator that a new line is being created
    l_line_tbl(1).operation := OE_GLOBALS.G_OPR_CREATE;
    -- CALL TO PROCESS ORDER
    OE_ORDER_PUB.Process_Order(........
    -- Passing just the entity records that are being created
    p_line_tbl=> l_line_tbl
    -- OUT variables
    And since I want to inserting a new line into an existing order that should be OK right? There is also sample code on how to update, delete etc, in many other scenarios.
    The link Jaco Verheul is refering to does not work at the time, so I will check it later
    Thanks,
    Michael

  • Insert data into oracle database using a PHP form

    I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
    NOTE: I don't have any problem connecting to the database using php.
    Here is the code I'm using:
    <?php
    // just print form asking for name if none was entered
    if( !isset($query)) {   
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Name: ";
    echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // insert client's name
    $query = "INSERT INTO client (name) VALUES ($data)";
    // connect to Oracle
    $username = "xxxx";
    $paswd = "yyyyyy";
    $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
    "(HOST=patriot.gmu.edu)(PORT=1521))".
    "(CONNECT_DATA=(SID=COSC)))";
    $db_conn = ocilogon($username, $paswd, $dbstring);
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>
    Thanks for your help. I will also appreciate a better was to do it.
    Tony

    resumption and jer,
    Sorry I cannot format the code for easy reading!
    The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
    <?php
    // connect to oracle
    $username = "xxxxx";
         $paswd = "yyyyy";
         $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
              "(HOST=patriot.gmu.edu)(PORT=1521))".
              "(CONNECT_DATA=(SID=COSC)))";
         $db_conn = ocilogon($username, $paswd, $dbstring);
    // username and password will be unset if they weren't passed,
    // or if they were wrong
    if( !isset($query)) {
    // just print form asking for account details
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Query: ";
    echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // remove unwanted slashes from the query
    $query = stripslashes($query);
    // run the query
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    // Open the HTML table.
    print '<table border="1" cellspacing="0" cellpadding="3">';
    // Read fetched headers.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
    print '</tr>';
    // Read fetched data.
    while (ocifetch($stmt))
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="v">'.ociresult($stmt,$i).'</td>';
    print '</tr>';
    // Close the HTML table.
    print '</table>';
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>

  • Insert data into fact table from source database tables

    here i try to insert data into fact table from source database tables here is the query 
    ALTER procedure [dbo].[facttable]
    as
    insert into [pp dw].dbo.Dimfact(Prod_ID,Production_ID,Material_ID,Equip_ID,WC_ID,Recipe_ID,Quantity,costprice)
    select Products.[Product ID],[Production ID],Materials.[Material ID],[Equipment ID],[Work Centre ID],[Recipy ID],Quantity,[cost price]
    from
    [PRODUCTION PLANNING 2].dbo.[Products],
    [PRODUCTION PLANNING 2].dbo.[Production Detail],
    [PRODUCTION PLANNING 2].dbo.[Material category],
    [PRODUCTION PLANNING 2].dbo.[Materials],
    [PRODUCTION PLANNING 2].dbo.[Equipment],
    [PRODUCTION PLANNING 2].dbo.[Working Centre] ,
    [PRODUCTION PLANNING 2].dbo.[Recipies]
    where
    Products.[Product ID] in (13, 14, 15, 16, 17) and
    [Production Detail].[Production ID] in (1, 2, 3) and
    [Materials].[Material ID] in (1, 2, 3, 4, 5) and
    [Equipment].[Equipment ID] in (1, 2, 3, 4) and
    [Working Centre].[Work Centre ID] in (1, 2, 3) and
    [Recipies].[Recipy ID] in (1, 2, 3) and
    [Material category].[Category ID] in (8, 9, 10, 11, 12, 13)
    and when i execute query it shows me error 
    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Dimfact_Dimproduct". The conflict occurred in database "pp dw", table "dbo.Dimproduct", column 'Prod_ID'.
    ERD IS
    HOW TO SOLVE THIS PROBLEM?

    I cant see any join conditions in your query posted. Whats the purpose of the query above. It will just bring you a cartesian product (cross join) of tables involved subjected to filters. Are you sure this is the correct query?
    The error you're getting may be because you've not yet populated DimProduct or may be because of logic you used in popultaing DimProduct causing it to miss some records which is what query is referring to in above case.
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Native SQL: insert data into oracle database, no return message.

    hi,
    the statement : insert into <TableName> values (Source)
    how can I know if the data have already insert to the database table?
    now I have a program have this problem: the data has already exist, but there's no error message return when insert the same data again.
    data: dbs like dbcon-con_name value 'HRGK',
                       dbtype type dbcon_dbms.
    data: sqlerr_ref type ref to cx_sql_exception,
             exc_ref    type ref to cx_sy_native_sql_error,
             error_text type string.
    data: cnt type i,
            i(2) type c.
    set locale language 'E'.
    EXEC SQL.
      CONNECT TO :DBS
    ENDEXEC.
    EXEC SQL.
      SET CONNECTION :DBS
    ENDEXEC.
    EXEC SQL.
      SELECT COUNT(*) from org_unit into :cnt
    ENDEXEC.
    write: / cnt.
    *do.
    i = 'A'.               
    try.
        EXEC SQL.
          BEGIN
           insert into ORG_UNIT ( ORGAN_ID, UNIT_NO, UNIT_NAME, PARENT_ID)
                         values ( 'A', '123412', 'SDFSG', 'DDS');                     " ORGAN_ID is primary key
    " If the data 'A' has already exist in database ORG_UNIT, it will show error message
    " But if I use :I instead 'A', it will not show error message.
            IF SQL%FOUND THEN
               COMMIT;
            END IF;
          END;
        endexec.
        EXEC SQL.
          SELECT COUNT(*) from ORG_UNIT into :cnt
        ENDEXEC.
        write: / cnt.
    catch cx_sy_native_sql_error into exc_ref.
        error_text = exc_ref->get_text( ).
        write: / error_text.
      catch cx_sql_exception into sqlerr_ref.
        perform handle_sql_exception using sqlerr_ref.
    endtry.
    EXEC SQL.
      disconnect :DBS
    ENDEXEC.
    *enddo.
    *&      Form  handle_sql_exception
    form handle_sql_exception
      using p_sqlerr_ref type ref to cx_sql_exception.
      format color col_negative.
      if p_sqlerr_ref->db_error = 'X'.
        write: / 'SQL error occured:', p_sqlerr_ref->sql_code,
               / p_sqlerr_ref->sql_message.                     "#EC NOTEXT
      else.
        write:
          / 'Error from DBI (details in dev-trace):',
            p_sqlerr_ref->internal_error.                       "#EC NOTEXT
      endif.
    endform.                    "handle_sql_exception
    please help to see the words:
    *" If the data 'A' has already exist in database ORG_UNIT, it will show error message*
    *" But if I use :I instead 'A', it will not show error message.*
    in the program.
    Thanks a lot!

    resumption and jer,
    Sorry I cannot format the code for easy reading!
    The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
    <?php
    // connect to oracle
    $username = "xxxxx";
         $paswd = "yyyyy";
         $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
              "(HOST=patriot.gmu.edu)(PORT=1521))".
              "(CONNECT_DATA=(SID=COSC)))";
         $db_conn = ocilogon($username, $paswd, $dbstring);
    // username and password will be unset if they weren't passed,
    // or if they were wrong
    if( !isset($query)) {
    // just print form asking for account details
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Query: ";
    echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // remove unwanted slashes from the query
    $query = stripslashes($query);
    // run the query
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    // Open the HTML table.
    print '<table border="1" cellspacing="0" cellpadding="3">';
    // Read fetched headers.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
    print '</tr>';
    // Read fetched data.
    while (ocifetch($stmt))
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="v">'.ociresult($stmt,$i).'</td>';
    print '</tr>';
    // Close the HTML table.
    print '</table>';
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>

  • Insert Data into Table from TXT or CSV file !!!!!

    Dear All,
    Recently I have started working on APEX. In Oracle Forms, we used to use TEXT_IO for inserting records into tables from txt files. Now I want to do the same thing in apex 3.2. How can I insert data into tables from txt of csv files.
    Waiting of your valuable suggestions.
    With kind regards,
    Yousuf.

    Yousuf
    wwv_flow_files is used by APEX to hold uploaded files.
    If you incorporate a file browse item on you page, browse for the selected file, then submit the page (having the PL/SQL process described as an on suibmit process) then what I detailed should work.
    If you don't need users to have access to this then just go to Home>Utilities>Data Load/Unload in APEX and there is a handy load utility there that does it all for you.
    Cheers
    Ben

  • Invoking  Servlet to insert  data  into database

    I have written a compose page in html which on clicking SEND button has to call a servlet which inserts the values entered in htmlpage int to database .
    Can any one suggest me how it is done.
    thanks....:)

    for inserting data into the database u need to do the following
    1)write the servlet doGet method.Inside it use the object of the HttpServletRequest to retrieve the values entered in the html page.The method getParameter is used for that.If it is going to be a name written in textbox it should be like
    req.getParameter("txtname");
    req being the object of the HttpServletRequest object and txtname the name of the textbox.
    2)Load the driver
    3)Fix the connection
    4)Write a preparedstatement or statement which would insert the value which is requested above
    5)Execute the query.
    thats it
    All the best
    VaijayanthiBalaraman

  • How to insert data into a table only when data has changed its value (when compared to the previous inserted value)

    I wish to insert data into a table only when the value of the inserted data has changed. Thus, in a time series, if the value of the data at time, t-1, is 206 then if the data to be inserted at time t is 206, then it is skipped (not entered).
    If the value of the data at time t+1 is 206, it is skipped also; until the value changes, so if the value at t+1 was 205, then that would be inserted, and if at time t+2 the data is 206, it would be inserted too.
    What is the best way to do it without increasing overheads?

    This view works:
    SELECT
    i.IDNO,i.[Date],i.[Level]
    FROM
    mytable i
    INNER
    JOIN mytable
    d
    ON
    d.IDNO
    = i.IDNO-1
    WHERE
    i.[Level]
    <> d.[Level]
    on this mytable below.  A trigger could be quite useful here although I am cautious using them. However I wish to avoid the overhead by not having a temp table (which could be sizable).  mytable below
    should give 3 lines. The IDNO is an identity column.
    IDNO
    Item
    Date
    Level
    1
    X24
    12/23/13 10:41
    22996
    2
    X24
    12/23/13 10:41
    22996
    3
    X24
    12/23/13 9:21
    23256
    4
    X24
    12/23/13 9:21
    23256
    5
    X24
    12/23/13 9:22
    23256
    6
    X24
    12/23/13 9:22
    23256
    7
    X24
    12/23/13 9:22
    22916

Maybe you are looking for

  • How do I sync my iphone with itunes without losing everything on my phone?

    How do I sync my iphone with itunes without losing everything on my phone?

  • [Slow NAL startup] How to speed up?

    We are a school with about 600 pc's running Windows XP + Novell Client 4.91 sp2. And one of the servers is running Netware 5.1 sp6, Zenworks for Desktops 4 and Zenworks for servers 3. We have 482 application objects in our tree. The problem is that a

  • IPhone tethering to get around port blocking

    Hello all. My company/institution blocks imap port 993 so that email is not stored locally on company computers. (I find this unreasonable but it is their choice). However, sometimes I bring my laptop from home and wish to access my mail using Mac Ma

  • How to configure Hibernate in JBoss

    Hi, I'm using JBoss to run my application. we are migrating complete application from JDBC to Hibernate, Can any one explain how should i configure Hibernate in JBoss server Cheers

  • Deleting multiple images

    I've accumulated so many photos that they're taking up too much space, and I don't use them.  I'm trying to find a way to delete multiple images using Adobe Bridge CS5.  I assumed it would be easiest through this program.  Its taking too much time to