Hi Guys,
I want to read the names of all the tables that there are in a given SQL-Server database and I create a method that returns a list like this: return s.createSQLQuery("select name from sys.all_objects where type_desc = 'USER_TABLE' order by name").list();
This query runs with no problem in the Query Analyzer but gives out ( an java.lang.NullPointerException ) error when I try to execute it through hibernate on my site.
Where am I going wrong?
If anyone could help me would be great.
Thanks.
Reginaldo
Follow the entire method. It runs ok for IB ( Interbase ) and OR ( Oracle ) but not for ( S7 ) SqlServer
public Object LeTabelas(Object opcoes, Session s) throws Exception { try { List qryAux = s.createSQLQuery("SELECT CDSIST FROM TPT000").list(); if ( qryAux.get(0).toString().equalsIgnoreCase("IB")) return s.createSQLQuery("select cast( rdb$relation_name as varchar(30)) from rdb$relations "+ " where rdb$view_blr is null and (rdb$system_flag is null or rdb$system_flag = 0) "+ " order by rdb$relation_name").list();
else if ( qryAux.get(0).toString().equalsIgnoreCase("S7")) return s.createSQLQuery("select name from sys.all_objects where type_desc = 'USER_TABLE' order by name").list();
else return s.createSQLQuery("select TABLE_NAME from user_tables order by table_name").list(); } catch (Exception e) { throw new Exception(e.getCause().getMessage()); } }
|