Backing up a database from a jsp or servlet

Please can someone give a suggestion on how I can backup my database from jsp interface or servlet code.I use my mssql database although I can do the backing up through the Enterprise Manager but I dont know the code to use or embed in my jsp and add a backup button for users to make it users friendly.
Please I need this ASAP.
Thanks in advance.

You issue the BACKUP database command to do the backup.
You could therefore write a script which you execute from the Servlet using the Runtime.exec methods.

Similar Messages

  • I have to ping a machine from my JSP or Servlet

    I have to ping a machine from my JSP or Servlet what is the best method to do this...

    1) There is a method in java.net.InetAddress called isReachable in JDK 1.5. Because the majority of the Web containers do not support JDK 1.5 nowadays, you can't use it directly in your servlet or JSP. (JBoss 3.2.4 promises to support JDK 1.5 but I couldn't use it with the Beta2.) If you have lots and lots of memory you can try to keep a program running in 1.5 that simply does the "ping" thing, and communicates via sockets with your servlet or JSP.
    2) JNI in Web containers can be used but imposes several problems in class loaders. If you can find a JNI library that can do ICMP ECHO try to use it, but the deployment of the JNI library depends heavily on the Web container.
    3) You can have a program (written in C for instance) that is continuously running and does only the "ping" function, and communicates via sockets with your servlet and JSP. You can have it running now and wait some years until the "isReachable" method is available to your programs.
    4) You could try to Runtime.exec the "ping" command-line executable, but if you are using a Web container you could have some problems (for instance, if you run the Web container as a Windows service the command will not be adequately run, or it runs but never terminates, etc.)

  • I can't connect to MySQL database from The JSP Standard Tag Library

    Hi All !
    I have a problem, please help me anybody !
    I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java\jdk1.5.0_10\jre\lib\ext\mysql-connector-java-3.1.13-bin.jar) and in War project folder �WEB-INF/lib� and in [TomcatServer]\common\lib.
    I have in folder�WEB-INF/lib� following files:
    antlr.jar
    commons-beanutils.jar
    commons-collections.jar
    commons-digester.jar
    commons-fileupload.jar
    commons-logging.jar
    commons-validator.jar
    jakarta-oro.jar
    jsf-api.jar
    jsf-impl.jar
    jstl.jar
    mysql-connector-java-3.1.13-bin.jar
    standard.jar
    struts.jar
    I'm using:
    NetBeans 5.5 Build200610171010 (bundled Tomcat 5.5.17)
    Ent.Pack 20061020 Visual Wb Pack 061103
    OS WinXP SP2
    Java 1.5.0_10
    MySQL 5.0.18-nt
    1:<%@page contentType="text/html"%>
    2:<%@page pageEncoding="UTF-8"%>
    8: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    9: <%@taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
    10:
    11: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    12: "http://www.w3.org/TR/html4/loose.dtd">
    13:
    14: <sql:setDataSource var="ds"
    15: driver="com.mysql.jdbc.Driver"
    16: url="jdbc:mysql://localhost:3306/test"
    17: user="root"
    18: password="xxxx"/>
    19:
    20:
    21:<sql:query sql="select name, age from People" var="res"
    22: dataSource="${ds}"/>
    I have received report on mistake when entered code at the top:
    �/index.jsp [21;0] According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions�
    I used instead of (dataSource="${ds}")->(dataSource="ds") but this did not work.
    After build and run I have received
    =========================================START=================================
    HTTP Status 500
    type Exception report:
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
    org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17
    =======================================END================================
    Error: "According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions" - but according to documentation such parameter possible.
    BUT WHEN JOINING With DATABASE FROM SERVLET ALL WORK FINE.
    I read this doc - [http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html], this applicable if I Tomcat Admin, but i'am not Admin
    I simply user, i.e. I want to place its database on virtual host (Tomcat+(JSP-JSTL)+MySQL).
    There is idea how can resolve this problem
    Thank you in advance ;)

    For all how have similar problem.
    Decision instead of these ways
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    it is necessary to indicate these
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

  • SQLException while accessing an MS Access database from a JSP

    I have a set of classes for accessing an MS Access database and have set up the database properly(System dsn...etc).These work fine when im using them from a console application....but when im tryng to use these from a jsp im getting an SQL general exception(Error code: 0).Really caught up here.please help.
    Im using jdk 1.6 and tomcat 6.0 and ms access 2000.
    Edited by: Sayantan_Auddy on Oct 15, 2008 12:56 AM

    I have a set of classes for accessing an MS Access database and have set up the database properly(System dsn...etc).These work fine when im using them from a console application....but when im tryng to use these from a jsp im getting an SQL general exception(Error code: 0).Really caught up here.please help.
    Im using jdk 1.6 and tomcat 6.0 and ms access 2000.
    Edited by: Sayantan_Auddy on Oct 15, 2008 12:56 AM

  • How to push back a message to browser using JSP or Servlet?

    Hi,
    I am coding some JSP and Servlet codes, and want to push back a mssage to browser and don't let browser first send a request to server like chat. Who can help me for that?
    Thanks,
    Wise

    You wrote:
    Not quite correct - see Pushlets:I wrote:
    "...to have code running on the client (eg an applet or a flash movie)"
    I add "...(eg an applet or a flash movie OR JavaScript)..." ;-)

  • Error while connecting to the database from a JSP Page

    Hi,
    I am using a simple JSP page which is based on the sample JSP pages from OTN.
    When I try to connect to my database using the following code:
    InitialContext ic = new InitialContext();
    OracleDataSource ds = (OracleDataSource)ic.lookup("jdbc/OTN9iDS");
    m_connection = ds.getConnection();
    I get the following error:
    Naming exception Error while connecting to the database : javax.naming.NameNotFoundException: jdbc/OTN9iDS not found in JDBCTest-JDBCTestProject-webapp
    Does anybody know wht this is happening?
    Any help would be appreciated
    FRank

    Hi Frank,
    Are you using standalone OC4J or 9iAS ? If you are using standalone OC4J then you need to add a proper data source entry in %OC4J_HOME%j2ee\home\config\data-sources.xml file.
    If you are using 9iAS the you can log in to the Enterprise Manager console and add the data source entry by using wizard provided by 9iAS.
    Ensure the case of the JNDI lookup string, since, it is case sensitive.
    Hope this helps.
    Abhijeet

  • Is it possible to return a figure back to the database from a web service

    I have a REST web service setup that has 4 values
    Is it possible to use a db call to grab these 4 values that can be used in an insert to the database?
    Thanks

    If it were SOAP webservices there are other ways, but a simple REST you could do it like this:
    select httpuritype('http://the.server.com/the_url?the_parameters').getxml()
      from dual
    /That gets you an XMLType object that you can then parse to get the results. For example using the XMLTable() function.
    You can see [url http://dspsd.blogspot.dk/2012/10/find-your-way-with-httpuritype-and.html]an example of this method that I blogged about two days ago ;-)
    Edit: Fixed typo HttpUriTType -> HttpUriType ;-)
    Edit again: Fixed method name getxml()
    Edited by: Kim Berg Hansen on Oct 19, 2012 10:01 AM
    Edited by: Kim Berg Hansen on Oct 19, 2012 10:14 AM

  • Finding out the userid from a JSP or servlet. (9.0.2)

    Hi Again!
    I have a JSP in the htdocs directory of my portal which fetches binary objects
    from a content repository. I use this binary.jsp to display images embedded
    in a content portlet shown within the portal. So as far as the browser gots
    the portal page it starts to fetch the images with an ordinary get operation
    to a given URL of the binary.jsp.
    Now I want to be able to find out if the current user is allowed to see the
    image from the content repository, so I have to find out the userid within
    the JSP. But I couldn't find any way to do this. Since the binary.jsp is
    not loaded in the context of the portal, it doesn't know anything about
    the PortletRendererRequest, so thi code returns null:
    PortletRenderRequest oraRequest = (PortletRenderRequest)
    request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
    if ( oraRequest == null ) {
    makeLog ("Could not get PortletRequest!");
    } else {
    oracleUser = oraRequest.getUser().getName();
    So I've tried to put the userID into the servlet session like this
    request.getSession().setAttribute("iASUserName", oracleUser);
    but obviously the binary.jsp doesn't share the same http session object,
    so this code returns null within the binary.jsp
    request.getSession().getAttribute("iASUserName");
    We allready done this with the old version of PDK and JServ and
    everything was OK, except that we used the deprecated API
    request.getSession().setValue("iASUserName", oracleUser);
    request.getSession().getValue("iASUserName");
    No both ways doesn't work, since we are using Orion-Appserver
    and PDK 9.0.2 :-(
    Is there anyone out there with an idea how we can solve
    this problem?

    I could understand what you are lookig for. We can probably relie on cookies to share user information between portal & non-portal resources.
    Example :
    Lets say we have a contributor.jsp viewed through portal. This sets up a cookie in the client machine which carries portal user name. It persists till the end of user session.
    contributor.jsp
    <%
    PortletRenderRequest pr =
    (PortletRenderRequest)request.getAttribute(HttpProvider.PORTLET_RENDER_REQUEST);
    String pUser = pr.getUser().getName();
    /* Customize these strings to suitable names. */
    String pUserKey = "CUR_PORTAL_USER";
    String pDomain = ".oracle.com";
    %>
    <SCRIPT language="JavaScript1.2">
    var today = new Date();
    function setCookie(name, value, domain)
    document.cookie = name + "=" + escape(value) +
    "; path=/" +
    "; domain=" + domain;
    </SCRIPT>
    <BODY onload="javascript:setCookie('<%=pUserKey%>', '<%=pUser%>', '<%=pDomain%>')"/>
    This cookie now will be set in the client machine and any JSP in the same domain will be able to access it.
    Let me know if it offers any help to your problem.
    Thanks,
    Amjad.

  • How does one open a JFrame from a JSP or servlet?

    Hi,
    I have a fairly complex Java app that includes a JFrame that I want to integrate into a Web app. Specifically, I want to enable the user to open a dialog window, which is in the form of a JFrame. Can this be done easily? TIA!
    Bob
    Edited by: FractalBob on Jan 4, 2010 7:48 PM

    FractalBob wrote:
    I like option 3, but I don't see how to implement it. For example, my app includes a JTree embedded in a JScrollPane, so the Web app needs to be able to register an event handler to detect selections on the tree. How is that done?Depends on your choice of web framework. JSF is extensible with richfaces which has a tree control among other controls.
    GWT would allow you to write Swing like code complete with listeners e.t.c.
    You should preview and compare a few of them before selecting one. This should be an easy exercise since you already know what the application needs are.

  • Lost Tomcat, its database and all JSP and HTML files

    I have mistakably uninstalled Tomcat from my machine, it removed the data I stored in the root including HTML and JSP files, I am using windows XP, Is there any way I can recover htem back, atlest the database and the JSP files? please Help

    Also a good example of why you should develop apps in a separate directory structure and then deploy the WAR file to Tomcat.
    You didn't have all your source code under Tomcat, did you?
    You weren't using a source control system like CVS?
    Oh, my. ;)
    You will from now on, I'll bet.
    %

  • How to capture the data from a JSP form

    Hi
    I have a JSP form, My task is to capture the data from a JSP and submit to Data Base. for example I have the field like
    Enter Table name to be created in data base: The table name is to be captured by a servlet and by that table name, table should be created in the data base.
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????

    Get the entered value from the jsp into servlet using request.getParameter("enteredTableName"). it will return the String,pass this table name to execute query using JDBC connection and statement objects.
    -cheers Ram

  • How to display contents from a database to a jsp page

    hi im using hibernate , i want to display the conetents from a databse to jsp page which is having a form
    i want to get the data on the form fields after changing the values i want to write it back to the database
    im using struts and hibernate
    im struck with this plz help me

    j2ee_struts_hibernate wrote:
    hi im using hibernate , You probably shouldn't be using Hibernate.
    i want to display the conetents from a databse to jsp page which is having a form "contents", "database"
    i want to get the data on the form fields after changing the values i want to write it back to the databaseWhat don't you understand? (Sounds like you don't understand anything.)
    im using struts and hibernate How well do you know Struts? Hibernate? JSP? Java?
    im struck with this plz help meAsk a specific question and we'll see what we can do.
    Write a JSP with the form in it; submit to Struts; Struts interacts with the database. That's the flow.
    %

  • Opening and closing database from JSPs

    Hi,
    I have a few web pages with an underlying database, and after some research I seem to have found that accessing this database directly from the JSP is a bad idea. Because of this I have created 2 methods in my JavaBean class to create the database connection and to close the database connection. What I want to have happen is when the user logs in the the site, a database connection is opened by calling the databaseConnection method then once they close the browser the destroyDBConnection is called. How do I go about implementing this approach in my JSPs? thanks for any suggestions
        * Method to create database connection
        public static void dbConnection() {
          try{
              // Step 1: Load the JDBC driver.
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                // Step 2: Establish the connection to the database.
                String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};" +
                        "DBQ=C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5" +
                        "\\webapps\\TheatreDepartment.mdb";
                connection = DriverManager.getConnection(url);
              connection.setAutoCommit(false);
          } catch (SQLException se) {
              System.out.println("SQL Error while connecting to the database : "+
                                  se.toString());
          } /*catch (NamingException ne) {
              System.out.println("Naming exception Error while connecting to the database : "+
                                  ne.toString());
          } */catch (Exception ne) {
              System.out.println("Error while connecting to the database : "+
                                  ne.toString());
        * Destroy the Connection Object.
        public static void destroyDbConnection() throws SQLException {
              if (connection != null || !connection.isClosed() ) {
                connection.close(); // close the connection
      }

    I would suggest you do some more research.
    Take a look into connection pooling.
    Most of the time you do NOT want to give each individual user their own database connection, but rather keep a bunch on hand for people to use.
    http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html
    http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

  • Connecting to a database from Business Components JSP Application

    Hallo All!
    Can anybody give me an advice about connecting to a database from Business Components JSP Application? In all examples I see that Oracle user name and password placed in configuration file.
    How can user provide his own name and password to start Oracle session and how then hi can close this session?
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Dmitri:
    Dear Laura,
    I mean first variant where the database would be the same:
    scott/tiger@database1
    foo/bar@database1
    Of course I understand that we must register every user in database by "CREATE USER XXX" and it is unacceptable for Internet. But it may be very convenient for an Intranet because we can build access restriction based on set of views without any changes in applications.
    Best wishes,
    Dmitri.<HR></BLOCKQUOTE>
    null

  • Pass the data back from the jsp page to the java code

    Hi,
    I have written an iView that receives an event using EPCF and extracts data from the client data bag.
    I need this iView to pass the data back from the jsp page to the java code.
    I am trying to do this using a hidden input field, but I cannot get the code to work.
    Here is the code on the jsp page.
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <hbj:content id="myContext" >
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId">
    <hbj:inputField id="myInputField" type="string" maxlength="100" value="" jsObjectNeeded="true">
    <% myInputField.setVisible(false);%>
    </hbj:inputField>      
       </hbj:form>
      </hbj:page>
    </hbj:content>
    <script language=JavaScript>
    EPCM.subscribeEvent("urn:com.peter", "namedata", window, "eventReceiver");
    function eventReceiver(eventObj) {
         var url = eventObj.dataObject;
         var funcName = htmlb_formid+"_getHtmlbElementId";
         func = window[funcName];
         var ipField = eval(func("myInputField"));
         ipField.setValue(url);
         var form = document.all(htmlb_formid);
         form.submit();
    </script> 
    Here is my java code
    package com.sap.training.portal;
    import com.sapportals.htmlb.InputField;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    public class ListSalesOrder extends PageProcessorComponent {
      public DynPage getPage(){
        return new ListSalesOrderDynPage();
      public static class ListSalesOrderDynPage extends JSPDynPage{
         private String merong;
        public void doInitialization(){
        public void doProcessAfterInput() throws PageException {
              InputField reportfld = (InputField) getComponentByName("myInputField");
              if (reportfld != null)      merong = reportfld.getValueAsDataType().toString();
        public void doProcessBeforeOutput() throws PageException {
              if ( merong != null ) setJspName("merong.jsp");
              else setJspName("ListSalesOrder.jsp");
    Here is DD
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="SharingReference" value="com.sap.portal.htmlb"/>
        <property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
      </application-config>
      <components>
        <component name="SearchSalesOrder">
          <component-config>
            <property name="ComponentType" value="jspnative"/>
            <property name="JSP" value="/pagelet/SearchSalesOrder.jsp"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
        <component name="ListSalesOrder">
          <component-config>
            <property name="ClassName" value="com.sap.training.portal.ListSalesOrder"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    After receive event, then call java script function "eventReceiver" and call "form.submit()".
    But .. PAI Logic in Java code doesn't called ...
    Where is my problme ?
    Help me ...
    Regards, Arnold.

    Hi Arnold,
    you should not do a form.submit yourself. Instead you can put a component called ExternalSubmit to your page:
    ExternalSubmit exSubmit = new ExternalSubmit("EX_SUBMIT"));
    exSubmit.setServerEventName("MyEvent");
    This results in a java script funtion on the page which is called "_htmlb_external_submit_". If you call this function the the form gets submitted and your event handler is called.
    regards,
    Martin

Maybe you are looking for