Ibm Data Server DB2 Instrukcja Użytkownika Strona 277

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 298
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 276
Appendix A. Sample applications 263
$conn = db2_connect($dsn, '', '');
if ($conn) {
echo "Connection succeeded.\n";
echo "Closing connection...\n";
db2_close($conn);
echo "Connection closed.\n";
}
else {
echo db2_conn_errormsg(), "\n";
echo "Connection failed.\n";
}
?>
A.3 Ruby
Example A-3 shows the application used to demonstrate the deployment of the
DB2 PHP application.
Example: A-3 Sample Ruby application
# A sample Ruby application.
# Use this program to test connection to a database.
# Database connectivity information is read as command line arguments.
# Give arguments in the following order:
# hostname port_number database_name user password
#
# Run the application as following:
# ruby itso_rubyapp.rb hostname port_number database_name user password
#
require 'ibm_db'
if ARGV.length != 5
puts " ERROR: incorrect command line arguments.\n Use hostname port_number
database_name user_name password\n"
else
# Creating dsn from command line arguments.
dsn = ""
dsn << "HOSTNAME=" << ARGV[0] << \
";PORT=" << ARGV[1] << \
";DATABASE=" << ARGV[2] << \
Przeglądanie stron 276
1 2 ... 272 273 274 275 276 277 278 279 280 281 282 ... 297 298

Komentarze do niniejszej Instrukcji

Brak uwag