-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: sys.all_objects sqlserver
PostPosted: Fri Oct 25, 2013 2:14 pm 
Newbie

Joined: Fri Oct 25, 2013 1:48 pm
Posts: 5
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());
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.