Hi Kamal,

Thank you very much for your message.

First off, a little disclaimer (I have to!):

2017-06-28 3:23 GMT+02:00 Kamal raj <[email protected]>:

> Hi,
>
> Imagine , the user types the below sql string into the browser of our web
> application:
>
> show tables from employees
>
> Now using Jooq I connect to the user's database and I run the following
> code:
>
> Result<Record> result = context.fetch(sql);
>

I'm sure you know what you're doing here and that you give your users the
full power over your database, far beyond what's possible through SQL
injection. This is usually fine when you write a database administration
tool. So, I'm assuming you're writing such a database administration tool.


> System.out.println(result.size());
>
> for(Record a : result) {
>     System.out.println(a.toString());
>     System.out.println("*********Fileds***********");
>     Field<?>[] fields = a.fields();
>     for(Field field : fields)
>         System.out.println(field.toString());
>     System.out.println("\n\n");
> }
>
> Here I want to get all the data like table name and its corresponding
> column names , types etc so that I can show that back to the user. However
> the line:
>
> a.fields()
>
> is returning :
>
> Tables_in_employees
>
> I was expecting to return the fields of the corresponding table (ie Record
> details). May be I'm wrong here.
>

Yes of course, the behaviour is correct. What happens if you run your query
in some other database administration tool, such as SQL Workbench? You'll
get exactly that column. Why would you expect jOOQ to do more than that?

Perhaps, the query you meant to execute was:

SELECT * FROM information_schema.columns WHERE table_schema = 'employees'

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to