SQL Satment with JSP

Hey,
I tried to make basic SQL statment (included in a string), but one of my field have a name finishing with a + like "Group-Id+"
This is a sample of my code :
String strSQL="SELECT HelpDeskCases.Group-ID+ FROM HelpDeskCases"
I tried thanks to different ways as :
strSQL="SELECT HelpDeskCases.[Group-ID+] FROM HelpDeskCases"
strSQL="SELECT HelpDeskCases.Group" + "-" +"ID" + "+" +" FROM HelpDeskCases"
It's always crash with an error message as column name MYCOLUNM not found
Or From not found,...
In the same time I can't use system.out.println
IS someone able to help me (I'm become crazy)?

try including the column name in double quotes..
ie.
String strSQL="SELECT HelpDeskCases.\"Group-ID+\" FROM
HelpDeskCases"

Similar Messages

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • SQL problem with JSP

    In sql statements with JSP. Heres the deal:
    Access database:
    Tablename: EVENT
    FieldName: event_id
    DataType: Number
    I want to compare the event_id to an integer variable called "var" in a WHERE clause in an SQL statement through a JSP.
    String query = "SELECT * FROM EVENT WHERE EVENT.event_id = 'var' ";
    It says "Data type mismatch in criteria expression."
    Any Suggestions? I thought this should be straight forward! am i missing something?

    if i am reading correctly "var" is an int variable correct? If this is the case then the following will work;
    String query = "SELECT * FROM EVENT WHERE EVENT.event_id = " + Interger.toString(var) ;
    Hope that helps ( and i hope i read your problem correctly)

  • Best way to create, modify, XML with JSP ?  HELP

    Hi friends,
    As i am new to XML,
    I know there are two APIs used for XML processing, i want to know as a begineer level, which API
    is easy and good to implement XML with JSP.
    1) SAX
    2) DOM
    i want to make a log file in XML, so on web page it will be displayed on HTML form through XSL.
    Since there is good tutorial on http://www.w3schools.com/dom
    but i think its HTML dom
    I want XML procession through JAVA CODE , what should i use ? and give some good tutorials on XML DOM
    that is used with JAVA / JSP.
    HELP.
    Edited by: Ghanshyam on Sep 19, 2007 3:24 PM

    Well what i think is you gonna checkout with your requirements before implementing any of the popular XML parsing mechnisms.
    If you are intrested in faster processing @sacrifising a gud amount of your Memory,DOM is the one which you are looking for.
    If you are instrested in Managing your memory and but if you are ok with sacrifising speed SAX is the best solution.it works on what is called a push technology.
    and if you think either way you might have to look towards a pull parser which is StAX (Streaming API for XML Parsing)
    it'd be a gr8 idea if you can go through the below article which explians about each of the parsing mechanisms
    http://www.stylusstudio.com/xml/parser.html#*
    coming back to helpful resources as far java is concern checkout the below link which might be of some help.
    and the main thing is that all of these parser there is a defined specification you might find implementations of different vendors on this.
    eg:Sun Provides one with JDK itself,same as IBM provides one,oracle does the same & so on...
    your first task would be to focus on one such implementation which can cater your requirements.
    DOM:*
    Basic Parsing Objects / Interfaces Involved while DOM parsing:
    http://www.w3.org/TR/DOM-Level-2-Core/java-binding.html
    Breif Overview & few important API details:
    http://www.developerlife.com/domintro/default.htm
    Simple Example:
    http://www.brics.dk/~amoeller/XML/programming/domexample.html
    Others:
    http://www.roseindia.net/xml/dom/
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPDOM.html#wp79994
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/1_read.html
    SAX:*
    http://www.javacommerce.com/displaypage.jsp?name=saxparser1.sql&id=18232
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/index.htm
    http://java.sun.com/developer/Books/xmljava/ch03.pdf
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPSAX.html#wp69937
    http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=6
    StAX:*
    http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP2.html
    http://javaboutique.internet.com/tutorials/stax/
    http://today.java.net/pub/a/today/2006/07/20/introduction-to-stax.html
    Hope this might be of some help :)
    REGARDS,
    RaHuL
    http://weblogs.java.net/blog/spericas/archive/2006/04/sun_stax_parser.html

  • Inserting your own sql-statements in JSP

    How do I use my own sql-statements in JSP combined with the ones
    generated by JDeveloper?
    It seems to me that the following sentences are the ones
    generating the sql for inserting in a database:
    <jbo:DataSource id="ds" appid="MimPKG.MimPKGModule"
    viewobject="BidragView"/>
    <jbo:Row id="newRow" datasource="ds" action="Create">
    <jbo:SetAttribute dataitem="*"/>
    </jbo:Row>
    I would like to have more control and therefore I need to make
    my own sql-statements.
    Is that possible?
    Thanks
    Leise

    You can use ExecuteSQL data tag to do so. It allows you to
    include your own query like insert, update etc.

  • Dynamic Queries with JSP

    I am developing a search page which should first bring the results sorted by some particular field & then the user should have the option of sorting the results by other field names which are provided in a form list.
    For generating dynamic requests, ? is used in place of parameter. But for some reason it is not working with Order by. Other dynamic queries are working fine. Please let me know the right way to handle it.
    And also if someone can advise a good reference book for dynamic SQL statements in accordance with JSP.
    Thanks for your time.

    Never mind my previous solution. Some success was not perfect, therefore not acceptable. I used a scriplet and the problem is solved!
      <!-- Dynamically build the query -->
        <%
          String sql = "select * from issue_list_view";
          String where = null;
          String param = null;
          // Status
          param = (String)pageContext.getAttribute("status");
          if(param != null && param.compareTo("")!=0)
            where = "status='"+param+"'";
          else
            where = "status not in ('Closed','Duplicate')";
          // Assigned To
          param = (String)pageContext.getAttribute("assign");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where = "category='"+param+"'";
          // Category
          param = (String)pageContext.getAttribute("category");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where = "category='"+param+"'";
          // Type
          param = (String)pageContext.getAttribute("type");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where += "issue_type='"+param+"'";
          // Id
          param = (String)pageContext.getAttribute("id");
          if(param != null && param.compareTo("")!=0)
            if(where.length()>0) {where += " and ";}
            where += "issue_id="+param;
          // Add where clause if needed
          if(where != null) { sql += " where " + where; }
        %>
        <!-- Do the query -->
        <sql:query var="issues" sql="<%=sql%>"/>

  • Help a new guys with JSP!

    Hi,
    i'm a new programer with JSP.
    I've created a class files that connect a database.
    But i would like to know how to write text with JSP?
    I would like to write a 'thank you' message after saving a form in a database.
    does its possible to have it in my class files?
    thanks for your help.

    Im not an expert on jsp or java but i will try to give my ideas.. i hope i can help you =)
    /* you could actually forward your servlet to your confirmation file like this : */
              ServletContext sc = getServletContext();
    .// just fill up here the variable msg , u cud write to its value your thank you message or something else like error messages
              RequestDispatcher rd = sc.getRequestDispatcher("/Confirmation.jsp?msg="+msg);          
              rd.forward(req, res);     
    /******* or u cud also throw ur request to the same jsp and display the ***/
    /******* message thru a form tag using javascript like this : ***/
    suppose your main jsp is this:
    <html>
    <head>
    <STYLE TYPE="text/css">
         .noBorder{
              border: white 0px solid;
              background-color: white;
              font-family:Arial;
              font-size:13px;
              font-weight: bold;
              color:green;
              width:300px;
              text-align:center;
    </STYLE>
    </head>
    <%!
    Connection conn;
    PreparedStatement pstmt;
    private doInsert(String name){
    // this is an oracle connection
    String sql = "INSERT INTO TABLENAME(FIELD1) VALUES(?)"
    try{     
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // just fill up the dburl , dnusername and dbpassword
    conn = DriverManager.getConnection(dburl,dbusername,dbpassword);
    pstmt = conn.prepareStatement(sql);
    pstmt.clearParameters(); // clear any previous parameter values
    pstmt.setString(1,name);
    pstmt.close();
    }catch(SQLException se){     
    }catch(Exception e){          
    }finally{
    if(conn!=null){
         try{
         conn.close();
         }catch(SQLException se){}
    %>
    <body>
    <form method=post"" name="msgscr">
    <tr><td colspan="2"><input type="text" name="msg" value="" class="noBorder" disabled/></td></tr>
    </form>
    <%
    if(request.getParamater("submit")!=null){
    // you could also add a return value for doInsert method to check whether the dbase insertion
    // is successful or not if the return value is true then the value for the document.msgscr.msg.value
    // is thank you otherwise u cud put "Unable to process your request" or other message
    doInsert(request.getParameter("name"));
    out.println("<script>document.msgscr.msg.value='Thanks you!!!!';</script>")
    %>
    <!-- this means that the request qill be thrown on this file-->
    <form method="post">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>
    </body>
    </html>     
    /**** or you could also do the confirmation message just by adding an **/
    /**** alert message using javascript like this: **/
    <head>
    <script language="javascript">
    function ValidateCreate(theform){
         if(theform.name.value==""){
         alert("name is required");
         return false;
         }else{
         alert("Thank you!!!!");
    return true;
    </script>
    </head>
    <body>
    <form method="post" onsubmit="return ValidateCreate(this)">
    <tr>
    <td>NAme : </td>
    <td><input type="text" name="name" value=""/></td>
    </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit " value="Submit"></td></tr>
    </form>

  • Help me plz with JSP

    Hi we r making some projects with JSP as front end and SQL as a back end and we want to version our Site but i dont know how to version a web bed application ....cuz we are not using an of activeX controls or any other control..........plz help me

    jsp pages are just flat files as everithing else. You can use common repositories for versioning - like MS SourceSafe, CW-RCS, ...
    I've done some web projects and used CW-RCS, which is free for single user sucessfully. Everithing that you have to do is to specify the development directory of your code. After you finish vith an implementation you just commit to the repository.
    Repository offers you also the comparation between the versions of code and reinstalling the old code in case ...
    Hope it helps,
    B.

  • How to create table with jsp in mysql

    Hi, every one,
    I just want to know how to create a table with jsp in mysql, please.
    Thanks in advance

    I have got the same question. I tried to pass sql "Create table" statement, but the servlet engine (tomcat4) threw an error "could not manipulet statement.execute". It works for normal SQL select statement.
    Anyone got the same problem ? or got a solution for this ? someone told me that PHP can do it, but just want to get it works with JSP.

  • The syntax for accessing MS SQL db from JSP

    Can anybody help me with the syntax for accessing MS SQL db from JSP???
    This is what I do when I use MySQL:
    Class.forName( "org.gjt.mm.mysql.Driver" );
    Connection conn = DriverManager.getConnection(
         "jdbc:mysql:://um" ,
    What do I write when it is MS SQL and where do I install the driver
    BR Soren

    Can anybody help me with the syntax for accessing MS
    SQL db from JSP???
    This is what I do when I use MySQL:
    Class.forName( "org.gjt.mm.mysql.Driver" );
    Connection conn = DriverManager.getConnection(
    "jdbc:mysql:://um" ,
    What do I write when it is MS SQL and where do I
    install the driver
    BR Soren
    One way of doing this is to use ODBC. Here's an example:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:odbc:<odbc name>", "<login>", "<password>");

  • What RAD tool should i use with JSP??

    I would like to know what RAD (opensource) to use to work with JSP and MySQL.
    If anyone could help
    thank you

    If you are using the Sun Java System Enterprise Studio, the Web Application Framework will provide you with all the tools you need to create a JSP/Servlet based web application that scales in performance like no other framework. Coupled with a WYSIWYG HTML editor like Dreamweaver and your RAD app dev is covered.
    For MySQL, there are some really nice GuI clients out there. This is a link to the one I have used:
    http://www.mysql.com/products/
    If you are using the Sun Java Studio, don't forget to add the MySQL jdbc driver so that you can access your DB at development time and use the Sql Model wizards from within the Web Application Framework tools.
    If your app is not concerned with serious scalability, and you are looking to build your app using the latest standards (JSF - Java Server Faces), you can download the Sun Java Studio Creator. It's more of a VB.NET/ASP like development environment with a WYSIWYG HTML form painter. Very slick. You can download here:
    http://developers.sun.com/prodtech/javatools/jscreator/index.jsp
    Here's a primer for Creator:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/primer.html
    The Creator forum is here:
    http://swforum.sun.com/jive/forum.jspa?forumID=123
    To recap, use Web Application Framework if you require the utmost in a mature, stable, and scalable web application. WAF apps can be deployed to any J2EE server.
    If you require a webapp based on the latest standard JSF implementation, and dev productivity is more important than enterprise strength scalability, then Creator is a great choice.
    cheers
    craig

  • Can't update a sql-table with a space

    Hello,
    In a transaktion I'm getting some Values from a SAP-ERP System via JCO.
    I update a sql-table with this values with a sql-query command.
    But sometimes the values I get from SAP-ERP are empty (space) and I'm not able to update the sql-table because of a null-value exception. (The column doesn't allow null-values). It seems that MII thinks null and space are the same.
    I tried to something like this when passing the value to the sql-query parameter but it didn't work:
    stringif( Repeater_Result.Output{/item/SCHGT} == "X", "X", " ")
    stringif( Repeater_Result.Output{/item/SCHGT} == "X", "X", " ")
    this works but I don't want to have a "_"
    stringif( Repeater_Result.Output{/item/SCHGT} == "X", "X", "_")
    Any suggestions?
    thank you.
    Matthias

    The problem is Oracle doesn't know the space function. But it knows a similar function: NVL --> replaces a null value with something else. So this statement works fine for me:
    update marc set
    LGort = '[Param.3]',
    dispo = '[Param.4]',
    schgt = NVL('[Param.5]', ' '),
    dismm = '[Param.6]',
    sobsl = NVL('[Param.7]',' '),
    fevor = '[Param.8]'
    where matnr = '[Param.1]' and werks = '[Param.2]'
    If Param.5 or Param.7 is null Oracle replaces it with a space in every other case it is the parameter itself.
    Christian, thank you for your hint with the space function. So I remembered the NVL-function.
    Regards
    Matthias

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to get all tables in oracle sql developer with MS SQLServer

    Hi All,
    I am using microsoft SQL server 2000. For displaying the tables and other stuff i am using oracle SQL developer tool. The problem is when i connect to sql developer with oracle database i can see all the tables in that database. But when i connect to MS SQL server database it is not showing all the tables in that database. I don't know why?.
    i tried doing the samething using another tool called Aqua Data Studio , there i can able to see all the tables in microsoft SQL server 2000.
    do you have any knowledge regarding this, why i am not getting all the tables in oracle sql developer when i connect to microsoft SQL server 2000.

    Same issue here. Haven't found the answer yet..

Maybe you are looking for

  • What is the policy now?

    I have an 8g iPhone and the speaker just went on it.....i can no longer hear music or have any alerts or ringtones comes through. I will be making an appointment with the apple genius but what is the exchange policy now? Will i get a refurb right the

  • Under what circmustances, is BodyContent null?

    Hi, I got a problem with BodyContent in my custom tag. I created the class that extends BodyTagSupport, and I use bodyContent object, which is a field of BodyTagSupport, in doEndTag method. The problem is "bodyContent is always null." Why is that? Do

  • Progress bar (app.thermometer) ???

    Need to display a progress bar using thermomter object while invoking a web service. Lets assume the function loadWebService() has the logic to connect and retrieve data from a web service. Can anyone drop a few lines of code to implement this logic?

  • Link freezes when trying to restore

    hi there, I did a full back up of my phone and updated the software everything went as planned phone started when i try to do the restore it keeps failing saying communication lost as it is about to start the restore (after saying preparing for resto

  • My address bar--in fact, my entire toolbar--has diappeared! I can't enter any new websites, or manage anything on familiar websites...no buttons,no control!

    To reiterate, my address bar and my entire toolbar have disappeared. I cannot enter any new websites, and I cannot control anything on the websites that I can enter, because my buttons are gone. The only websites I can access are the ones already loc