Error in java sql


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Error in java sql

  1. #1
    Join Date
    Sep 2005
    Posts
    39

    Error in java sql

    I am running the following code in JSP and I am receiving the error message:
    "sun.jdbc.odbc.JdbcOdbcResultSet@1627086 "

    String sql1 = "SELECT employeeID, groupPolicyNo FROM employee WHERE employeeID = 9;";
    Statement stmtAdmin =con.createStatement();
    ResultSet res = stmtAdmin.executeQuery(sql1);
    out.println(res);


    // the next query finds all the employees who have that group policy no.
    String sql2 = "SELECT employeeID, groupPolicyNo FROM employee WHERE groupPolicyNo = "+res+" ;";
    Statement stmt =con.createStatement();
    ResultSet rs = stmt.executeQuery(sql2);
    out.println(rs);

    These queries are running perfectly in the database but not on the browser,
    Can any one shed some light?

  2. #2
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    I assume that you are using an Applet in the browser? And it is running in the browser's Java plugin.
    If so, there might be error messages in the browser's Java console. Find the browser's menuitem that displays the Java console and copy the error messages from there to here.

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    I may be missing some features here.... but it seems to me that you are concatenating
    the string representation of a ResultSet instance to your second query string .

    I would code it like:
    Code:
    // the next query finds all the employees who have that group policy no.
    String sql2 = "SELECT employeeID, groupPolicyNo FROM employee WHERE groupPolicyNo = "+res.getString("groupPolicyNo")+" ;";
    And whats with that semicolon inside the query string ?
    eschew obfuscation

  4. #4
    Join Date
    Sep 2005
    Posts
    39
    Yes, I am concatenating a string representation of a ResultSet inside the second record. No I am not using an applet in a browser. But I have decided to re-write the code in pure Java instead of JSP.

    Thanks for the help!

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Kust for the record:

    A string representation of a java object has no business in a query string, unless it was in a (weird) database of java references strings.
    eschew obfuscation

Similar Threads

  1. Has Sun Given Up on the Desktop?
    By Lori Piquet in forum Talk to the Editors
    Replies: 114
    Last Post: 10-10-2002, 07:01 AM
  2. Replies: 3
    Last Post: 06-28-2002, 08:36 AM
  3. JAVA XML vs. PHP SQL
    By Kirsten Darrow in forum Web
    Replies: 0
    Last Post: 12-08-2000, 07:23 AM
  4. sql ser via java
    By a in forum Java
    Replies: 2
    Last Post: 11-16-2000, 10:09 PM
  5. Re: ODBC error
    By Devaraj in forum Enterprise
    Replies: 0
    Last Post: 05-11-2000, 01:48 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center