Amazon Redshift Guía de usuario Pagina 178

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 255
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 177
Example Connect to a Cluster by Using .NET
The following example connects to a cluster and runs a sample query that returns system tables. It does
not show server authentication. It is not necessary to have data in your database to use this example.
This example uses the System.Data.Odbc Namespace, a .NET Framework Data Provider for ODBC.
using System;
using System.Data;
using System.Data.Odbc;
namespace redshift.amazon.com.docsamples
{
class ConnectToClusterExample
{
public static void Main(string[] args)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
// Server, e.g. "examplecluster.xyz.us-west-2.redshift.amazonaws.com"
string server = "***provide server name part of connection
string****";
// Port, e.g. "5439"
string port = "***provide port***";
// MasterUserName, e.g. "masteruser".
string masterUsername = "***provide master user name***";
// MasterUserPassword, e.g. "mypassword".
string masterUserPassword = "***provide master user password***";
// DBName, e.g. "dev"
string DBName = "***provide name of database***";
string query = "select * from information_schema.tables;";
try
{
// Create the ODBC connection string.
//Redshift ODBC Driver - 64 bits
/*
string connString = "Driver={Amazon Redshift (x64)};" +
String.Format("Server={0};Database={1};" +
"UID={2};PWD={3};Port={4};SSL=true;Sslmode=Require",
server, DBName, masterUsername,
masterUserPassword, port);
*/
//Redshift ODBC Driver - 32 bits
string connString = "Driver={Amazon Redshift (x86)};" +
String.Format("Server={0};Database={1};" +
"UID={2};PWD={3};Port={4};SSL=true;Sslmode=Require",
server, DBName, masterUsername,
masterUserPassword, port);
API Version 2012-12-01
172
Amazon Redshift Management Guide
Connecting to Clusters From Client Tools and Code
Vista de pagina 177
1 2 ... 173 174 175 176 177 178 179 180 181 182 183 ... 254 255

Comentarios a estos manuales

Sin comentarios