Servlet and Database Connectivity

Hi,
I have got a basic question. I am connecting to a database through a servlet and displaying a table. What I need to do is have three buttons at the bottom of the table like "ADD", "DELETE" "MODIFY". I am wondering how I can add buttons to the HTML page through the servlet, select a row and click on one of the buttons to MODIFY/DELETE and how to capture the actions of each button when clicked like when "ADD" button is clicked it should pass control to a servlet "add.java". If i plan to include a javascript how can i call from the servlet, is there a way. If anyone could throw me some light or atleast point me in the right direction that would be great.
Thanks
Chak

you can even use buttons!
HTML:
<input type="submit" name="add" value="Add">
<input type="submit" name="modify" value="Modify">
<input type="submit" name="delete" value="Delete">
Servlet:
String addButton = req.getParameter("add");
String modifyButton = req.getParameter("modify");
String deleteButton = req.getParameter("delete");
So when the add-Button is clicked, addButton equals to "add", modifyButton==null and deleteButton==null, and vice versa

Similar Messages

  • Servlets and database connectivity

    I have connected my html webpage to a database in mysql. The servlet takes the answer of the radio button and compare it with the answer stored in the database.
    Is it possible to have two queries in one servlet?? Because when the servlet is run on the webpage it opens another html tellin the user if the answer was correct/incorrect. On that same page I want it to display the next question and set of radio buttons.
    Help!

    I have connected my html webpage to a database in
    mysql. The servlet takes the answer of the radio
    button and compare it with the answer stored in the
    database.
    Is it possible to have two queries in one servlet??
    Because when the servlet is run on the webpage it
    opens another html tellin the user if the answer was
    correct/incorrect. On that same page I want it to
    display the next question and set of radio buttons.
    Help!You may need to declare couple different Statement's or preparedStatements's depending wich one you use or you can just use the same ResultSet twice.
    Can't help you anymore without seeing your code

  • Performance with MySQL and Database connectivity toolbox

    Hi!
    I'm having quite some problems with the performance of MySQL and Database connectivity toolbox. However, I'm very happy with the ease of using database connectivity toolbox. The background is:
    I have 61 variables (ints and floats) which I would like to save in the MySQL-database. This is no problem, however, the loop time increases from 8ms to 50ms when using the database. I have concluded that it has to do with the DB Tools Insert Data.vi and I think that I have some kind of performance issue with this VI. The CPU never reach more the 15% of its maximum performance. I use a default setup and connect through ODBC.
    My questions are:
    1. I would like to save 61 variables each 8-10ms, is this impossible using this solution?
    2. Is there any way of increasing the performance of the DB Tools Insert Data.vi or use any other VI?
    3. Is there any way of adjusting the MySQL setup to achieve better performance?
    Thank you very much for your time.
    Regards,
    Mattias

    First of all, thank you very much for your time. All of you have been really good support to me.
    >> Is your database on a different computer?  Does your loop execute 61 times? 
    Database is on the same computer as the MySQL server.
    The loop saves 61 values at once to the database, in one SQL-statement.
    I have now added the front panel and block diagram for my test-VI. I have implemented the queue system and separate loops for producer and consumer. However, since the queue is building up faster then the consumer loop consumes values, the queue is building up quite fast and the disc starts working.
    The test database table that I add data to is created by a simple:
    create table test(aa int, bb char(15));
    ...I'm sure that this can be improved in some way.
    I always open and close the connection to the database "outside the loop". However, it still takes some 40-50 ms to save the data to the database table - so, unfortunatly no progress to far. I currently just want to save the data.
    Any more advise will be gratefully accepted.
    Regards,
    Mattias
    Message Edited by mattias@hv on 10-23-2007 07:50 AM
    Attachments:
    front panel 2.JPG ‏101 KB
    block diagram.JPG ‏135 KB

  • I run Dev 6i on Windows 2008 R2 64-bit,the forms are working fine after connection to the database but the reports continue to request for username, password and database connection string every time i try to open a report.

    I receive REP-0501: Unable to connect to specified database. I run developer 6i application on windows 2008 r2. I have applied the nn60.dll and nnb60.dll files to the \BIN directory. The forms are working fine. The reports will only display after the correct user id (username, password and database connection string) is supplied. This is happening to all attempts to open already complied form. Pls, help.

    If you are connecting to an Oracle 11g database, remember that by default the passwords are case sensitive. To disable that, run
    ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;

  • Enabling Usage Rights for Web Service and Database connectivity

    We are looking for code that allows us to enable web service and database connectivity rights into a form. We are using LiveCycle Forms 7.2 to render the XDP and merge data. Because we are merging data into the form, it has to be reader enabled through the  code everytime it is presented to the user in our application.
    usageRights[0] = com.adobe.document.pdf.DOCUMENT_SAVE.value;
    usageRights[1] = com.adobe.document.pdf.FORM_FILL_IN.value;
    usageRights[2] = com.adobe.document.pdf.FORM_EXPORT.value;
    usageRights[3] = com.adobe.document.pdf.FORM_IMPORT.value;
    usageRights[4] = com.adobe.document.pdf.FORM_ONLINE.value;
    Anyone's help would be greatly appreciated

    This topic was cross posted.  See responses here:
    http://forums.adobe.com/message/2111421#2111421

  • (IMP)Application module and database connection

    Hi,
    How application module pooling and database connection pooling is working ?
    Currently i m facing a problem like if i am creating 10 browser session then it doesn't mean that i'll have only 10 db sessions. While closing the browser session of application module time out respective db session is not removed.
    In this case, invalid db session are created in bulk which is crashing database sometime. We have writter script to kill those session periodically but in this case if application module is accessing such dbconnection then we are getting session killed error or not logged in error.
    To over come we need to bounce the server (middle tier).
    Is there any proper way to solve this or am i doing something wrong ?
    Please let me know if you need any more details.
    Thanks in advance
    Devang

    Thanks for your prompt reply Ricky.
    I just found out that in some of the JSP pages in application
    <jbo:ReleasePageResources/> is not written. Should this problem arise because of this?
    could you please tell me how can I release page resources in UIX pages ?
    Datasources.xml file content
    <data-source class="com.evermind.sql.DriverManagerDataSource"
    name="AITDS"
    location="jdbc/AITCoreDS"
    pooled-location="jdbc/pooled/AITPDS"
    xa-location="jdbc/xa/AITXADS"
    ejb-location="jdbc/AITDS"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username=<USERNAME>
    password=<PASSWORD>
    url=<URL>
    inactivity-timeout="30"
    />
    bc4j.xcfg file
    <BC4JConfig>
    <AppModuleConfigBag>
    <AppModuleConfig name="GsaServerModuleLocal">
    <DeployPlatform>LOCAL</DeployPlatform>
    <JDBCDataSource>jdbc/AITCoreDS</JDBCDataSource>
    <jbo.project>gsa</jbo.project>
    <AppModuleJndiName>oracle.appsit.gsa.server.GsaServerModule</AppModuleJndiName>
    <java.naming.factory.initial>oracle.jbo.common.JboInitialContextFactory</java.naming.factory.initial>
    <ApplicationName>oracle.appsit.gsa.server.GsaServerModule</ApplicationName>
    </AppModuleConfig>
    </AppModuleConfigBag>
    </BC4JConfig>
    Let me know if you need any more detail.
    Thanks in advance
    Devang

  • Servlet and Database access

    This is my first database program using servlet. Also I use ECS to create the HTML document.
    I accept data from a HTML page and display on the screen as well as writing to a TABLE (in instantDB)
    Do I have to have the database connection in INIT() method ?
    -------------Here's the code ---------------------------------------------------
    public class work2_db extends HttpServlet {
    public void doPost(HttpServletRequest request,
              HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String dbName = "db";
         String tableName = "survey";
         Connection conn = null;
         Statement stmt = null;
         System.out.print("\nLoading JDBC driver...\n\n");
         try {
         // InstantDB JDBC driver
         Class.forName("com.lutris.instantdb.jdbc.idbDriver");
         // MS Access, use default JDBC-ODBC driver
         // Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         } catch(ClassNotFoundException e) {
         e.printStackTrace();
         System.exit(1);
         try {
         System.out.print("Connecting to " + dbName + " database...\n\n");
         // InstantDB
         String url = "jdbc:idb:" + dbName;
         // InstantDB, specify the configuration file name in URL
         conn = DriverManager.getConnection(url + ".prp");
         // MS Access
         //conn = DriverManager.getConnection(url);
         System.out.println("Connected to and created database " + dbName);
         System.out.print("Accessing new " + tableName + " table...\n\n");
         stmt = conn.createStatement();
         } catch (SQLException se) {
         se.printStackTrace();
         System.exit(1);
    int id=0;
    //Go to the last record of the result set to get the next Survey ID
    String queryString = "SELECT * FROM " + tableName ;
         ResultSet rset = stmt.executeQuery(queryString);
         while (rset.next()) {
         id = rset.getInt("surveyid");
         id++; // This is the Survey ID for this new survey.
    rset.close();
    int service[] = {0,0,0,0,0,0};
    int level[] = {0,0,0,0,0};
    Body body = new Body();
    Html html = new Html()
    .addElement(new Head()
         .addElement(new Title("Survey Conformation")))
    .addElement(body);
    body.addElement(new H1("Thank you! Your Survey is accepted."));
    body.addElement(request.getParameter("salutation") + " " +
              request.getParameter("firstname") + " " +
              request.getParameter("lastname"))
    .addElement(new BR());
    body.addElement(request.getParameter("company"))
    .addElement(new BR());
    body.addElement(request.getParameter("street"))
    .addElement(new BR());
    body.addElement(request.getParameter("city") + " " +
              request.getParameter("state") + " " +
              request.getParameter("postal"))
    .addElement(new BR());
    body.addElement(request.getParameter("country"))
    .addElement(new BR());
    body.addElement("Email: " + request.getParameter("email"))
    .addElement(new BR())
    .addElement(new BR());
    body.addElement("You Travelled with us to : " +
              request.getParameter("destination"))
    .addElement(new BR());
    body.addElement("You used our following Services : ");
    body.addElement(new BR());
    String values[] = request.getParameterValues("service");
    if (values != null) {
    UL list = new UL();
    for (int i = 0; i < values.length; i++) {
         list.addElement(new LI(values));
         // setup category 1 feedback
         if (values[i] != null)
         service[i] = 1;
    body.addElement(list);
    body.addElement(new BR());
    body.addElement("Your satisfaction level : ");
         body.addElement(request.getParameter("level") + " " +
                   request.getParameter("good") + " " +
                   request.getParameter("better") + " " +
                   request.getParameter("best") + " " +
                   request.getParameter("very poor quality") + " " +
                   request.getParameter("none"))
    .addElement(new BR());
    body.addElement("You said we Can improve our Service as follows: " +
              request.getParameter("comments"));
    out.println(html.toString());
    //set up category level feed back
         if (request.getParameter("good") != null)
         level[1] = 1;
         else if (request.getParameter("better") != null)
         level[2] = 1;
         else if (request.getParameter("best") != null)
         level[3] = 1;
         else if (request.getParameter("very poor quality") != null)
         level[4] = 1;
         else if (request.getParameter("none") != null)
    level[5] = 1;
    //Now write the collected data into the database
    String insertString = "INSERT intO" + tableName+
    id + "," + service[1] + "," + service[2] + "," + service[3] + "," +
    + service[4] + "," + service[5] + "," + service[6] + "," +
    + level[1] + "," + level[2] + "," + level[3] + "," +
    + level[4] + "," + level[5] ;
    stmt.close();
    conn.close();
    -------------------------Compile Errors ---------------------------------------------------------------------------------
    I am getting following error for the exception handling. Can someone help me !!! PLEASE

    Hi JDKPSSH,
    Do I have to have the database connection in INIT() method ?not mandatory to have it in init() ( not INIT() ) method.
    I am getting following error for the exception handling. Can someone help me !!! PLEASE Check out by putting the following statements in try block
    stmt.close();
    conn.close();otherwise you get a compile time error.
    unreported exception java.sql.SQLException; must be caught or declared to be thrown
    Thanks,
    Sanath Kumar.

  • J2ME and database connectivity

    We are currently looking at ways to connect a pda to a server on a local Intranet. I have been told that the J2ME Wireless Toolkit does not include JDBC for database connectivity (I have not verified this). Does anybody have any ideas?

    yeah, of course you have to send the sql statement to the servlet. The servlet then connects to the DB, exeutes the statement and puts the result in some format, you can transfer to the phone since you cant serialize the java.sql.ResultSet directly. Maybe you would transform this to a String, each field delimited by a special character, each row delimited by another. make sure these characters wont appear in the fields ;-)
    The more correct way would be creating some XML structure from the DB result and transfer this but this can get very large and XML processing on mobiles is not recommended for large XML information.
    hth
    Kay

  • How to use sql request with Jdev and database connection

    Hello,
    I have a login page with simple username and password inputsecret text and a button validate! I would like, when the user click on the validate button, to check in the database that the user and password matches. I've done the "Method BIndind..." with the commandButton_action and the database connection works fine.
    How can I use an already existing procedure, say authenticate, wich is stored in the database to authenticate my user ?
    Do I have to create a jdbc connection in java even if I've done the connection with the "create new database connection" wizard ?
    String s1 = "jdbc:oracle:thin:@address:1521:ORCL";
    System.out.println( "Connecting with: " );
    System.out.println( s1 );
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    this.conn = DriverManager.getConnection( s1,"user","pass");
    thanks for your help

    Creating a connection to the DB in JDeveloper doesn't mean that your application is now connected to the DB - so yes you do need to create a connection to the database using JDBC.
    One note - if you are trying to do a database user authentication the following is probably the better way to go about it:
    http://www.oracle.com/technology/products/jdev/howtos/1013/oc4jjaas/oc4j_jaas_login_module.htm

  • Oracle 64-bit and database connectivity toolkit

    Hello- I am attempting to connect to an Oracle database by interfacing the databse connectivity toolkit with the Oracle 10.2.0.3 64-bit that my customer uses. I am running LV13 32-bit on their machine. I am unable to connect to the database. Are there any known issues with this type of setup? 

    There's some discussion about an unsupported method to use the Database Connectivity Toolkit with 64-bit Windows here: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/64-bit-Database-Toolkit/idi-p/2170088
    That may help with the problem you're seeing.  Something else to consider is the manual (page 1-2):
    The Microsoft ODBC driver for Oracle and the Microsoft OLE DB
    Provider for Oracle do not support BLOB (binary) data types. You
    cannot use Oracle with the Database Connectivity Toolkit for binary
    data with these drivers. Instead, use the OLE DB Provider and ODBC
    driver that Oracle provides. Refer to the Oracle Web site at
    www.oracle.com for more information about the OLE DB Provider
    and the ODBC driver that Oracle provides
    Jeff B.
    Applications Engineer
    National Instruments

  • LabView 5.1 and Database Connectivity Toolkit Compatibility?

    I am looking to serve some data from a LabView 5.1 application up to an Oracle 8i database. I have looked at the current Database Connectivity Toolkit (which uses ADO technology), but am not sure if this will be compatible with LabView 5.1... is it? If not, what are my alternatives? Are older versions of this toolkit available?
    Thanks!

    Also, could someone touch on how forward compatible LabView applications are? In this scenario, I have the same 5.1 application which now requires some database connectivity. Since the SQL Toolkit is no longer supported, I would be left with upgrading LabView to 7.0 and using the Database Connectivity Toolkit. How well (in general) do earlier LabView applications convert to newer versions?
    Thanks again!

  • OLE Objects and Database Connectivity Toolkit

    I am trying to insert and image (jpg) that is created in Labview into an Access database as an OLE object. How do I go about making this conversion, or are there any other suggestions?

    Hello -
    Have you tried any of the shipping examples for the database connectivity tookit? You can find them by navigating Help >> Find Examples >> Toolsets and Modules >> Database Connectivity. The Insert Example.vi may help you get started. Click here to access database examples posted on the Developer Zone.
    Please let me know if any of these examples helped. If not, can you provide more information about the version of LabVIEW and Access you are using? Thanks! Have a great day!
    Becky B.
    Applications Engineer
    National Instruments
    Becky Linton
    National Instruments
    Field Engineer
    Office: 734-464-2463
    Cell: 248-709-2822
    Email: [email protected]

  • AIR application and database connectivity (using JAVA)

    Hi
    I am creating AIR application and I want to connect with the database using java database connectivity (JDBC).
    Can any body give me the some suggestion on how to how to do that.
    Please give me any reference for creating AIR application for database connectivity with mysql/access.
    Thanks
    Sameer

    lots of serching on the google and found that For AIR applications either you use Webservices(JAVA/PHP/.Net) or you can use SQLLite.
    Not found any method for direct connectivity with the database using JDBC.
    If any one found direct connecivity withe database using JAVA then please reply.
    Thanks

  • Jsp and database connection using bean

    * I want create a bean to handle database connectivity.The
              <jsp:usebean> tag uses
              no argument constructor ..so I cannot pass the userid and password to
              the constructor.
              So how can I create a database connection when the user_id and password
              will be a part of parameter ?
              * Now I'm opening database connection in the jsp scriplets. Everytime I
              refresh the
              jsp page a new connection is created ? Is it not going to choke the
              database ? I cannot use connection pool because every user logs in with
              different userid.
              Thanks
              

    You can pass your arguments in this way:
              <jsp:usebean id="myBean" scope="page"/>
              <jsp:setProperty name="myBean" property="userId", value=<%= user_id%>/>
              <jsp:setProperty name="myBean" property="password", value=<%=
              user_password%>/>
              of course, in your bean class, you should create two setter methods,
              setUserId and setPassword.
              Hopefully, this will help you.
              sonia WEN
              Chiranjib Misra wrote:
              > * I want create a bean to handle database connectivity.The
              > <jsp:usebean> tag uses
              > no argument constructor ..so I cannot pass the userid and password to
              > the constructor.
              > So how can I create a database connection when the user_id and password
              > will be a part of parameter ?
              >
              > * Now I'm opening database connection in the jsp scriplets. Everytime I
              > refresh the
              > jsp page a new connection is created ? Is it not going to choke the
              > database ? I cannot use connection pool because every user logs in with
              > different userid.
              >
              > Thanks
              

  • Oc4j and database connections issue (way too many created)

    I seem to be experiencing a serious issue every time someone connects to my application. New connections are made to the database instead of using existing connections (i.e. pooling doesn't seem to work). In my data-sources.xml, the pools are set to have a max-connections of 3, yet when I query the v$sessions view, there are additional sessions created every time the application is hit which has sent it way over the max-connections parameter in the data-sources.xml file. If oc4j is pooling the connections how can this happen? Is there any way of tracking where this is occurring or what could be causing this? (SQLNET.EXPIRE_TIME has been set, database is 10g, oc4j is 101202 and oc4j on linux platform)
    Thanks
    Paul

    Paul,
    According to the documentation for OC4J 10.1.2, if you use the value of the "ejb-location" attribute (from the "data-sources.xml" file) when doing a JNDI lookup of your datasource, then you should be using connection pooling.
    It's probably also an idea to not define a "pooled-location" attribute in your "data-sources.xml" file.
    Also, you can get database connection information via the "Spy" [Web] application. Use the following URL:
    http://oc4jHost:oc4jPort/dmsoc4j/Spy
    Of-course you need to replace "oc4jHost" and "oc4jPort" with the appropriate values. For example if you open your Web browser on the same machine that OC4J is running on, and if you are using the default port, then the URL will be:
    http://localhost:8888/dmsoc4j/Spy
    Good Luck,
    Avi.

Maybe you are looking for

  • Installing ADOBE AIR Runtime ?

    Is it possible to install ADOBE AIR Runtime in silent mode without admin privileges on Windows? Regards

  • IPAD mini - emails going to outbox for 2 weeks - I need to send them

    I have just spent three hours trying to pinpoint problem I have had with my iPAD mini for about two weeks - - 15 messages sitting there in outbox - - I get that smtp.verizon.net - which I understand is correct.  It does seem to be affected by any oth

  • Flex marking a sample code invalid "Access of undefined property"?

    Hey, I used the code from this link: http://tdotblog.info/?q=node/6 When i put it into Flex Builder 3, it has several issues with the code like "Access of undefined property FileStream" (or File). When I run the application, only the typical gray bac

  • Pseudo Flex time for MIDI

    A friend created a piano boogie woogie midi file for me. I would like to convert it to standard musical notaton. He did not use a click track and varied his tempo quite a bit during the piece. The midi software was recording at 120 BPM but he was act

  • AE CS6 Far slower than 5.5 for some reason.

    Howdy.. I have a fairly complex photo-collage comp in AE CS6. It's 1m long. When I render with CS6, the estimated time is around 6 hours, however, if I 'save-as' a 5.5 project and render than with 5.5. the ETA is juat 2.25 hours... Anyone else seeing