Accessing postgresql record using servlet

Hello every body,
I am trying to access the postgresql database using servlet. But I found the error of ClassNotFound exception: org.postgresql.Driver. One thing more I am using eclipse ide. I have used the postgresql-8.1-404.jdbc3 driver. And I have set it on class path in eclipse.
package dbservlet.example;
import java.io.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DbServletExample1 extends HttpServlet{
     public String getServletInfo() {
          return "Servlet connects to PostgreSQL database and displays result of a SELECT";
     private Connection dbcon; // Connection for scope of DbServletExample1
     public void init(ServletConfig config) throws ServletException { // "init" sets up a database connection
          String loginUser = "ali";
          String loginPasswd = "ali";
          String loginUrl = "jdbc:postgresql://127.0.0.1:5432/ali"; // Load the PostgreSQL driver
          try{
               Class.forName("org.postgresql.Driver");
               dbcon = DriverManager.getConnection(loginUrl, loginUser, loginPasswd);
          catch (ClassNotFoundException ex){
               System.err.println("ClassNotFoundException: " + ex.getMessage());
               throw new ServletException("Class not found Error");
          catch (SQLException ex){
               System.err.println("SQLException: " + ex.getMessage());
     // Use http GET
     public void doGet(HttpServletRequest request, HttpServletResponse response)
                         throws IOException, ServletException {
          response.setContentType("text/html"); // Response mime type
          PrintWriter out = response.getWriter(); // Output stream to STDOUT
     out.println("<HTML><Head><Title>Db Servelt Example</Title></Head>");
     out.println("<Body><H1>Example of Servlet with Postgres SQL</H1>");
     try {                // Declare our statement               
          Statement statement = dbcon.createStatement();
          String query = "SELECT empid, name, dept, "; // Perform the query
          query += " jobtitle ";
          query += "FROM employee ";
          ResultSet rs = statement.executeQuery(query);
          out.println("<table border>");
          while (rs.next()) {      // Iterate through each row of rs
               String m_id = rs.getString("empid");
               String m_name = rs.getString("name");
               String m_dept = rs.getString("dept");
               String m_jobtitle = rs.getString("jobtitle");
               out.println("<tr>" +
                                   "<td>" + m_id + "</td>" +
                                   "<td>" + m_name + "</td>" +
                                   "<td>" + m_dept +"</td>" +
                                   "<td>" + m_jobtitle + "</td>" +
                              "</tr>");
          out.println("</table></body></html>");
          statement.close();
     catch(Exception ex){
          out.println("<HTML>" +
                         "<Head><Title>" +
                         "Bedrock: Error" +
                         "</Title></Head>\n<Body>" +
                         "<P>SQL error in doGet: " +
                         ex.getMessage() + "</P></Body></HTML>");
          return;
     out.close();
and web.xml file is
<web-app>
          <database>
               <driver>
               <type>org.postgresql.Driver</type>
          <url>jdbc:postgresql://127.0.0.1:5432/ali</url>
          <user>ali</user>
          <password>ali</password>
               </driver>
          </database>
          <servlet>
          <servlet-name>DbServletExample1</servlet-name>
          <servlet-class>dbservlet.example.DbServletExample1</servlet-class>
          </servlet>
          <servlet-mapping>
          <servlet-name>DbServletExample1</servlet-name>
          <url-pattern>/db11</url-pattern>
          </servlet-mapping>
</web-app>
Thanks in advance

That web.xml doesn't look right to me.
what's that <database> tag? I would only expect to see a <resource-ref> in the web.xml.
I would not touch the server.xml. Create a context.xml and put it in your META-INF directory. That should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/your-path" reloadable="true" crossContext="true">
    <Resource name="jdbc/your-jndi"
              auth="Container"
              type="javax.sql.DataSource"
              username="your-username"
              password="your-password"
              driverClassName="your-driver-class"
              url="your-url"
              maxActive="10"
              maxWait="60000"
              removeAbandoned="true"
              removeAbandonedTimeout="60000"/>
</Context>%

Similar Messages

  • How to access serial port using servlet

    I want to communicate with a microcontroller connected to the serial port of my computer.
    *I am using the following:
    Windows 98 operating system
    Tomcat web server 4.1
    *The directory structure is as given:
    Tomcat 4.1/webapps/myjsp/web-inf/classes/remoteservlets.
    I have placed my jsp files in my jsp folder and classfiles in remote servlets folder.
    **my java program has compiled correctly.**
    ** my simple java application which accesses the serial port works fine.***
    *when I start tomcat I am able to access the sevlet as the servlet responds with the button name i have pressed.
    **** I have also tried the following
    Copied file comm.jar in <JAVA_HOME>\jre\lib\ext
    Copied file javax.comm.properties in <JAVA_HOME>\jre\lib
    Copied file win32com.dll in <JAVA_HOME>\lib and also in c:\windows\system32 and c:\windows\system
    ***************which helped me do away with errors.
    still I don't get any output. I dont get any errors either.
    PLEASE HELP. URGENT. i am at my wits end.
    Thank you.

    Servlet is the one which runs in the server side...if u want to comunicate with the serial port of the server in which ur servlet is running can be done but making use of Communication api available....
    U can download the Api from http://java.sun.com/products/javacomm/index.jsp
    There are three levels of classes in the Java communications API:
    High-level classes like CommPortIdentifier and CommPort manage access and ownership of communication ports.
    Low-level classes like SerialPort and ParallelPort provide an interface to physical communications ports. The current release of the Java communications API enables access to serial (RS-232) and parallel (IEEE 1284) ports.
    Driver-level classes provide an interface between the low-level classes and the underlying operating system. Driver-level classes are part of the implementation but not the Java communications API. They should not be used by application programmers.
    regards
    shanu

  • Deleting a MS Access database table record using JOptionPane

    hi!
    just want some help here..
    is there a way to delete a MS Access database record through using JOptionPane?? i've gone through some, probably alot of examples on SELECT, INSERT, UPDATE, DELETE statements but none came up to the stuff i need.
    so far i've seen the DELETE statement like this and also this is a common DELETE statement..
    statement.executeUpdate("DELETE FROM tableName WHERE fieldName01 = 'blablabla' AND fieldName02 = 'etcetcetc'");like INSERT, there's a coding somewhat like this:
    String asd = JOptionPane.showInputDialog(null, "Enter blablabla stuff");
    statement.executeUpdate("INSERT INTO whatEverTableName (tableFieldName) VALUES('"+asd.getText()+"')");so, is it possible using the same method for DELETE??
    help and advices are appreciated in advanced..

    Here's how I did it. Research does help, but sometimes looking at others code does too... You do have to have a dummy file that you made with access though. You can't just make a file file.mdb (it will be corrupt)
         public void createDatabase(String database) throws SQLException{
              try{
                   // This file needs to have been created with MS Access
                   File dbfile = new File(this.dataBaseDir + "dummy.mdb");
                   // This is the new database file being made
                   File newFile = new File(this.dataBaseDir + database + ".mdb");
                   // Copy all bytes from dummy file to new DB file.
                   FileInputStream instream = new FileInputStream(dbfile);
                   FileOutputStream ostream = new FileOutputStream(newFile);
                   int numBytes = instream.available();
                   byte inBytes[] = new byte[numBytes];
                   instream.read(inBytes, 0, numBytes);
                   ostream.write(inBytes, 0, numBytes);
              catch(FileNotFoundException e) { e.printStackTrace();}
              catch(IOException e) { e.printStackTrace();}
              if(DEBUG) System.out.println("creating the " + database + " database");
         }

  • Access very large objects using servlets from database

    hai,
    Please suggest me to access a very large object, for example an image file, from the database using servlets.
    Thanks!
    null

    hai,
    Please suggest me to access a very large object, for example an image file, from the database using servlets.
    Thanks!
    null

  • Recording video/audio files using Flash Meida Server through rmtp, and allow users to access the recorded files through http.

    As titled, what is the way to record video/audio files using Flash Meida Server through rmtp, and allow users to access the recorded files through http?
    What I am trying to do, is to record a user's microphone's input and save it to the server. Afterwards, I would like other users to be able to access the recorded files and mainuplating the audio data, by computeSpectrum(), to do some visualization of the audio. As I know computeSpectrum() cannot work on streaming files, so I think I need to access the recorded files using http instead of rmtp. Is that true?
    How can I redirect the http request to the files I was recorded into my applications/appName folder? Or I need to somehow moved the recorded files to the /webroot folder?
    Thanks!

    I probably have asked a stupid question.
    My recorded streams are still saved in the applications/appName/streams folder.
    And I redirect the www.mydomain.com/streams to point to the applications/appName/streams folder.
    And the rmtp recorded streams are abled to connect through http now.

  • Displaying results from a database query using servlets

    I have this HTML form where users can search a MS Access database by entering a combination of EmployeeID, First name or last name. This form invokes a Java Servlet which searches the database and displays the results as an HTML page. I am giving the user the choice of displaying 3, 5 or 10 results per page. I want to know how to do that using servlets. If a particular search results in 20 results, the results should be displayed in sets of 3, 5 or 10 depending on the user's choice. If the user makes a choice of 5 results per page then 4 pages should be displayed with a "next" and "previous" button on each page. I want to know how this can be done.

    Arun,
    I'm not sure how to do this using JSP as I have not worked on JSP.
    But I can give you a hint on how to do this within normal java class as I've used this in my current project.
    In your core class/bean that generates the entire resultset, you need to run a loop that will scan through the desired number of records in the resultset.
    To do this, you have to have skip and max parameter in your URL.
    Somthing like http://server.com/myservlet?skip=0&max=10 to display first 10 records, http://server.com/myservlet?skip=10&max=10 to display next 10 records. The <next>parameter would be fed in by the user by a simple form in your web-page. If you need to hold this <max-num-of-recs-per-page> param, you can store it in a cookie (since this is nothing crucial piece of info, don't need to use session obj etc...cookie will do) and get the value each time you display the resultset.
    So, essentially, suppose you are at the first page and you wish to show 10 recs at a time. The link for "Next" button would be http://server.com/myservlet?skip=10&max=10
    when at the second page, you'll have
    "priv" button as http://server.com/myservlet?skip=0&max=10 and
    "next" button as http://server.com/myservlet?skip=20&max=10 and so on...
    hope this makes sense..
    Shantanu

  • UNABLE TO ACCESS SECURED EJB USING IIOP FROM JSP

    Following codes does not work with IIOP when called from jsp returns an
    com.sap.engine.services.iiop.CORBA.CORBAObject:com.sap.engine.services.iiop.server.portable.Delegate_1_1@8312b1 step2 RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: User Guest does not have access to method create(). at
    Following codes does not work with IIOP when called from a fat client returns an
    org.omg.CORBA.UNKNOWN:   vmcid: 0x0  minor code: 0 completed: Maybe
            at com.sun.corba.se.internal.core.UEInfoServiceContext.<init>(UEInfoServ
    iceContext.java:33)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
            at com.sun.corba.se.internal.core.ServiceContextData.makeServiceContext(
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.cosnaming.CNCtxFactory");
    p.put(Context.PROVIDER_URL, "iiop://hostname:50007");
    p.put(Context.SECURITY_PRINCIPAL, "User");
    p.put(Context.SECURITY_CREDENTIALS, "pass");
    I have add java option to add IIOP filer
    -Dorg.omg.PortableInterceptor.ORBInitializerClass.com.sap.engine.services.iiop.csiv2.interceptors.SecurityInitializer
    Solution Required: Could you please detail me what steps in need to perform in order for me to access secure ejb using iiop protocol.
    FYI -- How ever ejb security works with P4 protocol, If required i can send you the test case ear.
    Thanks
    Vijay
    Following are the server side logs
    java.rmi.RemoteException: com.sap.engine.services.ejb.exceptions.BaseRemoteException: User Guest does not have access to method create().
         at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:91)
         at test._TestEJBHome_Stub.create(_TestEJBHome_Stub.java:214)
         at jsp_testIIOP1199698887113._jspService(jsp_testIIOP1199698887113.java:33)
         at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:608)
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:505)
         at com.sap.engine.services.security.resource.ResourceContextImpl.checkPermission(ResourceContextImpl.java:45)
         at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:89)
         ... 20 more
    ; nested exception is:
         java.lang.SecurityException: com.sap.engine.services.security.exceptions.BaseSecurityException: Caller not authorized.
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:608)
         at com.sap.engine.services.security.resource.ResourceHandleImpl.checkPermission(ResourceHandleImpl.java:505)
         at com.sap.engine.services.security.resource.ResourceContextImpl.checkPermission(ResourceContextImpl.java:45)
         at test.TestEJBHomeImpl0.create(TestEJBHomeImpl0.java:89)
         at test._TestEJBHome_Stub.create(_TestEJBHome_Stub.java:214)
         at jsp_testIIOP1199698887113._jspService(jsp_testIIOP1199698887113.java:33)
         at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

    That's the code that you need to execute but you should
    probably encapsulate that code in Custom Action.
    Orion has a EJB Tag Library that is free to distribute that
    does all that stuff you just set some attributes.
    Go to their site and look at their Tag Libraries.
    Also look for other Tag Libraries Freely Available for EJB Access.

  • Exception while accessing com port from servlet

    I am trying to access communication port from a Servlet using java communications api's.
    But Following exception was thrown
    Caught java.lang.NullPointerException:name can't be null while loading driver com.sun.comm.Win32Driver
    The SecurityManager do not allow that opeartion.
    java.security AccessControlException:access denied (java.io.FilePermission c:\j2sdk1.4.1\jre\lib\javax.comm.properties delete)
    at java.security.AccessControlContext.java:270) at java.security.AccessController.checkPermission(SecurityManager.java)
    at java.lang.SecurityManager.checkDelete()
    at java.comm.CommPortIdentifier.getPortIdentifiers(CommportIdentifier.java)
    Please help me.Tell me what to do.how to successfully access a communication port from a Servlet.

    Hi there. I am also facing the problem accessing com port via servlet. if u have the solution, kindly forward to me at [email protected]
    many thanks

  • How to access Revenue records

    <b>[This thread was migrated from the On Demand Developer Forum in the old Siebel Community] </b>
    algocode
    New Contributor
    I try connecting to Revenue records with web services using the same user
    ID with which I'm able to create Service Revenue Details information from
    the CRM OnDeman user interface but instead, I get an error message saying
    "Access denied.(SBL-DAT-00553)";(SBL-EAI-04376).
    Why can't the web service read the revenue records that I am able to
    create or update manually from the CRM OnDemand portal, with the same ID?
    Product: General: IT Organizations and Processes
    10-27-2006 11:25 AM
    Re: how to access Revenue records
    algocode
    New Contributor
    Inside a class extending System.Web.UI.Page, I use the
    secure.crmondemand.com/OnDemand/user/account.wsdl?WSDLOBJ=account web
    service to
    1. Create a list of accounts and specify the fields returned by the
    result set;
    2. Create an AccountWS_AccountQueryPage_Input object;
    3. Retrieve an AccountWS_AccountQueryPage_Output object;
    These are the three methods involved:
    protected void Page_Load(object sender, System.EventArgs e)
    Account1[] objListOfAccount;
    //Initialize the ListOfAccount Arrays and Sub-Arrays
    objListOfAccount = createListOfAccount("";
    //Specify the Account Search Criteria
    objListOfAccount[0].AccountName = "LIKE '" + data["Account"] + "*'";
    //Tell OnDemand What Account fileds should be returned in the result set
    objListOfAccount[0].AccountId = "";
    objListOfAccount[0].Location = "";
    //Tell OnDemand What fields to return on the Opportunity Child
    objListOfAccount[0].ListOfOpportunity[0].OpportunityId = "";
    objListOfAccount[0].ListOfOpportunity[0].OpportunityName = "";
    objListOfAccount[0].ListOfOpportunity[0].CurrencyCode = "";
    //Tell OnDemand What fields to return on the Opportunity Service Child
    objListOfAccount[0].ListOfRevenue[0].RevenueId = "";
    objListOfAccount[0].ListOfRevenue[0].OpportunityName = "";
    objListOfAccount[0].ListOfRevenue[0].NumberOfPeriods = "";
    objListOfAccount[0].ListOfRevenue[0].Frequency = "";
    objListOfAccount[0].ListOfRevenue[0].StartCloseDate = "";
    //Call the Account Query
    AccountWS_AccountQueryPage_Input objAccQryParam =
    new
    AccountWS_AccountQueryPage_Input();
    objAccQryParam.ListOfAccount = objListOfAccount;
    objAccQryParam.PageSize = "90";
    AccountWS_AccountQueryPage_Output objQryOutput =
    RetrieveQueryPageOutput(objAccQryParam, session);
    public Account1[] createListOfAccount(string pstrAccountDimensions)
    int intAccountCount = 1;
    int intOpportunityCount = 20;
    int intRevenueCount = 10;
    try
    Account1[] rtnListOfAccount = new Account1[intAccountCount];
    for (int intAccIdx = 0; intAccIdx < intAccountCount; intAccIdx++)
    rtnListOfAccount[intAccIdx] = new Account1();
    rtnListOfAccount[intAccIdx].ListOfOpportunity =
    new
    Opportunity[intOpportunityCount];
    rtnListOfAccount[intAccIdx].ListOfRevenue =
    new Revenue[intRevenueCount];
    for (int intOppIdx = 0; intOppIdx < intOpportunityCount;
    intOppIdx++)
    rtnListOfAccount[intAccIdx].ListOfOpportunity[intOppIdx] =
    new Opportunity();
    for (int intRevIdx = 0; intRevIdx < intRevenueCount; intRevIdx++)
    rtnListOfAccount[intAccIdx].ListOfRevenue[intRevIdx] =
    new Revenue();
    return rtnListOfAccount;
    catch (Exception objExcep)
    throw objExcep;
    public AccountWS_AccountQueryPage_Output RetrieveQueryPageOutput(
    AccountWS_AccountQueryPage_Input qpinput,
    Session session)
    AccountWS_AccountQueryPage_Output qpoutput = null;
    // instantiate the proxy service
    Account accountProxy = new Account();
    try
    // set up the target URL & set the session cookie
    accountProxy.Url = session.GetURL();
    accountProxy.CookieContainer = session.GetCookieContainer();
    qpoutput = accountProxy.AccountQueryPage(qpinput);
    catch (Exception e)
    Response.Write("<br/><br/>" + e.InnerException);
    Response.Write("<br/><br/>" + e.Message);
    Response.Write("<br/><br/>" + e.StackTrace);
    return qpoutput;
    10-27-2006 02:31 PM
    Re: how to access Revenue records
    algocode
    New Contributor
    I found another way to access Revenue records. Instead of accessing the
    ListOfRevenue field of the Account web service, I access the ListOfProduct
    field of the Opportunity web service. I also instantiate Opportunity2
    objects so that the code to get a list of opportunities and products
    (containing revenue fields) becomes
    Opportunity2[] rtnListOfOpportunity = new
    Opportunity2[intOpportunityCount];
    try
    for (int intOppIdx = 0; intOppIdx < intOpportunityCount;
    intOppIdx++)
    rtnListOfOpportunity[intOppIdx] = new Opportunity2();
    rtnListOfOpportunity[intOppIdx].ListOfProduct =
    new Product[intProductCount];
    for (int intProdIdx = 0; intProdIdx < intProductCount;
    intProdIdx++)
    rtnListOfOpportunity[intOppIdx].ListOfProduct[intProdIdx] =
    new Product();
    return rtnListOfOpportunity;
    10-28-2006 11:17 AM
    Re: how to access Revenue records
    Echo
    Valued Contributor
    Weird. I'm not a big C# programmer but the code looks right. I'm curious -
    could you post some soap loads of the request. I'm wondering if there's
    something weird going on with the proxy.
    10-31-2006 12:00 AM

    I Assume the following is your sample data
    Table Name: Tab1
    RegID CustID Registration_Start      Registration_End
    1      1      01/04/2005           07/04/2005
    2      2      01/03/2005           29/05/2005
    3      1      21/03/2005           29/03/2005
    4      1      01/03/2005           21/03/2005
    Note : For the Regid "4" I have changed the Registration_End to 21/03/2005. It was earlier 21/04/2005.
    Coming to the query, you need to generate the list of regid that have gaps.
    Try the following query:
    SELECT c.*
    FROM tab1 c
    WHERE c.reg_id NOT IN (
    SELECT a.reg_id
    FROM tab1 a, tab1 b
    WHERE a.cust_id = b.cust_id
    AND a.registration_end = b.registration_start
    Note: I am sorry I didn't have access to the data base to execute my query. Correct me if I am wrong.
    Regards,
    Somu

  • Unable to access form parameter in servlet

    What could be the possible reasons, If a server side program say a servlet, cannot access the request parameters.
    I mean, i have a form and it uses get method. Now on submitting the form, I can see the query string in url but unable to access the same in servlet.
    thank you all
    Ravi

    The most obvious reason might be that the servlet's
    programmer wrote crappy code.
    Show the code where you try to read the parameters,
    please.Code is simple. To retrieve the form parameter I used the same
    request.getParameter("paramname")
    And in the form method used is get. After submission of form, I can see the form parameter appended to url
    something like this:
    http://localhost/servlets/Test?paramname=somevalue
    But for somereason in servlet i.e at request.getParameter("paramname"), is hanging here.
    I checked the paramname, no spelling mistakes as well :)
    But i am not able to find out the reason why I am not able to get the paramname in servlet.
    thanks
    Ravi

  • Locking database fields using Servlet

    Hi,
    I am developing a servlet application which is used to access and/or modifying a database on a server. I am now asked for locking fields if a user is accessing the information while others have already loaded the same information page preventing it from changing the same fields that an other user is currently viewing.
    The problem is that my server, running the servlet, is the only one to access the DB (using JDBC) and the connection is always done with the same username/pwd. This connection is done for a short period of time, that is, the time to create the HTML page.
    Is there a way to keep the servlet knowing who is connected to it? With that feature, I could ask for username and pwd for each user and then locking tables on the DB for them.
    I'm I clear enough? I don't feel so... ;)
    Thanks in advance for any hints!
    Snoozer

    Did you try to use:
    request.getRemoteUser()

  • Displaying a set of records using jstl

    hi i am new to jstl.my requirement is i want to display a set of records from my database using jstl.for eg i want to display 50 records per page and i want to navigate to other records using next and prevoius buttons and i need to put view and edit buttons in that page.can anybody give me a solution for this.urgent

    You may try the paging taglib ...
    http://www.servletsuite.com/servlets/pagertag.htm

  • Problem accessing HTML pages using Tomcat 4

    I am very new to programming. I have created an html file (ThreeParamsForm.html) and placed it in development directoy. I am unsure of how to access that file. When i am typing http://localhost/ThreeParamsForm.html it is giving me HTTP Status 404 error. I have tried using servlets in similar way it is working fine. Please help.....

    did you include the port number if other than 80 ?
    i.e. http:\\localhost:8080\whatever

  • When to use jsp,and when to use servlet?

    I think that jsp and servlet can realize the same functions, because when run a jsp, it is transferred to a servlet program, so when to use jsp and when to use servlet?
    I am now developing the input interface for a website, I just use jsp and javabean to connect to weblogic and database, and I didn't use servlet, Is there any unseemliness?
    Thank you!

    IMHO I use servlets to control the flow between my jsp's based on a number of factors in a webapp. For instance, user authorization. If a user has the authorization to conduct various administrative functions on an application (like change user rights, reset passwords etc) they will have access to specific buttons or links on some screens that others will not. I use servlets to establish what access rights a user has and direct them to the appropriate pages. I also use servlets to test data validity on form input screens. I know that I can also do this with JavaScript but that can be disabled by the client and in order to prevent that I also double check the form input from a servlet. All my jsp's do is display the results of a business process (which is held in a JavaBean or EJB) and the servlets act as the controllers for the application, connecting to multiple databases, verifying application state, flow control etc. I try to keep the jsp as simple as possible as some of them are maintained by html developers who lack the necessary experience to write java code. I hope this helps.

  • PageNotFound when using servlets as clients for EJB

    Can anyone help me? I have a container managed EJB. I'm using servlets as my client. I placed my EJB's in a jar file and my servlets and html pages in a WAR file. I deployed them using J2EE's deploytool. I can access my html files but not my servlet files. It always says file not found or a 405 error (resource not allowed) I access my servlet this way...
    http://localhost:8000/ReservationContextRoot/ReservationAlias
    my web.xml file looks like the following:
    <?xml version="1.0" encoding="Cp1252"?>
    <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN' 'http://java.sun.com/j2ee/dtds/web-app_2.2.dtd'>
    <web-app>
    <display-name>ReservationWAR</display-name>
    <description>no description</description>
    <servlet> <servlet-name>ReservationServlet</servlet-name>
    <display-name>ReservationServlet</display-name>
    <description>no description</description>
    <servlet-class>ReservationServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ReservationServlet</servlet-name>
    <url-pattern>ReservationAlias</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>30</session-timeout>
    </session-config>
    <resource-ref>
    <description>no description</description>
    <res-ref-name>jdbc/ReservationDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <ejb-ref> <description>no description</description>
    <ejb-ref-name>ejb/Reservation</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <home>ReservationHome</home>
    <remote>Reservation</remote>
    </ejb-ref>
    </web-app>

    Are you sure your servlet class itself can run without problem? Try debug in the these steps:
    1. Change your servlet to simply output some HTML text, so you can be sure tomcat can get to your servlet. If this is OK, it means the servlet itself has problem, probably the EJB stuff.
    2. Make sure the EJB container is running.
    3. Make your servlet a standalone client (not a servlet) and see if it can run. Pay attention to how you do JNDI lookup of the EJB.
    Yi

Maybe you are looking for

  • How to show GL Account Balance amount in Ledger Report.

    Hi, We need to show General Ledger balance based transaction wise how we can show GL Account Balance where it will store which table and which filed.here below query is there here only I need to add balance after Total please guide me. select T0.tran

  • Transport - Business services and Party components

    Hi Folks ... My SLD has Business systems with different names for each of my environment . e.g. - ECC_DEV -> ECC_QAS ->ECC_PRD and the transport targets takes care of the name changes when the objects are transported. How can I use the same concept f

  • Max Hard Drive size for Ultra 10s

    Hi, I'm kinda new to sun and I have a ultra 10s with a 9 Gig factory installed HD. I was wondering what the maximum sized IDE hard drive that can be installed. I would like to mirror the system as well. I've seen another post about this but the max s

  • Error installing Photoshop Elements 13 on Mac

    I have downloaded PhotoshopElements_13_WWEFDJ.dmg, got a warning message saying "invalid checksum"    I am using a Mac running OSX ver. 10.9.3.   Any fix?

  • Can you use a Windows-only printer over a print server?

    I recently found a large format printer from Ricoh that has great reviews and prints postscript with laser speed/economy with some new inkjet technology only they have - perfect for a home design office and a LOT cheaper than a typical tabloid laser.