AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Metodo che restituisce tutti i nomi dei database di sql serv

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java (Italian)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Apr 28, 2006 12:12 pm    Post subject: Metodo che restituisce tutti i nomi dei database di sql serv Reply with quote



Ciao a tutti ecco il mio problema:

ho bisogno di creare un metodo che restituisce una lista di tutti i
nomi dei database contenuti in sql server:
public List<String> getNomiDatabase()
List<String> dataBases = new ArrayList<String>();
......
return dataBases;

per avere la connessione ad an database noto uso il seguente frammento
di codice:

String url = "jdbc:odbc:DRIVER = SQL Server; Server = (local);
Database="+databaseNoto+";";
String username= "";
Styring pwd="";
try
con = DriverMAnager.getConnection(url,username,pwd);

catch
......

ma sicuramente non devo utilizzarlo perchè non devo connettermi al
data base ma devo sapere solo il nome.
potete aiutarmi completare il metodo? non sò proprio come fare! grazie
1000!!
Back to top
Vincent Vega
Guest





PostPosted: Fri Apr 28, 2006 4:12 pm    Post subject: Re: Metodo che restituisce tutti i nomi dei database di sql Reply with quote



lambertovenga (AT) hotmail (DOT) com wrote:

Quote:
ho bisogno di creare un metodo che restituisce una lista di tutti i
nomi dei database contenuti in sql server:

Esiste la stored procedure di sistema sp_databases.
Back to top
xamul
Guest





PostPosted: Mon May 01, 2006 10:12 pm    Post subject: Re: Metodo che restituisce tutti i nomi dei database di sql Reply with quote



Vincent Vega ha scritto:
Quote:
Esiste la stored procedure di sistema sp_databases.

non è cross database


meglio usare l'oggetto java.sql.DatabaseMetaData (lo ottiene da
connection.getMataData()) mi sembra che il metodo sia getSchemas();
(boh da provare comunque da li ci si arriva).
Back to top
Vincent Vega
Guest





PostPosted: Tue May 02, 2006 8:19 am    Post subject: Re: Metodo che restituisce tutti i nomi dei database di sql Reply with quote

xamul wrote:
Quote:
Vincent Vega ha scritto:
Esiste la stored procedure di sistema sp_databases.

non è cross database

Lui chiedeva espressamente sql Server.

Quote:
meglio usare l'oggetto java.sql.DatabaseMetaData (lo ottiene da
connection.getMataData()) mi sembra che il metodo sia getSchemas();
(boh da provare comunque da li ci si arriva).

Sicuro che gli schema siano i database, ovvero ciò che chiede? (non
so, chiedo)
Comunque anche i metadata non sono tutte informazioni disponibili allo
stesso modo su tutti i database.
Back to top
Guest






PostPosted: Tue May 02, 2006 10:12 am    Post subject: Re: Metodo che restituisce tutti i nomi dei database di sql Reply with quote

per poter usare connection.getMetaData() devo usare la stringa di
connessione
String url = "jdbc:odbc:DRIVER = SQL Server; Server = (local);
Database="+databaseNoto+";"; //questo campo NON posso passarglielo
perchè non lo conosco
String username= "";
Styring pwd="";
try
con = DriverMAnager.getConnection(url,username,pwd);
come faccio?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.