ResultSet.getStatement returns null in some cases.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    ResultSet.getStatement returns null in some cases.

    I am trying out to find out how many Schemas are there in a Database.

    [code=java]
    ResultSet schema_rs = db_metadata.get Schemas();

    while(schema_rs .next()){
    String schema_name = schema_rs.getSt ring("TABLE_SCH EM");
    System.out.prin tln("Schema Name: " + schema_name);
    }
    System.out.prin tln("Yahoo: " + schema_rs.getSt atement());
    schema_rs.getSt atement().close ();
    [/code]

    Actually i read out API there it is told that if the ResultSet generated some other way as for example, through DatabaseMeta then it returns null.
    Here it matches the condition.
    Here no Schemas found ...and here I am using MySQL.
    If i tried with some other database so far I tried with PostgreSQL and Sybase.
    There I found some Schemas and there the ResultSet.getSt atement does not return null as it generated through DatabaseMetadat a.

    Is it database dependent?Or if no schemas found then it happens.
    Or it is a specific problem with MySQL?

    Debasis Jana.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    What does Google have to say about this? Have you tried there? I do not use MySQL so I could not tell you. Just making sure your question is answered:-)
    Last edited by Dököll; Dec 21 '08, 11:32 PM. Reason: MySQL for my SQL ;-)

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Your question is quite chaotic; read the API documentation for the ResultSet interface:

      Originally posted by ResultSet API
      Retrieves the Statement object that produced this ResultSet object. If the result set was generated some other way, such as by a DatabaseMetaDat a method, this method may return null.
      You didn't get your ResultSet by a Statement and hence the source Statement can be null.

      kind regards,

      Jos

      Comment

      Working...