Results 1 to 9 of 9
  1. #1
    jarhead is offline Member
    Join Date
    Oct 2014
    Posts
    2
    Rep Power
    0

    Default advanced jdbc query application

    I am looking into writing an advanced query application for my company, department.

    I work with several application, and third party tools, example: WebSphere, Weblogic, TDS, AD/LDS, SAP, couchbase, unix, linux, mainframe, solaris, etc.... The list goes on and on.

    Anyway, we also have several versions of our own custom built application. Part of our job is going to the client site, and doing custom implementation, configuration, setup, etc...
    Please take in mind that our application is custom built and has it own error messages not always associated with some of the tools it uses.

    When we go on site, sometimes we run into an error that someone on the team may have already experienced, or this may be a new issue.

    We would like to be able to query for that information based on an advanced query, so that we could get the information back fast, and not have to track someone down all the time looking for answers.

    Example. possible jsp page.

    Advanced query fields: Platform/ OS, Application, Version, key word, etc....

    I would like to be able to put this query together so that:
    1. Not all of the fields have to have something in it. It would be smart enough to put the query together so that it would read something like: Select field 1, field 2, If field3 = null {skip to next field}, field 4. I would also like to make it sortable by all fields.


    Is there already something in place for something like this that anyone might know about, or could point me in the right direction.

    jarhead

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,433
    Rep Power
    21

    Default Re: advanced jdbc query application

    Is there a single table you're querying against?
    The brute force way:
    Java Code:
    StringBuilder sb = new StringBuilder("Your base query")
    if (request.getParameter(x) != null) {
        sb.append(" AND X = ?";
        myListOfBindValues.add(request.getParameter(x));
    }
    etc.
    then bind them by iterating over the list.
    That will return all the fields.

    If you want to be a bit neater and reduce the number of fields then preprocess the request and produce a Map<String, Object> where the String is the column name, then you can construct the query using that.

    The important bit is going to be the table structure you are querying and what exactly you expect the supplied filter to look like.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,020
    Rep Power
    8

    Default Re: advanced jdbc query application

    That will break if the base query has no initial "where" clause though ;)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,433
    Rep Power
    21

    Default Re: advanced jdbc query application

    I never said it was a copy/paste job.
    :)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,020
    Rep Power
    8

    Default Re: advanced jdbc query application

    he he :)

    "Your solution doesn't work!"
    "I never said it was correct"
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    847
    Rep Power
    7

    Default Re: advanced jdbc query application

    in order to make it work ..
    take request.getParameterNames() list as a key and getParameter("corresponding name") as a value in map or some collections.then build the query.
    i think it should work.
    Ramya:cool:

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,433
    Rep Power
    21

    Default Re: advanced jdbc query application

    Quote Originally Posted by gimbal2 View Post
    he he :)

    "Your solution doesn't work!"
    "I never said it was correct"
    Admittedly I usually put a disclaimer on, but forgot this time.

    Put another way..."oh shut up!"
    :P
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    jarhead is offline Member
    Join Date
    Oct 2014
    Posts
    2
    Rep Power
    0

    Default Re: advanced jdbc query application

    Hey everyone. Thanks for all of the replies. I really appreciate it. I took some of your suggestions, and googled parts of them.

    I found this, even though it is from 2008. Does this look like a viable solution?
    Rico Live Grid | Java Code Samples

    Or should I take a standard CRUD application and add in the needed features as I go?
    I have played around with JSF, Struts 2, etc... There are so many choices now of days.

    Take in mind that, we would like to be able to access this application from any location. I would have to make it where we would login to it. Security, etc...
    Once logged in, they would be able to add information to db, if they have a specific role. We of course don't want anyone in that is new, that can delete, or update entries.

    There are just so many choices to choose from now of days. Any suggestions are welcome.

    Jarhead

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,433
    Rep Power
    21

    Default Re: advanced jdbc query application

    This has ceased to be about a query and is now all about architecture, by the look of it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. how to transfer postgrsql query into jdbc
    By poliocertes in forum JDBC
    Replies: 2
    Last Post: 12-17-2013, 11:01 AM
  2. Replies: 0
    Last Post: 12-14-2010, 06:56 AM
  3. JDBC Query
    By KumbhaniMehul in forum Java Servlet
    Replies: 1
    Last Post: 04-07-2010, 03:41 AM
  4. Mysql/JDBC update query problem
    By thelinuxguy in forum Advanced Java
    Replies: 3
    Last Post: 02-11-2009, 10:56 PM
  5. ms access jdbc query problem
    By Fleur in forum New To Java
    Replies: 2
    Last Post: 04-30-2008, 06:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •