Results 1 to 4 of 4
  1. #1
    Kelly is offline Member
    Join Date
    Mar 2010
    Posts
    7
    Rep Power
    0

    Default Not getting a response for query

    Hey im having some trouble getting a response with Java, Im able to connect to the database and get information like the version and so on, but when i try to get a query of any type, it doesn't respond... below is my code, would really appreciate any suggestions

    Java Code:
    import java.sql.*;
    
    public class Main {
    
      public static void main(String[] args)
          throws ClassNotFoundException, SQLException
      {
       Class.forName("oracle.jdbc.driver.OracleDriver");
    
        String url = "jdbc:oracle:thin:@//localhost:1521";
    
        Connection conn = DriverManager.getConnection(url,"test","test");
    
        conn.setAutoCommit(false);
        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select * from mytable");
        
        while (rset.next()) {
             System.out.println ("results: "+rset.getString(1));
        }
        stmt.close();
      }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,997
    Rep Power
    19

    Default

    Does mytable have anything in it?
    What does "select count(*) from mytable" give?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    What you mean by not get the response? Did your code completely execute without any results? Can you please elaborate bit more. Seems your code don't have an error.

    select * from mytable
    Is that above query really gives some results on your database?

  4. #4
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

Similar Threads

  1. response.setContentType
    By bbq in forum Java Servlet
    Replies: 3
    Last Post: 01-17-2012, 05:37 PM
  2. MDB/JMS Request/Response
    By rkands in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 03-04-2010, 02:38 PM
  3. Try catch response
    By Reiyn in forum New To Java
    Replies: 1
    Last Post: 03-30-2009, 08:30 PM
  4. response.sendRedirect(url)
    By mutuah in forum Advanced Java
    Replies: 2
    Last Post: 08-07-2007, 01:56 PM
  5. Velocity / XML response
    By sabatier in forum XML
    Replies: 0
    Last Post: 07-24-2007, 01:13 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
  •