Meet us at at Real World in Orlando, Florida.

Platforms to show: All Mac Windows Linux Cross-Platform

The class SQLConnectionMBS

class SQLConnectionMBS
MBS Real Studio SQL Plugin (SQL),

class, SQL, MBS Real Studio SQL Plugin (SQL), class SQLConnectionMBS,
Plugin version: 9.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: The class for a SQL Plugin Database connection.
Example:
dim con as new SQLConnectionMBS

try

// where is the library?
con.SetFileOption con.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")

// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC

dim server as string = "192.168.1.80:3306@test"

con.Connect(server,"root","",SQLConnectionMBS.kMySQLClient)

MsgBox "We are connected!"

// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect

msgbox "We are disconnected!"

catch r as RuntimeException
MsgBox r.message

// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try

// on error rollback changes
con.Rollback

catch rr as runtimeexception
MsgBox rr.message
end try
end try
Notes: Supported databases: Oracle, Microsoft SQL Server, DB2, Sybase, Informix, InterBase/Firebird, SQLBase, MySQL, PostgreSQL and ODBC and SQLite

Values for autocommit property

ConstantValueDescription
kAutoCommitOff 0Autocommit is off.
kAutoCommitOn 1Autocommit is on.
kAutoCommitUnknown -1Autocommit unknown

The database client constants

ConstantValueDescription
kDB2Client 6DB2 client.
kFirebirdClient 4InterBase/Firebird client.
kInformixClient 7Informix client.
kInterBaseClient 4InterBase/Firebird client.
kMySQLClient 9MySQL client.
kODBCClient 1ODBC client.
kOracleClient 2Oracle client.

For Windows the file is "oci.dll", for Linux libclntsh.so and for Mac OS X libclntsh.dylib.
kPostgreSQLClient 10PostgreSQL client.
kSQLBaseClient 5SQLbase client.
kSQLiteClient 11SQLite client. Or spatialite.
kSQLServerClient 3Mircosoft SQL Server client.

You may need to download the client packages for accessing SQL Server. Files like the SQLNCLI dll may be missing. You can download for example the Feature Pack for Microsoft SQL Server 2005 from the microsoft download page.
kSybaseClient 8Sybase client.

Options to specify the library with SetFileOption

ConstantValueDescription
kOptionLibraryDB2 "DB2CLI.LIBS"for DB2.
kOptionLibraryFirebird "IBASE.LIBS"for Firebird.
kOptionLibraryInformix "INFCLI.LIBS"for Informix.
kOptionLibraryInterbase "IBASE.LIBS"for Interbase.
kOptionLibraryMySQL "MYSQL.LIBS"for MySQL. Library extension on Mac is ".dylib", on Linux ".so" and on Windows ".dll". You get this library with the MySQL download on their homepage.
kOptionLibraryODBC "ODBC.LIBS"for ODBC.
kOptionLibraryOracle "OCI8.LIBS"for Oracle.
kOptionLibraryPostgreSQL "LIBPQ.LIBS"for Postgre SQL.
kOptionLibrarySQLBase "SQLBASE.LIBS"for SQLbase.
kOptionLibrarySQLite "SQLITE.LIBS"for SQLite. Can also be the spatialite library.
kOptionLibrarySybaseComn "SYBCOMN.LIBS"for Sybase.
kOptionLibrarySybaseCS "SYBCS.LIBS"for Sybase.
kOptionLibrarySybaseCT "SYBCT.LIBS"for Sybase.
kOptionLibrarySybaseIntl "SYBINTL.LIBS"for Sybase.
kOptionLibrarySybaseTCL "SYBTCL.LIBS"for Sybase.

This class has no sub classes.

Some methods using this class:

Some properties using for this class:

Some examples which use this class:


The items on this page are in the following plugins: MBS Real Studio SQL Plugin.




Links
MBS REALbasic Plugins - Bilder aus Nickenich