Servlet JDBC

Can anyone please help me with pointing to the right direction on webapplications.
I have a table in the database that returns 50K rows when running a query. I have been reading through some books and forums, SDN including that a correct way to access the database is through the Business tier EJB session beans and JPA and access these objects from Servlets. I understand that and I have an example that works using paging so I do not need to send all 50K records at once. My question is, the resultset retrieves entity objects and I have to create data transfer objects for each one of them to send to the GWT client? Doesn't it mean I have twice as much objects in the memory at a time to compare with accessing database through JDBC from Servlets directly? In the later case I wouldn't have any entity objects and occupy less memory? Is it completely wrong idea?
Thanks

mambo_jumbo wrote:
Without their superpowers some of them are still not serializable for GWT.
Never mind,
Thanks for answer.I don't understand what the problem is here.
Dod you have a problem with making them Serializable? They have to be Serializable if you want to make them arguments to remote methods anyway.

Similar Messages

  • Servlets/JDBC vs. servlets/EJB performance comparison/benchmark

    I have a PHB who believes that EJB has no ___performance___ benefit
    against straightforward servlets/JSP/JDBC. Personally, I believe that
    using EJB is more scalable instead of using servlets/JDBC with
    connection pooling.
    However, I am at a lost on how to prove it. There is all the theory, but
    I would appreciate it if anyone has benchmarks or comparison of
    servlets/JSP/JDBC and servlets/JSP/EJB performance, assuming that they
    were tasked to do the same thing ( e.g. performance the same SQL
    statement, on the same set of tables, etc. ).
    Or some guide on how to setup such a benchmark and prove it internally.
    In other words, the PHB needs numbers, showing performance and
    scalability. In particular, I would like this to be in WLS 6.0.
    Any help appreciated.

    First off, whether you use servlets + JDBC or servlets + EJB, you'll
    most likely spend much of your time in the database.
    I would strongly suggest that you avoid the servlets + JDBC
    architecture. If you want to do straight JDBC code, then it's
    preferable to use a stateless session EJB between the presentation layer
    and the persistence layer.
    So, you should definitely consider an architecture where you have:
    servlets/jsp --> stateless session ejb --> JDBC code
    Your servlet / jsp layer handles presentation.
    The stateless session EJB layer abstracts the persistence layer and
    handles transaction demarcation.
    Modularity is important here. There's no reason that your presentation
    layer should be concerned with your persistence logic. Your application
    might be re-used or later enhanced with an Entity EJB, or JCA Connector,
    or a JMS queue providing the persistence layer.
    Also, you will usually have web or graphic designers who are modifying
    the web pages. Generally, they should not be exposed to transactions
    and jdbc code.
    We optimize the RMI calls so they are just local method calls. The
    stateless session ejb instances are pooled. You won't see much if any
    performance overhead.
    -- Rob
    jms wrote:
    >
    I have a PHB who believes that EJB has no ___performance___ benefit
    against straightforward servlets/JSP/JDBC. Personally, I believe that
    using EJB is more scalable instead of using servlets/JDBC with
    connection pooling.
    However, I am at a lost on how to prove it. There is all the theory, but
    I would appreciate it if anyone has benchmarks or comparison of
    servlets/JSP/JDBC and servlets/JSP/EJB performance, assuming that they
    were tasked to do the same thing ( e.g. performance the same SQL
    statement, on the same set of tables, etc. ).
    Or some guide on how to setup such a benchmark and prove it internally.
    In other words, the PHB needs numbers, showing performance and
    scalability. In particular, I would like this to be in WLS 6.0.
    Any help appreciated.--
    Coming Soon: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnweblogic.com

  • Ias support for EJB, JSP/servlets,JDBC, connection pooling, XML, SOAP, load balancing etc

    Please let me know where I can find more information regarding iPlanet usage/deployment/configuring/tuning etc for support of technologies - like EJB, JSP/servlets, JDBC, connection pooling, XML, load balancing, JDBC & Transactions
    (I have already read the 'Getting Started with the iPlanet Application Server' part five and six - http://developer.iplanet.com/appserver/testdrive/partfive.jsp and partsix.jsp)(I am using the ias testdrive version).

    Hi,
    It's difficult to explain unless the J2EE architecture is understood. Also, explaining things like load balancing, Transactions, tuning, are bit vague and could blow the disk space of this site.
    To get started, the best way is to test the sample applications and the best part is you don't require internet connection to follow each steps. Install iWS and iAS, open browser, type in http://hostname:port/ias-samples/index.html. You can find links to the sample applications bundled. Please follow the steps given on deploying the application. This will enable you to a higher level.
    Regards
    Ganesh .R
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Java servlets - JDBC

    hi,
    I have a problem... i would like to fetch some strings from the database using JDBC and create a tree structure using java servlets to be displayed on a browser using html.
    Currently i have tried using a hashtable as well as defaultmutabletreenode, both of which grew complicated and did not give the desired results.
    Pls help...

    I tried using both a DefaultMutableTreeNode
    containing all the other nodes as child nodes and a
    hashtable with a series of internal hashtables -- and
    passed it to the servlet displaying the html
    l content.
    Is there a better/simpler data structure to use in
    this case other than a Hashtable and a
    DefaultMutableTreeNode?How should we know? You're asking what is better to solve your problem, without saying what your problem is. (Hint: "I can't do this" or "It doesn't work" are not useful problem descriptions.)
    If I were doing this, and if I had to build a tree structure in memory before producing HTML from it, I would use DefaultMutableTreeNode. But then I don't know anything about your problem.

  • Servlets & JDBC

    Hi
    Could someone tell me how to delete or ammend a specific field in a database through a servlet. I have written a servlet that writes to a database but I need it to ammend or delete a already existing field.
    Any help would be appreciated.
    By the way I am using jswdk-101 server
    Regards
    Mark

    Hi
    I cant for the life of me get it to ammend to the database although I did manage to get it to delete thanks to the code leukbr gave me. Its not compiling at all for some reason. Although it did compile with leukbr code but it didnt do anything.
    This is the error I am getting now.
    C:\jswdk-1.0.1\examples\WEB-INF\servlets>javac *.java
    ad3.java:85: DataAmmend(int,java.lang.String,java.lang.String,java.lang.String)
    in ad3 cannot be applied to (java.lang.String,java.lang.String,java.lang.String,
    java.lang.String)
    out.println (DataAmmend(ad_id, ad_path, email, categ
    ory));
    ^
    1 error
    Below is the code for ammending.
    import java.io.*;
    import java.util.Date;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    public class ad3 extends HttpServlet{
         private Connection connection;
         private Statement statement;
         private ResultSet resultSet;
         private ResultSetMetaData rsmd;
         private String SQL;
         private String str_HTML_Result;
         public void init() throws ServletException
              String url = "jdbc:odbc:addetails";          
              String username = "test";
              String password = "test";
              // Load the driver to allow connection to the database
              try {
                   Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
                   connection = DriverManager.getConnection(url, username, password );
              catch ( ClassNotFoundException cnfex ) {
                   System.out.println("Time stamp [JDBC Driver]:" + new Date() +
                             "Failed to load JDBC/ODBC driver." );
              System.out.println(
                             "Time stamp [JDBC Driver]:" + new Date() +
                   cnfex.toString());
              catch ( SQLException sqlex ) {
                   System.out.println(
                             "Time stamp [Connection Problem]:" + new Date() +
                             "Unable to connect" );
                   System.out.println(
                             "Time stamp [JDBC Driver]:" + new Date() +
                             sqlex.toString());
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              String ad_id = request.getParameter("ADID");
              String ad_path = request.getParameter("ADPATH");
              String shown = request.getParameter("SHOWN");
              String clicked = request.getParameter("CLICKED");
              String ratio = request.getParameter("RATIO");
              String email = request.getParameter("EMAIL");
              String category = request.getParameter("CATEGORY");
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html>");
              out.println("<head>");
              out.println("<title>Ad Manager Ad Removal Section</title>");
    out.println("</head>");
              out.println("<body bgcolor=\"#999999\" text=\"#000000\">");
    out.println("<div align=\"center\">");
              out.println("<font face=\"Arial, Helvetica, sans-serif\" size=\"5\" color=\"#DDDD00\">");
              out.println("<b>Banner Manager Ad Removal Section</b></font></div>");
              out.println("<br>");
              out.println("<hr>");
              out.println("<table border=" + "\"" + "0" + "\"" +" width=" + "\"" + "100%" + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
         if((ad_id!=null) && (ad_path!=null) && (email!=null) && (category!=null)) {//**Is this rignt??**
                                                           //**Is this rignt??**
                   out.println (DataAmmend(ad_id, ad_path, email, category));     //**Is this rignt??**
              }                                             //**Is this rignt??**
              out.println(getDataTable());
    /*============================================================================*/
    // Main Page HTML
    /*============================================================================*/
              out.println("</table>");
              out.println("<br>");
              out.println("<hr>");
              out.println("<br>");
         out.println(new Date());
              out.println("<form ACTION='http://localhost:8080/examples/servlet/ad3' METHOD = GET>");
              out.println("<center><B><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"> Ad ID </B>");
              out.println("<input type=text name ='ADID'><br>");
              out.println("<B> Email Address </B>");
              out.println("<input type=text name ='email'>");
              out.println("<B> Category </B>");
              out.println("<input type=text name ='category'>");
              out.println("<B> Ad Path </B>");
              out.println("<input type=text name ='ad_path'><p>");
              out.println("<input type=submit value = 'Submit'></p>");
              out.println("</form>");
              out.println("</Font>");
              out.println("<br><br>");
              out.println("<center><a href = http://localhost:8080/examples/servlet/ad> <b><font face=\"Arial, Helvetica, sans-serif\" size=\"3\">Click here to add a new banner to the system</b></a><br>");
              out.println("</center></body>");
    /*============================================================================*/
    // Get Ad Details List
    /*============================================================================*/
    private String getDataTable()
         String str_HTML="";
         try{
    SQL= "SELECT ADDETAILS.ADID, ADDETAILS.ADPATH, ADDETAILS.SHOWN, ADDETAILS.CLICKED, ADDETAILS.RATIO, ADDETAILS.EMAIL, ADDETAILS.CATEGORY ";
              SQL= SQL + "FROM ADDETAILS ";
              statement = connection.createStatement();
              resultSet = statement.executeQuery( SQL );
              str_HTML = processResultSet( resultSet );
    catch ( SQLException sqlex ) {
    System.out.println(
                   "Time stamp [SQL Problem]:" + new Date() +
                   sqlex.toString());
    return str_HTML;
    /*============================================================================*/
    // Get Ad Details List
    /*============================================================================*/
    private String getTable()
         String str_HTML="";
         try
    SQL= "SELECT ADDETAILS.ADID, ADDETAILS.ADPATH, ADDETAILS.SHOWN, ADDETAILS.CLICKED, ADDETAILS.RATIO, ADDETAILS.EMAIL, ADDETAILS.CATEGORY ";
              SQL= SQL + "FROM ADDETAILS ";
              SQL= SQL + "ADID ADDETAILS.ADID";
              statement = connection.createStatement();
              resultSet = statement.executeQuery( SQL );
              str_HTML = processResultSet( resultSet );
    catch ( SQLException sqlex ) {
    System.out.println(
                   "Time stamp [SQL Problem]:" + new Date() +
                   sqlex.toString());
    return str_HTML;
    /*============================================================================*/
    // Ammending details in database
    /*============================================================================*/
    public int DataAmmend(int A, String adPath, String email, String category) {
         //String str_HTML = "";
    int result;
         int adId      = A;
         String aadPath      = adPath;
         String aemail      = email;
         String acategory = category;
    try {          
    SQL= "UPDATE ADDETAILS SET ADPATH = '" + aadPath + "', EMAIL = '" + aemail + "' CATEGORY = '" + acategory + "' WHERE ADID = " + adId;
    statement = connection.createStatement();          
    result = statement.executeUpdate( SQL );
    catch ( SQLException sqlex ) {          
    System.out.println("Time stamp [SQL Problem]:" + new Date() + sqlex.toString());     
    return result;
    /*============================================================================*/
    // Process Ad Details Listing
    /*============================================================================*/
    private String processResultSet( ResultSet rs ) throws SQLException {
    // position to first record
    boolean moreRecords = resultSet.next();
    // If there are no records, display a message
    if ( ! moreRecords ) {
    return null;
    Vector cols = new Vector();
    Vector rows = new Vector();
    try
         rsmd = rs.getMetaData();
         for (int i = 1; i <= rsmd.getColumnCount(); ++i)
         cols.addElement( rsmd.getColumnName(i));
         // get row data
         do{
              rows.addElement( getNextRow( rs, rsmd ) );
         }while ( rs.next() );
    catch ( SQLException sqlex ) {
         System.out.println("Time stamp [Process Reultset]:" + new Date() +
         " Exception in Process Results" );
         System.out.println("Time stamp [SQL Problem]:" + new Date() +
         sqlex.toString());
         String str_HTML_TABLE="";
         Enumeration enum_Cols = cols.elements();
         Enumeration enum_Rows = rows.elements();
         StringBuffer buf = new StringBuffer();
         buf.append("<tr><td>");
         while (enum_Cols.hasMoreElements())
         buf.append(enum_Cols.nextElement()).append(" ");
         buf.append("</td></tr><tr><td>   </td><tr>");
         while (enum_Rows.hasMoreElements())
         buf.append("<tr><td>" + enum_Rows.nextElement()).append("</td></tr>");
         str_HTML_TABLE = str_HTML_TABLE + buf.toString();
         return str_HTML_TABLE;
    /*============================================================================*/
    // Get each row of the to be processed
    /*============================================================================*/
    private Vector getNextRow( ResultSet rs,ResultSetMetaData rsmd )throws SQLException{
         Vector currentRow = new Vector();
                   for ( int i = 1; i <= rsmd.getColumnCount(); ++i ){
                        currentRow.addElement( rs.getString( i ) );
    return currentRow;
    /*============================================================================*/
    // Close Database Connection
    /*============================================================================*/
    public void destroy(){
         try{
              connection.close();
         catch (Exception e){
              System.out.println("Problem Closing DB");
    }

  • Servlets/JDBC - Connect to database ONCE and not in every servlet - How?

    Hello, I'm using servlets and JDBC.
    In every servlet , i connect to the database and then i close the connection, but this is not ptactical.
    I would like to connect to the database once (at the beginning) when container starts and then close the connection.
    How am i supposed to do that?
    Thanks, in advance!

    Bad idea. Don't do that. The connection will timeout sooner or later (depends on DB used, it's usually around 30 mins) and your application will crash.
    You should always acquire and close the connection (and statement and resultset!) in the shortest possible scope. To improve connecting performance just use connection pooling.
    Create a DAO class which does all the task and just instantiate and assign it as Servlet class variable during Servlet's init() method. For more insights and code samples start here: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].
    To go back to your fundamental question, doing some stuff during startup and shutdown of webapp, you could use the ServletContextListener for this. But again, do NOT do this to get hold of an external resource such as a connection! It's receipt for trouble.

  • Servlet-jdbc problem

    hello all,
    I am writing a simple servlet which will extract data (empno and empname) from a html form and insert in to database.
    everything seems to work fine except it inserts in to the table empno and empname as it is without values.
    if u can think of some reason and specify it would be great.
    thanx once again.
    mahesh
    anyway i have those 2 small programs as below :
    enterinfo.java - for generating entry form
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class EnterInfo extends HttpServlet
         public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
              res.setContentType("text/html");
              PrintWriter out=res.getWriter();
              out.println("<html><body>");
              out.println("<form name=\"insertdata\" method=\"post\" action=\"msgservlet\">");
              out.println("Emp No<input type=text name=empno><br>");
              out.println("Emp Name<input type=text name=empname><br>");
              out.println("<input type=submit value=send>");
              out.println("</form></body></html>");
    msgservlet.java - for extracting data and inserting data in to the table
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class msgservlet extends HttpServlet
         private Connection con;
         private PrintWriter out;
         private Statement stmt;
         public void init(ServletConfig conf) throws ServletException
              super.init(conf);
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              catch(ClassNotFoundException cnfe)     
                   System.err.println("Details:"+cnfe);
                   System.exit(0);
              try
                   conrjc();
                   //con=DriverManager.getConnection("jdbc:odbc:njdbc");
              catch(SQLException sqle){
              System.err.println("Details"+sqle);
         public void conrjc() throws SQLException
              con=DriverManager.getConnection("jdbc:odbc:njdbc");
         public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
              res.setContentType("text/html");
              try{
                   out=res.getWriter();
                   out.println("<html>");
                   out.println("<head>");
                   out.println("<title>Sample JDBC Servlet</title>");
                   out.println("</head>");
                   out.println("<body>");
                   stmt=con.createStatement();
                   int eno=Integer.parseInt(req.getParameter("empno"));
                   String enm=req.getParameter("empname");
                   //String ins="insert into MYEMPLOYEE values('req.getParameter("empno")','req.getParameter("empname")')";
                   stmt.executeUpdate("insert into MYEMPLOYEE values(eno,enm)");
                   out.println("<h1>OK</h1>");
    //               stmt.close();
                   con.commit();
              catch(SQLException se){
              out.println("An SQL Exception was Thrown"+ se);
              catch(IOException se){
              out.println("An IO Exception was Thrown");
              out.println("</body>");
    out.println("</html>");
              out.close();          
              public void destroy(){
              try{
                   con.close();
              catch(SQLException sqle){}

    try using the following statement instead on the previous one...
    stmt.executeUpdate("insert into MYEMPLOYEE values('"+eno+"','"+enm+"')");
    Usually strings are passed as 'string' to be inserted into the database. Make sure you know what data type you are inserting into the database (from database design). However, prepared statement should work as well.
    Hope this helps
    AAJ

  • JSP Servlet JDBC connection

    Below is the code for handling login.
    However I am new to servlets, and I am wondering is the code below correct?
    Can anyone give me some advice if it is not correct?
    package gcd;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.mysql.jdbc.*;
    public class LoginHandler extends HttpServlet
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    //Load the driver
    Class.forName("com.mysql.jdbc.Driver");
    //Get a connection to the database
    java.sql.Connection connection=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/gcdBB_db");
    //Create a statement object
    java.sql.Statement statement = connection.createStatement();
    Enumeration parameters = request.getParameterNames();
    if(parameters.hasMoreElements())
    // Get the user's account number, and password
    String username = req.getParameter("username");
    String password = req.getParameter("password");
    statement.executeUpdate("INSERT INTO users (username,password) VALUES ('"+username+"','"+password+"')");
    // Check the name and password for validity
    if (!allowUser(username, password))
    out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>");
    out.println("<BODY>Your login and password are invalid.<BR>");
    out.println("You may want to <A HREF=\"Login.jsp\">try again</A>");
    out.println("</BODY></HTML>");
    else
    // Valid login. Make a note in the session object.
    HttpSession session = req.getSession();
    session.setAttribute("logon.isDone", account); // just a marker object
    // Try redirecting the client to the page he first tried to access
    try
    String target = (String) session.getAttribute("login.target");
    if (target != null)
    res.sendRedirect(target);
    return;
    catch (Exception ignored) { }
    // Couldn't redirect to the target. Redirect to the site's home page.
    res.sendRedirect("/");
    protected boolean allowUser(String username, String password)
    return true; // trust everyone
    }

    I made the following changes as suggested, to the LoginHandlaer code.
    I also want to ask about the code for ProtectedResources. Do I need to inlude anything in the program. Will I need to include code for the JDBC connection?
    Are the 2 java servlets below correct, as I want JSP-Servlet-JSP operation for login? I can also include the code for Login.jsp if requested?
    PS: I am using Tomcat 3.1 as my server.
    package gcd;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.mysql.jdbc.*;
    public class LoginHandler extends HttpServlet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
                   response.setContentType("text/jsp");
              PrintWriter out = response.getWriter();
              try
                   //Load the driver
                   Class.forName("com.mysql.jdbc.Driver");
                        //Get a connection to the database
                        java.sql.Connection connection=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/gcdBB_db");
                        //Create a statement object
                        java.sql.Statement statement = connection.createStatement();
                        Enumeration parameters = request.getParameterNames();
                        // Get the user's username, and password
                        String username = request.getParameter("username");
                        String password = request.getParameter("password");
                        statement.executeUpdate("INSERT INTO users (username,password) VALUES ('"+username+"','"+password+"')");
                   // Check the username and password for validity
                   if (!allowUser(username, password))
                        out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>");
                        out.println("<BODY>Your login and password are invalid.<BR>");
                        out.println("You may want to <A HREF=\"Login.jsp\">try again</A>");
                        out.println("</BODY></HTML>");
                   else
                        // Valid login. Make a note in the session object.
                        HttpSession session = request.getSession();
                        session.setAttribute("logon.isDone", username); // just a marker object
                        // Try redirecting the client to the page he first tried to access
                        try
                             String target = (String) session.getAttribute("login.target");
                             if (target != null)
                                  response.sendRedirect(target);
                                  return;
                        catch (Exception ignored) { }
                             // Couldn't redirect to the target. Redirect to the site's home page.
                             response.sendRedirect(request.getContextPath() + "http://localhost:8080/jsp/gcdBB");
                   catch (ClassNotFoundException e)
                        out.println("Could not load database driver: " + e.getMessage());
                   catch(SQLException e)
                        out.println("SQLException caught: " + e.getMessage());
         protected boolean allowUser(String username, String password)
              return true; // trust everyone
    package gcd;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.mysql.jdbc.*;
    public class ProtectedResources extends HttpServlet
         public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
              response.setContentType("text/plain");
              PrintWriter out = response.getWriter();
              // Get the session
              HttpSession session = request.getSession();
              // Does the session indicate this user already logged in?
              Object done = session.getAttribute("logon.isDone"); // marker object
              if (done == null)
                   // No logon.isDone means he hasn't logged in.
                   // Save the request URL as the true target and redirect to the login page.
                   session.setAttribute("login.target",
                   HttpUtils.getRequestURL(request).toString());
                   response.sendRedirect(request.getContextPath() + "http://localhost:8080/jsp/gcdBB/Login.jsp");
                   return;
              // If we get here, the user has logged in and can see the bulletin boards
              out.println("The GCD Computing Bulletin Board awaits you!");
    Any help would be greatly appreciated!

  • Document name, servlets, jdbc

    Yes ;)
    Everything works just fine, my servlet now reads binary documents from my database and pushes them over to the client web-browser.
    But... ducument names are all set to the servletname... what an annoyance.
    Ideas, anyone?

    And for parsing: (I haven't tested it but I remember using something like this long time ago)
    Hashtable params = new Hashtable();  //this will contain param/value pairs
    String queryString = request.getQueryString();
    if (queryString == null) {
       //no query String .. do whatever you need to do in that case
    StringTokenizer st = new StringTokenizer(queryString, "/");
    while (st.hasMoreTokens()) {
         String key = st.nextToken();
         String value = null;
         if (st.hasMoreTokens()) {
             value = st.nextToken();
         params.put(key, value);
    String idString = (String)params.get("id"); //id in the sample URL you provided

  • Servlets, JDBC, and Arabic

    when using the Java Servlets to process an HTML Form that have Arabic input .. the Arabic input is not viewable in any proper encoding after INSERTing it to a Access DB using the JdbcOdbc bridge ..
    How can I make sure of the encoding before INSERTing it ? can how can I convert between different encodings ( ISO-8859-6 to WINDOWS-1256, or ANSI to UTF-8, and so on) ???

    Alternatively, ignore what the HttpServletRequest says the encoding is, because it may be relying on what the client browser says. Browsers are notoriously lax and unreliable when it comes to non-ASCII data. Try assuming that the input encoding is actually UTF-8, or something suitable for Arabic. Forget about the database for now and concentrate on making sure that you can actually get Arabic characters into your servlet correctly -- as I said, you will probably have to experiment with various encodings. When you are sure of that, then start on the database end (which I am also dubious about, most databases handle non-ASCII data badly too).

  • Help With Servlet+JDBC Example?

    hi there
    i've made my first jsp page
    that contain two textfields name&description
    and i want that when the user presses the add button
    the information is sent to the servlet and the servlet add the information in the database
    how that can be done in the servlet?
    thank you

    You can extends the httpservlet, then implements the method of the doGet,and you can do what you want to do&#12290;
    it is easy&#65292; u had better find some book to read&#12290;

  • Uploading External Documents (*.doc, *.pdf, *.html) using JSP, Servlets, JDBC

    I would like to upload external documents to an Oracle 8.16 db without using agents or interMedia.
    Documents can range from *.doc, *.pdf, *.html and so forth. Ive been all over OTN and all I keep finding are examples on uploading Audio, Video or Image data - which is fine.. but damn, can we get a couple "Real World" examples in there?
    Im even looking at iWorkplace which is excellent.. but a little out of my league when it comes to uploading external documents. But that's exactly what Id like to do. The documentation on this issue is very scarce - Please help.
    Any help in this matter would be greatly appreciated.
    Many Thanks in Advance.

    Is anyone having problems loading text files using this routine? I can load a file with this, but even though the table contains a CLOB, the file is uploaded as binary and one only sees a series of question marks when looking at the CLOB. So, basically, the file appears to be converted somehow from text to binary. Any thoughts? I'm using 8.1.6.0.0 on Sun Solaris 2.7. character set in the database is UTF8.
    Thanks.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Rick Post:
    Steps you need to follow are:
    1. Create a table to hold the documents
    CREATE TABLE XML_DOCUMENTS (
    DOCNAME VARCHAR2(200) NOT NULL,
    XMLDOC CLOB,
    TIMESTAMP DATE
    2. Create a directory
    CREATE OR REPLACE DIRECTORY bfile_dir AS /private1/LOB/files;
    3. Grant READ privileges on the directory to the appropriate user
    GRANT READ on bfile_dir to SCOTT;
    4. Create a procedure
    CREATE PROCEDURE insertXmlFile( dir VARCHAR2,
    file VARCHAR2,
    name VARCHAR2 := NULL) IS
    theBFile BFILE;
    theCLob CLOB;
    theDocName VARCHAR2(200) := NVL(name,file);
    BEGIN
    -- (1) Insert a new row into xml_documents with an empty CLOB, and
    -- (2) Retrieve the empty CLOB into a variable with RETURNING..INTO
    INSERT INTO xml_documents(docname,xmldoc) VALUES(theDocName,empty_clob())
    RETURNING xmldoc INTO theCLob;
    -- (3) Get a BFile handle to the external file
    theBFile := BFileName(dir,file);
    -- (4) Open the file
    dbms_lob.fileOpen(theBFile);
    -- (5) Copy the contents of the BFile into the empty CLOB
    dbms_lob.loadFromFile(dest_lob => theCLob,
    src_lob => theBFile,
    amount => dbms_lob.getLength(theBFile));
    -- (6) Close the file and commit
    dbms_lob.fileClose(theBFile);
    COMMIT;
    END;
    5. Execute the procedure
    INSERTXMLFILE('bfile_dir', filename, 'description');
    Good Luck!
    <HR></BLOCKQUOTE>
    null

  • Regd JDBC SERVLET

    hi friends,
    Question 1:It's regarding JDBC using PreparedStatement from Servlets. I created a table named st in ORACLE having columns name varchar2(20) and dateofbirth date. From insert.htm, i am accepting, the data for dateofbirth as a string; i.e., <Input type="TEXT"...>.
    Now my question is how to convert this dateofbirth of string into SQL ORACLE data type and then store in DB.
    Processing is taking place in Servlet; i.e., from htm to servlet to ORACLE Db.
    Question 2: How can i store boolean values from servlet into Oracle DB & how to retrieve back.
    Plz help me in this regard....
    thank u...

    You can use java.text.SimpleDateFormat to convert String to Date.
    This problem has nothing to do with Servlets, JDBC, let alone Oracle.

  • Inserting data with more than 255 characters in to MSACCESS through JDBC

    Hi All,
    I have developed a product using servlets,JDBC,HTML.The backend is MS access database.
    I have to provide an option for the user to key in more than 255 characters of data in the textarea & then store it in the access database.But i read that access ODBC driver has a limit of 255 characters.Is this correct.
    I tried changing the Datatype of the field from text to Memo field in MS ACCESS.But when i insert the data using setString method of the PreparedStatement ,it's giving the following SQL exception:SQLException caught:[Microsoft][ODBC Microsoft Access Driver]String data, right truncated (null)
    How do i let an user key in more than 255 characters.Can somebody help me on this please ASAP as this is a very crucial issue which i need to solve by tomorrow.
    Thanks in Advance
    GCR

    hi rashmi,
    HOw bout using CLOB facility to store such large strings?? try it.
    Cheers,
    -Jer

  • Pre mature termination of Java Program (Servlet)

    Hi,
    Any One can help me for the above subject
    i have my application on java servlets/JDBC on linux (red hat 6.2)
    with Oracle 8i 8.1.6 we we fire a application which invloves some big table (10) and millions of row after 30 to 35 minutes my java application dies pre maturly.
    i have 250 MB SGA and java settings in init.ora are as
    java_pool_size = 50M #20971520
    java_max_sessionspace_size = 90000000
    java_soft_sessionspace_limit = 90000000

    You use the java in the DB?
    We makes DB connection thru java class.
    What kind of Class do you use for Insert?
    Class.forName("oracle.jdbc.driver.OracleDriver")
    Do you use PreparedStatemend with addBatch over all Rows or do you set commit after every rows?
    Yes we are using PreparedStatemend and committing after each row.
    Do you get an exception?
    No we do not get any exception.

Maybe you are looking for

  • Cisco ISE FlexAuth with 802.1X PCs and IP Phones as MAB multi-domain Q?

    Cisco ISE FlexAuth with 802.1X PCs and IP Phones as MAB multi-domain Q? Im trying to follow the trustsec 2.1 guide on IP Phones into LowImpact mode. I can get a PC on its own to authenticate via dot1x/tls I can get a Cisco IP Phone on its own to auth

  • Acrobat 8 and 9 slow scrolling in terminal server or RDP

    Adobe, there have been several postings here regarding the painfully slow scrolling introduced in acrobat 8 and 9 when viewing a multi page PDF via terminal services or RDP. It is discussed here in your forums and other internet forums. Have you a so

  • Calculated Hex to Unicode for display in label

    Hi I want to calculate an integer, convert to unicode and display the appropriate character in a label. I can display the correct chinese character if I pass a string literal e.g. "\u4e00" to the setText method. But I dont want to have hardcoded stri

  • Login problem with MI424WR router

    I am trying to login to my router, but am having password trouble.  I used admin for the name and tried password and my serial number and several other things for the password.  I noticed that when I type in the password field, several asterisks are

  • Navigation not displaying horizontally

    I've been trying to tweak every level of the CSS but cannot get the sub nav items to display horizontally on hover. Here is the test page: http://gbetza.mydomain.com/webservice2/test/Basso56/test/Reviews.html Here is the CSS: http://gbetza.mydomain.c