db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@gmail.com>
Subject Re: Tree view in Derby Stored Procedure
Date Mon, 20 Apr 2015 20:09:20 GMT
Again, I think that a table function would be well suited to this task. 
A table function is a public static method which returns a ResultSet. 
See 
http://db.apache.org/derby/docs/10.11/devguide/cdevspecialtabfuncs.html. 
I don't have any better idea than that.

I think that a streaming interface like ResultSet is a better solution 
than materializing a gigantic JSON or XML value.

Hope this helps,
-Rick

On 4/18/15 3:41 AM, BalNagendra wrote:
> Hi Rick, I am pasting code from program which did not work for 
> recursion very well. At line 13 executeQuery is returning a resultset. 
> This is where I am running into problem. ResultSet being a cursor I am 
> not able to use recursion. It would be better if I can return from 
> executeQuery a JSON or XML. JSON is scalar and can be manipulated 
> freely. Is there any such way to query the database. 1 package 
> recursion; 2 import java.sql.*; 3 public class RecursiveSQL { 4 public 
> static EmpRecord databaseConnection () throws SQLException { 5 
> Connection c = null; 6 Statement s = null; 7 ResultSet rs = null; 8 
> String ename = null; 9 EmpRecord emp = new EmpRecord(); 10 try { 11 c 
> = DriverManager.getConnection("jdbc:derby:scott"); 12 s = 
> c.createStatement(); 13 rs = s.executeQuery("SELECT empno, ename FROM 
> EMP"); 14 rs.next(); 15 
> System.out.println("rs="+rs.getString("ename")); 16 emp.empno = 
> rs.getInt("empno"); 17 emp.ename = rs.getString("ename"); 18 
> c.close(); 19 } 20 catch (SQLException sx) { 21 System.out.println ("
>
>
>       Database Connect SQL Exception.
>
> "); 22 sx.printStackTrace(); 23 } 24 return (emp); 25 } 26} thanks for 
> the help, BalNagendra
> ------------------------------------------------------------------------
> View this message in context: Re: Tree view in Derby Stored Procedure 
> <http://apache-database.10148.n7.nabble.com/Tree-view-in-Derby-Stored-Procedure-tp143909p143950.html>
> Sent from the Apache Derby Users mailing list archive 
> <http://apache-database.10148.n7.nabble.com/Apache-Derby-Users-f95095.html> 
> at Nabble.com.


Mime
View raw message