Syntax for Database query on a simple java appl?

Connection con;
private boolean conFree = true;
private String dbName = "java:comp/env/jdbc/gene";
public geneDB () throws Exception {
try{
     Context ic = new InitialContext();
     DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
catch (Exception ex){
throw new Exception("Couldn't open connection to database: " + ex.getMessage());
String insertStatement =     "insert into gene (cds,status) values(" + cds + "," + status + ")";
PreparedStatement prepStmt = con.prepareStatement(insertStatement);
prepStmt.setString(1, cds);
prepStmt.setString(2, status);
prepStmt.executeUpdate();
prepStmt.close();
Any comments??? This is what i have done, pls comment....

actually i m having some kind of trouble and i would like to confirm about the code design suggestion regarding about the database query using pointbase through a java web service.

Similar Messages

  • Thread monitoring for database query

    Hi,
    I need to be able to store a database query in a thread. This means that the entire query from executing to return should take place in this thread (as well as connection etc). I would then like to know when it have finished its work so i can carry on some more porcessing.
    I tried doing this with two threads, one to do the work and the other to 'watch' and then tell me when is is done. However, i errors 'every now and again' to which i can attribute to my thread structure not working properly. I am using a synchronised class and code post the code if anyone wishes to see it, however, i would appreciate it if someone could give me a basic structure to how i can go about this so that i do not get these 'random' errors.
    Thanks Rudy

    Okay -
    I have an idea. Withut fully implementing your code, mind you.
    If looks like you're having problems with concurrent access to your Vector.
    A Vector is, of course, a Collection and a List (interfaces) - these are not thread safe. To make them thread safe, you need to "wrap" them.
    <lifted from JavaDocs>
    public static Collection synchronizedCollection(Collection c)
        Returns a synchronized (thread-safe) collection backed by the specified collection. In order to guarantee
    serial access, it is critical that all access to the backing collection is accomplished through the returned
    collection.
        It is imperative that the user manually synchronize on the returned collection when iterating over it:
      Collection c = Collections.synchronizedCollection(myCollection);
      synchronized(c) {
          Iterator i = c.iterator(); // Must be in the synchronized block
          while (i.hasNext())
             foo(i.next());
        Failure to follow this advice may result in non-deterministic behavior.
        The returned collection does not pass the hashCode and equals operations through to the backing
    collection, but relies on Object's equals and hashCode methods. This is necessary to preserve the
    contracts of these operations in the case that the backing collection is a set or a list.
        The returned collection will be serializable if the specified collection is serializable.
        Parameters:
            c - the collection to be "wrapped" in a synchronized collection.
        Returns:
            a synchronized view of the specified collection.</lifted from JavaDocs>
    Give your Vector a wrapper and see if that solves your problem.
    +M                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Date syntax for MySql query in SQL Reporting Services

    I am currently trying to link a mysql Stored Procedure to a Microsoft SQL Reporting Server. It is coming up with a Syntax error. I believe this is down to the
    Date_from and Date_to Parameters. The query is below any help would be appreciated 
    DELIMITER $$ 
    USE `mydb`$$ 
    DROP PROCEDURE IF EXISTS `DTI`$$ 
    CREATE DEFINER=`linkeduser`@`%` PROCEDURE `DTI`(IN date_from DATETIME, 
    IN date_to DATETIME) 
    BEGIN 
    SELECT title,gender,firstname,lastname,address1,town,postcode,dob,IF(co.start_date = '00-00-0000', '', CAST(DATE(co.start_date) AS DATE)) AS 'StartDate' 
    FROM cf_user AS us 
    JOIN ca_compliance AS co ON co.user_id = us.user_id 
    WHERE co.start_date BETWEEN date_from AND date_to; 
    END$$ 
    DELIMITER ;

    Hello,
    The dataset query runs on the external data source.
     In your case, you create a report by retrieve data from MySQL database with a stored procedure. The stored procedure will run on MySQL Server and return the result in the Report designer or Report Builder. To solved this issue, please execute the stored
    procedure on the MySQL database and check the syntax error.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Syntax for Update Query?

    Hi
    I have the following query:
    update martin_adhoc_pct
    set adhoc.mbr_oed = mbr.orig_eff_date
    where adhoc.subs_ssn = mbr.subs_ssn
    and adhoc.mbr_type = mbr.mbr_type
    I get an error saying that:
    ORA-000904 "mbr"."mbr_type" invalid identifier..
    I am using PL/SQL and pulled the table name and field directly from the Objects listing so the names are right. This is the first time I've attempted an UPDATE statement with SQL, so wondering what I'm doing wrong..
    Thanks for any help..

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    I have created a table in our data warehouse that has a blank column (specified as datatype DATE) that I want to update with data from another data warehouse table (one that I didn't create). So for example:
    ssn mbr type oed
    123456789 aab needs to be filled in
    987654321 dd1 needs to be filled in
    etc..
    The unique identifier is the sub id and mbr type, so that's why my code joined these fields between the tables. Where they are equal, fill in the associated oed. I need all rows filled in, not just one. Here is the created table code:
    SELECT  mbr00.mbr_type,
            mbr00.mbr00_subs_ssn,
            me607.subscriber_id,
            cast (null as date) mbr_oed       
    from  odw.member_exp me607,
            odw.member_mas mbr00
    where   me607.subscriber_id = mbr00.mbr00_ssn_ref_num   
    and     me607.elig_start_date < sysdate
    and     me607.elig_end_date > sysdate
    and     me607.rmc_code in ('123')
    {code}
    Thanks..
    Edited by: user12296489 on Feb 11, 2010 9:06 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Value settings for database query

    I have a database set up for item prices. Currently, the
    database is set for currency and I have 1.99 and 2.99 entered in
    the two fields. However, the cfm page form displays them as 1.9900
    and 2.9900. Why is it adding the extra "00" at the end? The value
    in the page coding is integer. Should I have it set at something
    different? Also, how would I get a "$" to show before the price?
    Thanks,
    Dave

    It is probable that your database is adding the extra zeros
    as an
    indication of the precision the field contains for currency.
    Many
    people care about those fractions of a cent and would not
    want them
    rounded off.
    To display the data the way your desire, check out the
    DecimalFormat(),
    DollarFormat() and|or NumberFormat() functions.
    Dave Blake wrote:
    > I have a database set up for item prices. Currently, the
    database is set for
    > currency and I have 1.99 and 2.99 entered in the two
    fields. However, the cfm
    > page form displays them as 1.9900 and 2.9900. Why is it
    adding the extra "00"
    > at the end? The value in the page coding is integer.
    Should I have it set at
    > something different? Also, how would I get a "$" to show
    before the price?
    >
    > Thanks,
    > Dave
    >

  • Syntax for insert query

    I want to insert like
    insert into families(id, name) values(1,'Ram's car');
    but due to 's in Ram's car error is occurring.
    Plz suggest any solution.....

    Replace one single quote by two single quotes:
    SQL> insert into families(id, name) values(1,'Ram''s
    car');
    1 row created.
    SQL>
    True, alternatively
    insert into families(id, name) values(1,q'!Ram's car!');Both of which the OP would have easily discovered with a simple search.

  • Query Syntax for Dynamic Navigation Menu

    I'm trying to build a Navigation menu from a query using the following syntax:
    select LEVEL,
           LABEL,
           LINK,
           'NO' as IS_CURRENT,
           null as IMAGE
      from V$RC_MENUS
    where CLUB = :APP_CLUB
    start with PID is null
    connect by prior ID = PID
    order by SEQUENCE, LABEL
    The query itself works fine for all values of APP_CLUB but it only generates the menu entries for some values of APP_CLUB, but not others. The SEQUENCE value determines the order of the entries within each level. Is this the correct syntax for a query-based navigation menu? How does it determine which sub-levels belong to a parent?  Does the ordering of the resultset have any impact on how the menu is generated?

    Jritschel-Oracle wrote:
    I'm trying to build a Navigation menu from a query using the following syntax:
    select LEVEL, 
          LABEL, 
          LINK, 
          'NO' as IS_CURRENT, 
          null as IMAGE 
      from V$RC_MENUS 
    where CLUB = :APP_CLUB 
    start with PID is null 
    connect by prior ID = PID 
    order by SEQUENCE, LABEL 
    The query itself works fine for all values of APP_CLUB but it only generates the menu entries for some values of APP_CLUB, but not others. The SEQUENCE value determines the order of the entries within each level. Is this the correct syntax for a query-based navigation menu? How does it determine which sub-levels belong to a parent?  Does the ordering of the resultset have any impact on how the menu is generated?
    As stated in the documentation:
    ...do not specify either ORDER BY or GROUP BY, because they will destroy the hierarchical order of the CONNECT BY results. If you want to order rows of siblings of the same parent, then use the ORDER SIBLINGS BY clause.
    Try:
    select LEVEL,
          LABEL,
          LINK,
          'NO' as IS_CURRENT,
          null as IMAGE
      from V$RC_MENUS
    where CLUB = :APP_CLUB
    start with PID is null
    connect by prior ID = PID
    order siblings by SEQUENCE, LABEL

  • Syntax for query help

    I'm in need of coming up with the correct syntax for a query that would work in Oracle.
    I would like to convert or change the syntax of my SQL statement used in SQL Server to produce the same result in Oracle.
    Select receiptDate, receiptNumber, receiptAmount
    From receipt, customer
    where customer.customerid = receipt.customerid
    and customerName = 'Joe Smith'
    and receiptDate between '01/01/2011' and '03/31/2011'
    ORDER BY receiptDate;
    Sorry if this is posted in the wrong forum.
    Thank you for any information, even if it is just a link to show where I can get more syntax structure.

    Hi,
    Welcome to the forum!
    891100 wrote:
    I'm in need of coming up with the correct syntax for a query that would work in Oracle.
    I would like to convert or change the syntax of my SQL statement used in SQL Server to produce the same result in Oracle.
    Select receiptDate, receiptNumber, receiptAmount
    From receipt, customer
    where customer.customerid = receipt.customerid
    and customerName = 'Joe Smith'
    and receiptDate between '01/01/2011' and '03/31/2011'
    ORDER BY receiptDate;Is receiptDate a DATE? If so, change the last part of the WHERE clause from
    and receiptDate between '01/01/2011' and '03/31/2011'to
    AND     receiptDate >= TO_DATE ( '01/01/2011'     -- First day to include
                                 , 'DD/MM/YYYY'
    AND      receiptDate <  TO_DATE ( '04/01/2011'     -- First day NOT to include
                                 , 'DD/MM/YYYY'
                          ) Or you can use DATE literals, like this:
    AND     receiptDate >= DATE '2011-01-01'
    AND      receiptDate <  DATE '2011-04-01'With DATE literals, you don't have any choice of format: the dates have be to given as 'YYYY-MM-DD'.
    DATEs in Oracle always include hours, minutes and seconds. If you don't specify the hours, minutes or seconds, they default to 00.
    If you said:
    AND     receiptDate BETWEEN TO_DATE ( '01/01/2011'
                                          , 'DD/MM/YYYY'
                  AND     TO_DATE ( '03/31/2011'
                                          , 'DD/MM/YYYY'
                                   ) that would not include most of the last day, March 31: it would include only the first second of that day (that is, 00:00:00). To include all of March 31, up to and including 23:59:59, you could say:
    AND     receiptDate BETWEEN TO_DATE ( '01/01/2011'
                                          , 'DD/MM/YYYY'
                  AND     TO_DATE ( '03/31/2011 23:59:59'
                                          , 'DD/MM/YYYY HH24:MI:SS'
    Sorry if this is posted in the wrong forum. No, this is the right place for this kind of question.
    Thank you for any information, even if it is just a link to show where I can get more syntax structure.

  • XPATH Database Query Syntax in an Assign

    Trying to get an XPATH Database query to work by assigning the Input variable value in a simple BPEL Process to my query condition. I keep getting invalid XPATH errors. I cannot seem to figure out how get write it out.
    Here is what I have:
    <from expression="orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')"/>
    Here is my error:
    Error(30): [Error ORABPEL-10039]: invalid xpath expression [Description]: in line 30 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\BPELws\ReadDB\ReadDB.bpel", xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" specified in <from> is not valid, because XPath query syntax error. Syntax error while parsing xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')", at position "80" the exception is Expected: ). Please verify the xpath query "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" which is defined in BPEL process. . [Potential fix]: Please make sure the expression is valid.
    Any help?
    Thanks!!!

    Ok. I have figured out how to place the condition (variable value) inside a concatentated string. So my final result is the actual XPATH Query-Database statement. But the problem is it is being returned as a String. How can I turn that final string into the XPATH expression I need? I suspect another <COPY> block could pull this off but I am not sure how to do it.
    Here is my code:
    <process name="QueryBuild" targetNamespace="http://xmlns.oracle.com/QueryBuild" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:client="http://xmlns.oracle.com/QueryBuild" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="client:QueryBuild" myRole="QueryBuildProvider"/>
    </partnerLinks>
    <variables>
    <variable name="inputVariable" messageType="client:QueryBuildRequestMessage"/>
    <variable name="outputVariable" messageType="client:QueryBuildResponseMessage"/>
    <variable name="QueryText" type="ns1:string"/>
    </variables>
    <sequence name="main">
    <receive name="receiveInput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="inputVariable" createInstance="yes"/><!-- Generate reply to synchronous request -->
    <assign name="Assign_1">
    <copy>
    <from expression="concat(&quot;orcl:query-database('select ename from emp where empno = &quot;, bpws:getVariableData('inputVariable','payload','/client:QueryBuildProcessRequest/client:input'), &quot;,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL)'&quot;)"/>
    <to variable="QueryText"/>
    </copy>
    <copy>
    <from variable="QueryText"/>
    <to variable="outputVariable" part="payload" query="/client:QueryBuildProcessResponse/client:result"/>
    </copy>
    </assign>
    <reply name="replyOutput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="outputVariable"/>
    </sequence>
    </process>

  • How do I change Transfer Syntax for DICOM images using sample Java sources?

    Hi,
    I tested using Note:876534.1 Java API samples. It works fine when I put the "Implicit VR Little Endian" DICOM file.
    I could insert the DICOM file, also I could get the all DICOM tags correctly by SQL.
    But I could not get all DICOM tags when inserted "Explicit VR Little Endian" and "JPEG Lossy" DICOM file.
    Also I could not find how to change the Transfer Syntax to orddicom Java API.
    How do I change following simple java source for inserting different Transfer Syntax DICOM file?
    Connection conn = DriverManager.getConnection(args[0], args[1], args[2]);
    System.out.println("Got database connection");
    conn.setAutoCommit(false);
    Statement stmt = conn.createStatement();
    CallableStatement cs = null;
    cs = conn.prepareCall("begin ord_dicom.setDataModel(); end; ");
    cs.execute();
    cs.close();
    String rowInsertSQL = "insert into dicom_test (id, dcmobj) values (" + args[3] + ",ordsys.orddicom())";
    stmt.execute(rowInsertSQL);
    System.out.println("Inserted empty dicom object ...");
    String rowSelectSQL = "select dcmobj from dicom_test where id = " + args[3] + " for update";
    OracleResultSet rset = (OracleResultSet)stmt.executeQuery(rowSelectSQL);
    rset.next();
    OrdDicom dcmProxy = (OrdDicom)rset.getORAData("dcmobj", OrdDicom.getORADataFactory());
    rset.close();
    System.out.println("selected row for update...");
    File testFile = new File(args[4]);
    boolean success = dcmProxy.loadContent(testFile, true);
    dcmProxy.setProperties();
    if (success) {            
    String updateSQL = "update dicom_test set dcmobj=? where id=" + args[3];
    OraclePreparedStatement opstmt =
    (OraclePreparedStatement)conn.prepareStatement(updateSQL);
    opstmt.setORAData(1, dcmProxy);
    opstmt.execute();
    int contentLength = dcmProxy.getContentLength();
    String SOPInstanceUID = dcmProxy.getSOPInstanceUid();
    System.out.println("contentLength: " + contentLength);
    System.out.println("SOPInstanceUID: " + SOPInstanceUID);
    opstmt.close();
    Thanks,
    Tatsuya
    Edited by: user13490925 on 2011/01/31 1:48

    It would go like this
    1. TIFF + XML metadata => DICOM image file
    you can use the method ord_dicom.createDicomImage(src blob, metadata xmltype, dest blob) to create the DICOM image in a blob.
    2, then use the ORDDicom constructor ORDDIcom(data blob) to create an ORDDicom object
    3. then use the ORDDicom processCopy method to change the image properties.
    Alternatively you can change image properties on the input TIFF image (using ORDImage methods) then create the DICOM image. If you are happy with the image properties then you can skip step 3.
    Edited by: rabbott on Jun 22, 2009 12:41 PM

  • MS SQL - Syntax error for valid query

    I have a problem with the second query in this code (gives me
    a syntax error in my HAVING line)
    <cfquery name="getDupes" datasource="#application.ODBC1#"
    dbtype="ODBC" username="#application.userNameODBC1#"
    password="#application.userPassODBC1#">
    SELECT *
    FROM view_FormCount
    WHERE formCount >= 2
    ORDER BY formNum
    </cfquery>
    <cfset variables.lstForms = "">
    <cfoutput query="getDupes">
    <cfset variables.lstForms=
    listAppend(variables.lstForms,"'#getDupes.formNum#'")>
    </cfoutput>
    <cfset variables.whereClause = "(formNum =
    #ReplaceNoCase(variables.lstForms,',',' OR formNum =
    ','ALL')#)">
    <cfquery name="getDetails"
    datasource="#application.ODBC1#" dbtype="ODBC"
    username="#application.userNameODBC1#"
    password="#application.userPassODBC1#">
    SELECT tblForms.formNum, tblForms.formName,
    tblForms.formCustNum, tblCompanies.companyAbbr
    FROM tblForms INNER JOIN tblCompanies ON tblForms.formCustNum
    = tblCompanies.companyNum
    GROUP BY tblForms.formNum, tblForms.formName,
    tblForms.formCustNum, tblCompanies.companyAbbr
    HAVING #variables.whereClause#
    ORDER BY tblForms.formNum, tblForms.formCustNum
    </cfquery>
    Now, the really odd thing is if I just take the query text
    out of the CFQUERY tags and use CFOUTPUT instead (to see in my
    browser what query is getting executed) I get a query that I can
    paste into Enterprise Mgr and runs fine.
    I can even paste the resulting text into my code in a CFQUERY
    and CF will run it fine.
    In other words, the dynamic version query gives me an error,
    but if I just output the SQL statement, copy-and-paste that into
    the CFQUERY that's erroring out (replacing what's there) to run as
    a static query, it works fine (sample of static query below).
    The error I get when I try to do it dynamically is "Error
    Executing Database Query. [Macromedia][SQLServer JDBC
    Driver][SQLServer]Line 4: Incorrect syntax near '10169318'. The
    error occurred on line 21." which is where the HAVING clause
    starts.
    SELECT tblForms.formNum, tblForms.formName,
    tblForms.formCustNum, tblCompanies.companyAbbr FROM tblForms INNER
    JOIN tblCompanies ON tblForms.formCustNum = tblCompanies.companyNum
    GROUP BY tblForms.formNum, tblForms.formName, tblForms.formCustNum,
    tblCompanies.companyAbbr HAVING (formNum = '10169318' OR formNum =
    '1016CONCERTA' OR formNum = '1016NSAIDS' OR formNum =
    '1016STRATTERA' OR formNum = '1016WELLBUTRIN' OR formNum =
    '18504211' OR formNum = '185093807' OR formNum = '73208565' OR
    formNum = '732120027' OR formNum = '7322154' OR formNum = '7323402'
    OR formNum = '7323522' OR formNum = '73238900' OR formNum =
    '7324211' OR formNum = '7324211S' OR formNum = '7324265' OR formNum
    = '73242891' OR formNum = '732434341' OR formNum = '732434342' OR
    formNum = '73243435' OR formNum = '73243436' OR formNum =
    '73243439' OR formNum = '73243440' OR formNum = '73243441' OR
    formNum = '73243442' OR formNum = '73243443' OR formNum = '7324359'
    OR formNum = '7324360' OR formNum = '7324370' OR formNum =
    '7324560' OR formNum = '7324959' OR formNum = '7326411ptreg' OR
    formNum = '7326599' OR formNum = '7326600' OR formNum = '7326620'
    OR formNum = '7326707' OR formNum = '7326931' OR formNum =
    '7328410' OR formNum = '732851031TOP' OR formNum = '7328512' OR
    formNum = '7328548' OR formNum = '7328548P2' OR formNum =
    '7328548P3' OR formNum = '7328548P4' OR formNum = '73289400' OR
    formNum = '73290D' OR formNum = '7329154' OR formNum =
    '73291544JHS' OR formNum = '73291545JHS' OR formNum =
    '73291546JHSMH' OR formNum = '73291547JHSMH' OR formNum = '7329174'
    OR formNum = '7329308' OR formNum = '7329402' OR formNum =
    '7329424' OR formNum = '7329455' OR formNum = '7329520' OR formNum
    = '7329539' OR formNum = '73297701JH' OR formNum = '73298273' OR
    formNum = '73298400' OR formNum = '73298403' OR formNum =
    '73298404' OR formNum = '7329883' OR formNum = '73298860' OR
    formNum = '7329887' OR formNum = '73298974' OR formNum = '7329899'
    OR formNum = '7329899S' OR formNum = '73299190' OR formNum =
    '7329987' OR formNum = '7329999PTO' OR formNum = '732AV5160' OR
    formNum = '732CMHFRAZ' OR formNum = '732HIPAA' OR formNum =
    '732HIPAAFLYERS' OR formNum = '734HEART' OR formNum = '7444711' OR
    formNum = '7449230' OR formNum = '744HR4991' OR formNum =
    '7538014MI' OR formNum = '77511044' OR formNum = '77511045' OR
    formNum = '775stampnochange' OR formNum = '80851001BLUE' OR formNum
    = '80MR4200' OR formNum = '80MR4273' OR formNum = '80MR4274' OR
    formNum = '80MR4300' OR formNum = '80MR9934' OR formNum =
    '80MR9935' OR formNum = '80SHC100' OR formNum = '80SHC4301' OR
    formNum = '80SHC9830' OR formNum = '80SHC9832') ORDER BY
    tblForms.formNum, tblForms.formCustNum

    AWFrueh1808 wrote:
    > OK, that's simple enough. But then I'm really confused
    as to why the query in
    > my original post/example didn't work.
    >
    > The only single quotes in my #whereClause# variable were
    wrapped around each
    > varchar value in the WHERE clause (well, HAVING) as in
    HAVING formNum = '12345'
    > OR formNum = '54321'
    >
    > I never used a single quote within the value itself. And
    yet
    > preservesinglequotes fixed it. So what was CF doing? Why
    did the single
    > quotes still show up in the error msg - and in the right
    place?
    >
    As I said the default behavior is to escape the quotes in
    your variables
    as data. So the default output of your SQL statement, before
    preserveSingleQuotes() would be like this.
    HAVING formNum = ''12345'' OR formNum = ''54321''
    As you can see that is not the desired results in your case.
    In your
    case you have the proper number of single quotes in your
    string and you
    do not want any added. You want to preserve them so to say.
    Thus
    adding preserveSingleQuotes() around your whereClase
    variable, i.e.
    preserveSingleQuotes(whereClause) says do not add any quotes,
    keep them
    all single.

  • Access database query resultset in java scriptlet

    Question:
    1) I am Creating a web page and plotting points on the page:
    2) Database query results in decimal values dec_latitude and dec_longiitude.
    3) Perform calculations on lati. & long. in a java scriptlet to create a plot position (xpos, ypos).
    4) Send the xpos and ypos back to the java server page
    5) Use <IMG and absolute positioning to plot the point at position xpos, and ypos.
    6) Repeat until all rows in the query result set have been plotted.
    I don't know how to pass the dec_latitude and dec_longitude to the java scriptlet.
    After the java scriptlet calculation translates the latitude and longitude
    into xpos and ypos, I need to pass the xpos and ypos back to the java server page so that a data point is plotted on a map at position xpos, ypos.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    The code below results in a runtime error.
    Am I supposed to create a java object and access that in the java scriptlet? Can the java scriptlet access the latvar and longvar created during the "<c:set var="latvar"... ?
    If not, what mechanisum do I use to access the resulting colums: dec_latitude and dec_longitude? I need the java scriptlet to convert the
    dec_latitude and dec_longitude into a display position based on the number of pixels from the TOP and LEFT (xpos, ypos). Then plot of the data point using the IMG and (xpos, ypos). This will overlay a map whose z-index is lower than the plotted data point.
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar"); <--- runtime error !!!!
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    </c:forEach>

    Thanks
    I still get a runtime error: I translated the code you gave to code below .... which I think is equivalent. See Below: I'm still learning about this stuff so I may not have not translated this properly. Do
    you see what I am doing wrong?
    Best Regards,
    - John
    %@ page language="java" contentType="text/html;
    charset=ISO-8859-1"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page import="java.lang.Math"%>
    <sql:setDataSource dataSource="jdbc/SampleDB" />
    <c:set var="genus_name" value="${param.genus_name}" />
    <c:set var="species_name" value="${param.species_name}" />
    <c:set var="species_common_name" value="${param.species_common_name}" />
    <c:set var="dd_sighted" value="${param.dd_sighted}" />
    <c:set var="mm_sighted" value="${param.mm_sighted}" />
    <c:set var="yyyy_sighted" value="${param.yyyy_sighted}" />
    <c:set var="species_state" value="${param.species_state}" />
    <c:set var="species_county" value="${param.species_county}" />
    <c:set var="species_country" value="${param.species_country}" />
    <c:set var="dec_latitude" value="${param.dec_latitude}" />
    <c:set var="dec_longitude" value="${param.dec_longitude}" />
    <c:set var="notes" value="${param.notes}" />
    <c:set var="person_first_name" value="${param.person_first_name}" />
    <c:set var="person_last_name" value="${param.person_last_name}" />
    <c:set var="person_street" value="${param.person_street}" />
    <c:set var="person_city" value="${param.person_city}" />
    <c:set var="person_state" value="${param.person_state}" />
    <c:set var="person_zip" value="${param.person_zip}" />
    <c:set var="person_country" value="${param.person_country}" />
    <c:set var="person_email" value="${param.person_email}" />
    <h2>Species Sightings:</h2>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Breckenridge Citizen Bio-Survey Selective Output Page</title>
    </head>
    <body>
    Izaak Walton League of America
    <h1>Breckenridge Citizen Bio-Survey Selective Output</h1>
    <HR>
    <c:if test="${param.action == 'Submit'}">
    <%int xpos = 0;
         int ypos = 0;
         float latitude = 0.0F;
         float longitude = 0.0F;
         float latitudeMpls = 45.06F;
         float longitudeMpls = -93.14F;                    int xposMpls = 1205 - (int) Math.round(latitudeMpls);
         int yposMpls = 735 + (int) Math.round(longitudeMpls);
    %>
    <IMG SRC="minnesota_1990.jpg" ALT="minesota map" style="z-index:1;"> <----- THIS WORKS FINE
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2"> <----- THIS WORKS FINE FOR HARDCODED MPLS XPOS AND YPOS
    <sql:query var="qryBio">
    SELECT
    PERSON_FIRST_NAME,
    PERSON_LAST_NAME,
    GENUS_NAME,
    SPECIES_NAME,
    SPECIES_COMMON_NAME,
    SPECIES_COUNTY,
    SPECIES_STATE,
    SPECIES_COUNTRY,
    DD_SIGHTED,
    MM_SIGHTED,
    YYYY_SIGHTED,
    DEC_LATITUDE,
    DEC_LONGITUDE,
    NOTES,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    genus_name like rtrim(upper('${genus_name}')) AND
    species_name like rtrim(upper('${species_name}')) AND
    species_common_name like rtrim(upper
    ('${species_common_name}')) AND
    species_state like rtrim(upper('${species_state}')) AND
    species_county like rtrim(upper('${species_county}')) AND
    species_country like rtrim(upper('${species_country}')) AND
    person_first_name like rtrim(upper('${person_first_name}')) AND
    person_last_name like rtrim(upper('${person_last_name}')) AND
    person_email like rtrim(upper('${person_email}'))
    </sql:query>
    <c:forEach var="row" items="${qryBio.rows}">
    <--- THE LINE ABOVE WORKS FINE --->
    <c:set var="latvar" value="${row.dec_latitude}" scope="page" />
    <c:set var="longvar" value="${row.dec_longitude} " scope="page" />
    <%
    latitude =
    Float.parseFloat((String)pageContext.getAttribute("latvar"));
    <--- RUNTIME ERROR OCCURS HERE --- SEE LINE ABOVE --->
    longitude =
    Float.parseFloat((String)pageContext.getAttribute("longvar"));
    xpos = (int) Math.round(latitude);
    ypos = (int) Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    request.setAttribute("xpos",new Integer(xpos));
    request.setAttribute("ypos",new Integer(ypos));
    %>
    IIMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    <--- THIS (ABOVE) WORKS FINE WITH CORRECT VALUES FOR XPOS AND YPOS WHEN RUNTIME ERROR DOES NOT OCCUR --->
    </c:forEach>
    </c:if>

  • Access database query data in Java SCriptlet

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar");
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar");
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

  • Database query from Java

    I'm writing a Java program that needs to query a Microsoft Access database. I'm not sure how to do this. Someone said to use ODBC drivers but I don't know what these are. Any clarification/ideas would be appreciated.

    There are a few easy step to set up a connection to your database in your java program.
    1. establish an odbc data source in windows control panel (may be under Administrative tools).
    2. you need to import the java.sql package.
    3. you need a connection, so type the following into your database class:
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection("jdbc:odbc:/*your data source name goes here*/");
    catch (ClassNotFoundException exception)
    System.err.println("Failed to load JDBC/ODBC driver");
    exception.printStackTrace();
    System.exit(1);
    catch (SQLException exception)
    System.err.println("Unable to connect");
    exception.printStackTrace();
    System.exit(1);
    }4. Find an SQL tutorial on the web.
    5. For each query/update etc create a Statement object using the following code:
    try
    Statement statement = connection.createStatement();
    /* now use the remainder of this try block to execute your query. Each database query returns a ResultSet object */
    ResultSet resultSet = statement.executeQuery("/*your query string goes here*/");
    /* the next() method in ResultSet returns true if there are any more records, like an iterator. Therefore, you know if there are any results or not*/
    if (resultSet.next())
    /* If your query was a 'SELECT * FROM ...etc' then you will get a whole row from the table(s) within the database. if you need to extract a number from that record and you know the column number, then use the following */
    int id = resultSet.getInt(1);
    /* where 1 corresponds to the first column in the table, and so on. Ifyou want to extract a String, the use the getString() method*/
    catch (SQLException exception)
    }That's basically the easiest way to go about it (I think). Best to consult a book for a more in-depth look. Try Java - How to Program, by Deitel and Deitel (available at www.deitel.com). I found this very useful.

  • Java bean for database access

    Hi,
    I am writing a JSP/servlet/Javabean based app. using MVC architecture.The database related logic is in java beans.
    I want a generalized class/bean that can form a connection , execute the passed query and return the results.Does any one has any URLs or sample code to explain how to do this using introspection?
    I would greatly appreciate any help as this design is very crucial for our application.
    Thanks -
    k

    i don't think it need help,every book has such code,maybe i haven't understanding your meaning correctly,follow steps:
    1 create a class named DBconnect,
    2 in the constructor of the class,you create the connection,
    3 add several methods that execute the operation into your class ,such as :executeQuery(),executeUpdare().....
    that depands the requirement of your project.

Maybe you are looking for

  • Adding an Icon to a JButton Component - Not working

    Hi all, Please help me by saying, why the below gevon SSCE doesnt work. import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; impo

  • Can't sync Reminders without iCloud?

    Really? For something as basic as Reminders (i.e. To-Do's) you are forced to use iCloud and can't sync through iTunes? Really?? I have no intention of ever using iCloud for any kind of Sync, and it seems just odd to me that it Reminders can't be sync

  • Wireless Connection to Sony XBR9

    I have just purchased a Sony XBR9 with a LAN input, an Airport Extreme 802.11n and an Airport Express 802.11n. My intent is to connect (hardwire) the Extreme in one room to my Dell & modem and the Express to the XBR9 in another room on the same floor

  • Supported way to migrate to larger hard disk

    I am a happy, no exctatic owner of a Macbook Pro 15 inch 2.6, purchased in December 2012. The 750 GB hard disk is a bit tight. So I'm looking at getting a 1.5 TB drive and migrating to it. I don't want to lose my restore partion or anything else I've

  • Problem with executing SPARQL command using jdbc or jena in Java

    Hi everybody I am new to Oracle and SPARQL, so I'm sorry if my question is the elementry one! select s, p, o  from table(SEM_MATCH( '(?s ?p ?o) (?s <htt...> ?o) ', SEM_Models('OWlTEST'), null, null, null )) I have an SPARQL command which runs on Orac