Reputation: 19
I query the Teradata database using resultset
and getmetadata
. For some reason I find it hard to get the result using C#.
This is the code in Java:
public class T20905JD
{
public static String sUser = "guest";
public static String sPassword = "please";
public static void main(String args[])
{
// Creation of URL to be passed to the JDBC driver
String url = "jdbc:teradata://whomooz/TMODE=ANSI,CHARSET=UTF8";
// Creating a connection object
Connection con = DriverManager.getConnection(url, sUser, sPassword);
System.out.println(" User " + sUser + " connected.");
System.out.println(" Connection to Teradata established. \n");
DatabaseMetaData dbmd = con.getMetaData();
System.out.println(" DatabaseMetaData object created. \n");
ResultSet rs = dbmd.getSchemas();
// Display the database names
System.out.println(" DISPLAYING ALL DATABASE NAMES:\n");
while(rs.next())
{
System.out.println(" " + rs.getString("TABLE_SCHEM"));
}
}
}
How would I get the same result using C# in Teradata?
Upvotes: 0
Views: 1187
Reputation: 371
this is not related to C# nor Java, but Teradata. The easiest way to get all databases (schemata) is to query for:
SELECT DatabaseName, OwnerName
FROM DBC.DATABASES
WHERE DBKind = 'D';
If you would like to see the hierarchy of the databases, you have to include OwnerName into your query.
Upvotes: 2